summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-08-26 14:34:28 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-08-26 14:34:28 +0200
commit0c2d4d698c9743f75cb1adb6d485154192536242 (patch)
tree74ae301780b0149932fe53ea35b5839f34a0513a /scripts
parenta47f170a7562d40d2f675600c641c616c2ebc592 (diff)
downloadphp-git-0c2d4d698c9743f75cb1adb6d485154192536242.tar.gz
Make sure that params with null default are marked nullable
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dev/gen_stub.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/dev/gen_stub.php b/scripts/dev/gen_stub.php
index 47ff115da1..9fa14fc662 100755
--- a/scripts/dev/gen_stub.php
+++ b/scripts/dev/gen_stub.php
@@ -2,6 +2,7 @@
<?php declare(strict_types=1);
use PhpParser\Node;
+use PhpParser\Node\Expr;
use PhpParser\Node\Stmt;
error_reporting(E_ALL);
@@ -38,7 +39,7 @@ function processStubFile(string $stubFile) {
$arginfoCode = generateArgInfoCode($funcInfos);
file_put_contents($arginfoFile, $arginfoCode);
} catch (Exception $e) {
- echo "Caught {$e->getMessage()} while processing $stubFile\n";
+ echo "In $stubFile:\n{$e->getMessage()}\n";
exit(1);
}
}
@@ -230,6 +231,14 @@ function parseFunctionLike(string $name, Node\FunctionLike $func, ?string $cond)
throw new Exception("Error in function $name: only the last parameter can be variadic");
}
+ if ($param->default instanceof Expr\ConstFetch &&
+ $param->default->name->toLowerString() === "null" &&
+ $param->type && !($param->type instanceof Node\NullableType)
+ ) {
+ throw new Exception(
+ "Parameter $varName of function $name has null default, but is not nullable");
+ }
+
$foundVariadic = $param->variadic;
$args[] = new ArgInfo(