From: Nikita Popov Date: Mon, 26 Aug 2019 12:34:28 +0000 (+0200) Subject: Make sure that params with null default are marked nullable X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c2d4d698c9743f75cb1adb6d485154192536242;p=php Make sure that params with null default are marked nullable --- diff --git a/ext/readline/readline.stub.php b/ext/readline/readline.stub.php index 64b433a943..ba157b54e4 100644 --- a/ext/readline/readline.stub.php +++ b/ext/readline/readline.stub.php @@ -1,7 +1,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(