summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-11-15 17:33:37 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-11-15 17:33:37 +0100
commit292a1aeb59f348aabed58ac4fbc1d467dde3fcea (patch)
treed53c6bc68ba16c2e19e8ba9d1d863b0715bcb863 /scripts
parent0cec268d15e5aded8692ee8076e93d2839725918 (diff)
downloadphp-git-292a1aeb59f348aabed58ac4fbc1d467dde3fcea.tar.gz
Support union types for args in gen stubs
Using this requires care! The zpp implementation for this union must be consistent with the arginfo implementation! Apart from array|object, this is probably only the case for int|float right now.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dev/gen_stub.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/scripts/dev/gen_stub.php b/scripts/dev/gen_stub.php
index c6f9557fb4..253c188b2a 100755
--- a/scripts/dev/gen_stub.php
+++ b/scripts/dev/gen_stub.php
@@ -532,8 +532,7 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
$argKind = $argInfo->isVariadic ? "ARG_VARIADIC" : "ARG";
$argType = $argInfo->type;
if ($argType !== null) {
- $simpleArgType = $argType->tryToSimpleType();
- if ($simpleArgType !== null) {
+ if (null !== $simpleArgType = $argType->tryToSimpleType()) {
if ($simpleArgType->isBuiltin) {
$code .= sprintf(
"\tZEND_%s_TYPE_INFO(%s, %s, %s, %d)\n",
@@ -547,6 +546,15 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
$simpleArgType->toEscapedName(), $argType->isNullable()
);
}
+ } else if (null !== $representableType = $argType->tryToRepresentableType()) {
+ if ($representableType->classType !== null) {
+ throw new Exception('Unimplemented');
+ }
+ $code .= sprintf(
+ "\tZEND_%s_TYPE_MASK(%s, %s, %s)\n",
+ $argKind, $argInfo->getSendByString(), $argInfo->name,
+ $representableType->toTypeMask()
+ );
} else {
throw new Exception('Unimplemented');
}