From 0c2d4d698c9743f75cb1adb6d485154192536242 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 26 Aug 2019 14:34:28 +0200 Subject: Make sure that params with null default are marked nullable --- scripts/dev/gen_stub.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'scripts') 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 @@ 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( -- cgit v1.2.1