com php-src: Make sure that params with null default are marked nullable: ext/readline/readline.stub.php ext/readline/readline_arginfo .h
ext/standard/basic_functions.stub.php scripts/de v/gen_stub.php

From: Date: Mon, 26 Aug 2019 12:34:28 +0000
Subject: com php-src: Make sure that params with null default are marked nullable: ext/readline/readline.stub.php ext/readline/readline_arginfo .h
ext/standard/basic_functions.stub.php scripts/de v/gen_stub.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108062@lists.php.net to get a copy of this message
Commit: 0c2d4d698c9743f75cb1adb6d485154192536242 Author: Nikita Popov <nikita.ppv@gmail.com> Mon, 26 Aug 2019 14:34:28 +0200 Parents: a47f170a7562d40d2f675600c641c616c2ebc592 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0c2d4d698c9743f75cb1adb6d485154192536242 Log: Make sure that params with null default are marked nullable Changed paths: M ext/readline/readline.stub.php M ext/readline/readline_arginfo.h M ext/standard/basic_functions.stub.php M scripts/dev/gen_stub.php Diff: diff --git a/ext/readline/readline.stub.php b/ext/readline/readline.stub.php index 64b433a..ba157b5 100644 --- a/ext/readline/readline.stub.php +++ b/ext/readline/readline.stub.php @@ -1,7 +1,7 @@ <?php /** @return string|false */ -function readline(string $prompt = null) {} +function readline(?string $prompt = null) {} /** @return mixed */ function readline_info(string $varname = UNKNOWN, string $newvalue = UNKNOWN) {} diff --git a/ext/readline/readline_arginfo.h b/ext/readline/readline_arginfo.h index e9ce57b..43c8fbc 100644 --- a/ext/readline/readline_arginfo.h +++ b/ext/readline/readline_arginfo.h @@ -1,7 +1,7 @@ /* This is a generated file, edit the .stub.php file instead. */ ZEND_BEGIN_ARG_INFO_EX(arginfo_readline, 0, 0, 0) - ZEND_ARG_TYPE_INFO(0, prompt, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, prompt, IS_STRING, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_readline_info, 0, 0, 0) diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index ea1d99f..0da6f99 100644 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -356,7 +356,7 @@ function inet_pton (string $ip_address) {} function metaphone(string $text, int $phones = 0) {} /* {{{ head.c */ -function header(string $string, bool $replace = true, int $http_response_code = null): void { } +function header(string $string, bool $replace = true, int $http_response_code = 0): void { } function header_remove(string $name = UNKNOWN): void { } diff --git a/scripts/dev/gen_stub..php b/scripts/dev/gen_stub.php index 47ff115..9fa14fc 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(

« previous php.cvs (#108062) next »