Skip to content

Commit

Permalink
functionMap - synchronized some of parameter names with PHP 8 stubs t…
Browse files Browse the repository at this point in the history
…o have the test always pass
  • Loading branch information
ondrejmirtes committed Oct 12, 2020
1 parent b87dba1 commit 71e7550
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions resources/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -3003,7 +3003,7 @@
'forward_static_call_array' => ['mixed', 'function'=>'callable', 'parameters'=>'array<int,mixed>'],
'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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Classes/InstantiationRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
]);
Expand Down Expand Up @@ -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,
],
]);
Expand Down Expand Up @@ -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<string> given.',
'Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, array<string> given.',
18,
],
[
'Parameter #2 ...$args of function sprintf expects bool|float|int|string|null, array<int, string> given.',
'Parameter #2 ...$values of function sprintf expects bool|float|int|string|null, array<int, string> 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,
],
]);
Expand All @@ -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,
],
]);
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
[
Expand Down

0 comments on commit 71e7550

Please sign in to comment.