From 9fdc774e7c3fc41a9381c26ca424a4569bb8af10 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 25 Oct 2025 15:20:14 +0200 Subject: [PATCH 1/2] Report unknown parameter for implicit variadic methods --- src/Rules/FunctionCallParametersCheck.php | 4 ++- .../CallToFunctionParametersRuleTest.php | 15 +++++++++++ .../Rules/Functions/data/bug-13719.php | 25 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/PHPStan/Rules/Functions/data/bug-13719.php 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..e5c6c94bec 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 non_variadic.', + 18, + ], + [ + 'Unknown parameter $greetings in call to function implicit_variadic.', + 25, + ], + ]); + } + 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..de69633f52 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-13719.php @@ -0,0 +1,25 @@ + Date: Sat, 25 Oct 2025 17:40:39 +0200 Subject: [PATCH 2/2] Fix namespace --- .../Rules/Functions/CallToFunctionParametersRuleTest.php | 8 ++++---- tests/PHPStan/Rules/Functions/data/bug-13719.php | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index e5c6c94bec..b179c1ff0d 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -539,12 +539,12 @@ public function testBug13719(): void { $this->analyse([__DIR__ . '/data/bug-13719.php'], [ [ - 'Unknown parameter $greetings in call to function non_variadic.', - 18, + 'Unknown parameter $greetings in call to function Bug13719\non_variadic.', + 20, ], [ - 'Unknown parameter $greetings in call to function implicit_variadic.', - 25, + 'Unknown parameter $greetings in call to function Bug13719\implicit_variadic.', + 27, ], ]); } diff --git a/tests/PHPStan/Rules/Functions/data/bug-13719.php b/tests/PHPStan/Rules/Functions/data/bug-13719.php index de69633f52..8a33eb50f3 100644 --- a/tests/PHPStan/Rules/Functions/data/bug-13719.php +++ b/tests/PHPStan/Rules/Functions/data/bug-13719.php @@ -1,5 +1,7 @@