From 71e7550ba355fd9be672f6efa623216509926b15 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Mon, 12 Oct 2020 10:46:08 +0200 Subject: [PATCH] functionMap - synchronized some of parameter names with PHP 8 stubs to have the test always pass --- resources/functionMap.php | 18 +++++++++--------- .../NativeFunctionReflectionProvider.php | 2 +- .../Rules/Classes/InstantiationRuleTest.php | 2 +- .../CallToFunctionParametersRuleTest.php | 16 ++++++++-------- .../Rules/Methods/CallMethodsRuleTest.php | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/resources/functionMap.php b/resources/functionMap.php index 28957528d5..229deb0efb 100644 --- a/resources/functionMap.php +++ b/resources/functionMap.php @@ -1796,7 +1796,7 @@ 'debugger_print' => [''], 'debugger_start_debug' => [''], 'decbin' => ['string', 'decimal_number'=>'int'], -'dechex' => ['string', 'decimal_number'=>'int'], +'dechex' => ['string', 'num'=>'int'], 'decoct' => ['string', 'decimal_number'=>'int'], 'define' => ['bool', 'constant_name'=>'string', 'value'=>'mixed', 'case_insensitive='=>'bool'], 'define_syslog_variables' => ['void'], @@ -3003,7 +3003,7 @@ 'forward_static_call_array' => ['mixed', 'function'=>'callable', 'parameters'=>'array'], 'fpassthru' => ['int|false', 'fp'=>'resource'], 'fpm_get_status' => ['array|false'], -'fprintf' => ['int', 'stream'=>'resource', 'format'=>'string', '...args='=>'string|int|float'], +'fprintf' => ['int', 'stream'=>'resource', 'format'=>'string', '...values='=>'string|int|float'], 'fputcsv' => ['int|false', 'fp'=>'resource', 'fields'=>'array', 'delimiter='=>'string', 'enclosure='=>'string', 'escape_char='=>'string'], 'fputs' => ['int|false', 'fp'=>'resource', 'str'=>'string', 'length='=>'int'], 'fread' => ['string|false', 'fp'=>'resource', 'length'=>'int'], @@ -8845,7 +8845,7 @@ 'prev' => ['mixed', '&rw_array_arg'=>'array'], 'print' => ['int', 'arg'=>'string'], 'print_r' => ['string|true', 'var'=>'mixed', 'return='=>'bool'], -'printf' => ['int', 'format'=>'string', '...args='=>'string|int|float'], +'printf' => ['int', 'format'=>'string', '...values='=>'string|int|float'], 'proc_close' => ['int', 'process'=>'resource'], 'proc_get_status' => ['array{command: string, pid: int, running: bool, signaled: bool, stopped: bool, exitcode: int, termsig: int, stopsig: int}|false', 'process'=>'resource'], 'proc_nice' => ['bool', 'priority'=>'int'], @@ -9875,7 +9875,7 @@ 'register_tick_function' => ['bool', 'function'=>'callable(): void', '...args='=>'mixed'], 'rename' => ['bool', 'old_name'=>'string', 'new_name'=>'string', 'context='=>'resource'], 'rename_function' => ['bool', 'original_name'=>'string', 'new_name'=>'string'], -'reset' => ['mixed', '&rw_array_arg'=>'array'], +'reset' => ['mixed', '&rw_array'=>'array'], 'ResourceBundle::__construct' => ['void', 'locale'=>'string', 'bundlename'=>'string', 'fallback='=>'bool'], 'ResourceBundle::count' => ['int'], 'ResourceBundle::create' => ['?ResourceBundle', 'locale'=>'string', 'bundlename'=>'string', 'fallback='=>'bool'], @@ -10141,7 +10141,7 @@ 'SessionUpdateTimestampHandler::validateId' => ['char', 'id'=>'string'], 'SessionUpdateTimestampHandlerInterface::updateTimestamp' => ['bool', 'key'=>'string', 'val'=>'string'], 'SessionUpdateTimestampHandlerInterface::validateId' => ['bool', 'key'=>'string'], -'set_error_handler' => ['?callable', 'error_handler'=>'null|callable(int,string,string,int,array):bool|callable(int,string,string,int):bool|callable(int,string,string):bool|callable(int,string):bool', 'error_types='=>'int'], +'set_error_handler' => ['?callable', 'callback'=>'null|callable(int,string,string,int,array):bool|callable(int,string,string,int):bool|callable(int,string,string):bool|callable(int,string):bool', 'error_types='=>'int'], 'set_exception_handler' => ['null|callable(Throwable):void', 'exception_handler'=>'null|callable(Throwable):void'], 'set_file_buffer' => ['int', 'fp'=>'resource', 'buffer'=>'int'], 'set_include_path' => ['string', 'new_include_path'=>'string'], @@ -10232,7 +10232,7 @@ 'SimpleXMLElement::addChild' => ['SimpleXMLElement', 'name'=>'string', 'value='=>'string', 'ns='=>'string'], 'SimpleXMLElement::asXML' => ['string|bool', 'filename='=>'string'], 'SimpleXMLElement::attributes' => ['SimpleXMLElement|null', 'ns='=>'string', 'is_prefix='=>'bool'], -'SimpleXMLElement::children' => ['SimpleXMLElement', 'ns='=>'string|null', 'is_prefix='=>'bool'], +'SimpleXMLElement::children' => ['SimpleXMLElement', 'namespaceOrPrefix='=>'string|null', 'is_prefix='=>'bool'], 'SimpleXMLElement::count' => ['int'], 'SimpleXMLElement::getDocNamespaces' => ['string[]', 'recursive='=>'bool', 'from_root='=>'bool'], 'SimpleXMLElement::getName' => ['string'], @@ -10298,9 +10298,9 @@ 'SoapClient::__setSoapHeaders' => ['bool', 'soapheaders='=>''], 'SoapClient::__soapCall' => ['', 'function_name'=>'string', 'arguments'=>'array', 'options='=>'array', 'input_headers='=>'SoapHeader|array', '&w_output_headers='=>'array'], 'SoapClient::SoapClient' => ['object', 'wsdl'=>'mixed', 'options='=>'array|null'], -'SoapFault::__construct' => ['void', 'faultcode'=>'string', 'faultstring'=>'string', 'faultactor='=>'string', 'detail='=>'string', 'faultname='=>'string', 'headerfault='=>'string'], +'SoapFault::__construct' => ['void', 'faultcode'=>'string', 'string'=>'string', 'faultactor='=>'string', 'detail='=>'string', 'faultname='=>'string', 'headerfault='=>'string'], 'SoapFault::__toString' => ['string'], -'SoapFault::SoapFault' => ['object', 'faultcode'=>'string', 'faultstring'=>'string', 'faultactor='=>'string', 'detail='=>'string', 'faultname='=>'string', 'headerfault='=>'string'], +'SoapFault::SoapFault' => ['object', 'faultcode'=>'string', 'string'=>'string', 'faultactor='=>'string', 'detail='=>'string', 'faultname='=>'string', 'headerfault='=>'string'], 'SoapHeader::__construct' => ['void', 'namespace'=>'string', 'name'=>'string', 'data='=>'mixed', 'mustunderstand='=>'bool', 'actor='=>'string'], 'SoapHeader::SoapHeader' => ['object', 'namespace'=>'string', 'name'=>'string', 'data='=>'mixed', 'mustunderstand='=>'bool', 'actor='=>'string'], 'SoapParam::__construct' => ['void', 'data'=>'mixed', 'name'=>'string'], @@ -11400,7 +11400,7 @@ 'Spoofchecker::setAllowedLocales' => ['void', 'locale_list'=>'string'], 'Spoofchecker::setChecks' => ['void', 'checks'=>'long'], 'Spoofchecker::setRestrictionLevel' => ['void', 'restriction_level'=>'int'], -'sprintf' => ['string', 'format'=>'string', '...args='=>'string|int|float|bool'], +'sprintf' => ['string', 'format'=>'string', '...values='=>'string|int|float|bool'], 'sql_regcase' => ['string', 'string'=>'string'], 'SQLite3::__construct' => ['void', 'filename'=>'string', 'flags='=>'int', 'encryption_key='=>'string|null'], 'SQLite3::busyTimeout' => ['bool', 'msecs'=>'int'], diff --git a/src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php b/src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php index 8f9766177d..4b040cdf9e 100644 --- a/src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php +++ b/src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php @@ -53,7 +53,7 @@ public function findFunctionReflection(string $functionName): ?NativeFunctionRef array_map(static function (ParameterSignature $parameterSignature) use ($lowerCasedFunctionName): NativeParameterReflection { $type = $parameterSignature->getType(); if ( - $parameterSignature->getName() === 'args' + $parameterSignature->getName() === 'values' && ( $lowerCasedFunctionName === 'printf' || $lowerCasedFunctionName === 'sprintf' diff --git a/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php b/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php index df1c4f4098..d2068de716 100644 --- a/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php +++ b/tests/PHPStan/Rules/Classes/InstantiationRuleTest.php @@ -201,7 +201,7 @@ public function testSoap(): void [__DIR__ . '/data/instantiation-soap.php'], [ [ - 'Parameter #2 $faultstring of class SoapFault constructor expects string, int given.', + 'Parameter #2 $string of class SoapFault constructor expects string, int given.', 6, ], ] diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 09fff9144e..23b684b9f1 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -43,7 +43,7 @@ public function testCallToFunctionWithIncorrectParameters(): void 14, ], [ - 'Parameter #1 $error_handler of function set_error_handler expects (callable(int, string, string, int, array): bool)|null, Closure(mixed, mixed, mixed, mixed): void given.', + 'Parameter #1 $callback of function set_error_handler expects (callable(int, string, string, int, array): bool)|null, Closure(mixed, mixed, mixed, mixed): void given.', 16, ], ]); @@ -220,7 +220,7 @@ public function testPassingNonVariableToParameterPassedByReference(): void 33, ], [ - 'Parameter #1 $array_arg of function reset expects array, null given.', + 'Parameter #1 $array of function reset expects array, null given.', 39, ], ]); @@ -311,19 +311,19 @@ public function testUnpackOperator(): void { $this->analyse([__DIR__ . '/data/unpack-operator.php'], [ [ - 'Parameter #2 ...$args of function sprintf expects bool|float|int|string|null, array given.', + 'Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, array given.', 18, ], [ - 'Parameter #2 ...$args of function sprintf expects bool|float|int|string|null, array given.', + 'Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, array given.', 19, ], [ - 'Parameter #2 ...$args of function sprintf expects bool|float|int|string|null, UnpackOperator\Foo given.', + 'Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, UnpackOperator\Foo given.', 22, ], [ - 'Parameter #2 ...$args of function printf expects bool|float|int|string|null, UnpackOperator\Foo given.', + 'Parameter #2 ...$values of function printf expects bool|float|int|string|null, UnpackOperator\Foo given.', 24, ], ]); @@ -333,11 +333,11 @@ public function testFunctionWithNumericParameterThatCreatedByAddition(): void { $this->analyse([__DIR__ . '/data/function-with-int-parameter-that-created-by-addition.php'], [ [ - 'Parameter #1 $decimal_number of function dechex expects int, float|int given.', + 'Parameter #1 $num of function dechex expects int, float|int given.', 9, ], [ - 'Parameter #1 $decimal_number of function dechex expects int, float|int given.', + 'Parameter #1 $num of function dechex expects int, float|int given.', 40, ], ]); diff --git a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php index 8a49038be9..530f587e78 100644 --- a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php @@ -388,7 +388,7 @@ public function testCallMethods(): void 921, ], [ - 'Parameter #1 $ns of method SimpleXMLElement::children() expects string|null, int given.', + 'Parameter #1 $namespaceOrPrefix of method SimpleXMLElement::children() expects string|null, int given.', 942, ], [