mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Make sure that params with null default are marked nullable
This commit is contained in:
parent
a47f170a75
commit
0c2d4d698c
4 changed files with 13 additions and 4 deletions
|
@ -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) {}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 { }
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue