diff --git a/src/Rules/FunctionCallParametersCheck.php b/src/Rules/FunctionCallParametersCheck.php index 57ae028018..5c3821aa4f 100644 --- a/src/Rules/FunctionCallParametersCheck.php +++ b/src/Rules/FunctionCallParametersCheck.php @@ -562,11 +562,13 @@ private function processArguments( $originalParametersByName = []; $unusedParametersByName = []; $errors = []; + $isNativelyVariadic = false; foreach ($parameters as $i => $parameter) { $parametersByName[$parameter->getName()] = $parameter; $originalParametersByName[$parameter->getName()] = $originalParameters[$i]; if ($parameter->isVariadic()) { + $isNativelyVariadic = true; continue; } @@ -603,7 +605,7 @@ private function processArguments( $parametersCount = count($parameters); if ( - !$parametersAcceptor->isVariadic() + !$isNativelyVariadic || $parametersCount <= 0 || $isBuiltin ) { diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 41a04a2420..b179c1ff0d 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -534,6 +534,21 @@ public function testBug4514(): void $this->analyse([__DIR__ . '/data/bug-4514.php'], []); } + #[RequiresPhp('>= 8.0')] + public function testBug13719(): void + { + $this->analyse([__DIR__ . '/data/bug-13719.php'], [ + [ + 'Unknown parameter $greetings in call to function Bug13719\non_variadic.', + 20, + ], + [ + 'Unknown parameter $greetings in call to function Bug13719\implicit_variadic.', + 27, + ], + ]); + } + public function testBug4530(): void { $this->analyse([__DIR__ . '/data/bug-4530.php'], []); diff --git a/tests/PHPStan/Rules/Functions/data/bug-13719.php b/tests/PHPStan/Rules/Functions/data/bug-13719.php new file mode 100644 index 0000000000..8a33eb50f3 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-13719.php @@ -0,0 +1,27 @@ +