From 0c2d4d698c9743f75cb1adb6d485154192536242 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 26 Aug 2019 14:34:28 +0200 Subject: [PATCH] Make sure that params with null default are marked nullable --- ext/readline/readline.stub.php | 2 +- ext/readline/readline_arginfo.h | 2 +- ext/standard/basic_functions.stub.php | 2 +- scripts/dev/gen_stub.php | 11 ++++++++++- 4 files changed, 13 insertions(+), 4 deletions(-) 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( -- 2.50.1