From 292a1aeb59f348aabed58ac4fbc1d467dde3fcea Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 15 Nov 2019 17:33:37 +0100 Subject: 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. --- scripts/dev/gen_stub.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'scripts') 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'); } -- cgit v1.2.1