diff options
| author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-05-25 17:30:49 +0200 |
|---|---|---|
| committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-05-25 17:30:57 +0200 |
| commit | b3718430de781647676b5ec2b2b004c310e25e4b (patch) | |
| tree | 0725481b1f272fca750fd6ac00546c68ce030375 /build | |
| parent | cbf86efc218e203ec692941aab8ab8077ab63f1b (diff) | |
| download | php-git-b3718430de781647676b5ec2b2b004c310e25e4b.tar.gz | |
Annotate internal functions with the mixed type
Closes GH-5618
Diffstat (limited to 'build')
| -rwxr-xr-x | build/gen_stub.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/build/gen_stub.php b/build/gen_stub.php index 4846452219..eb00b34136 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -65,6 +65,10 @@ class SimpleType { public static function fromNode(Node $node) { if ($node instanceof Node\Name) { + if ($node->toString() === "mixed") { + return new SimpleType($node->toString(), true); + } + assert($node->isFullyQualified()); return new SimpleType($node->toString(), false); } @@ -97,6 +101,8 @@ class SimpleType { return "IS_VOID"; case "callable": return "IS_CALLABLE"; + case "mixed": + return "IS_MIXED"; default: throw new Exception("Not implemented: $this->name"); } @@ -123,6 +129,8 @@ class SimpleType { return "MAY_BE_OBJECT"; case "callable": return "MAY_BE_CALLABLE"; + case "mixed": + return "MAY_BE_ANY"; default: throw new Exception("Not implemented: $this->name"); } @@ -637,8 +645,11 @@ function parseFunctionLike( $param->default->name->toLowerString() === "null" && $type && !$type->isNullable() ) { - throw new Exception( - "Parameter $varName of function $name has null default, but is not nullable"); + $simpleType = $type->tryToSimpleType(); + if ($simpleType === null || $simpleType->name !== "mixed") { + throw new Exception( + "Parameter $varName of function $name has null default, but is not nullable"); + } } $foundVariadic = $param->variadic; |
