From 555da34a492cfbef6ad967d159c214e04e06afaf Mon Sep 17 00:00:00 2001 From: Pascal CESCON - Amoifr Date: Wed, 8 Apr 2026 18:15:55 +0200 Subject: [PATCH] Add test for unknown named parameters on native variadic functions Adds a regression test for #14408 verifying that unknown named arguments passed to native variadic functions like sprintf() are properly detected. --- .../Functions/CallToFunctionParametersRuleTest.php | 14 ++++++++++++++ tests/PHPStan/Rules/Functions/data/bug-14408.php | 12 ++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/PHPStan/Rules/Functions/data/bug-14408.php diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index a6513f03cb1..e76e464513d 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -545,6 +545,20 @@ public function testBugNumberFormatNamedArguments(): void $this->analyse([__DIR__ . '/data/number-format-named-arguments.php'], []); } + public function testBug14408(): void + { + if (PHP_VERSION_ID < 80000) { + $this->markTestSkipped('Test requires PHP 8.0'); + } + + $this->analyse([__DIR__ . '/data/bug-14408.php'], [ + [ + 'Unknown parameter $foo in call to function sprintf.', + 6, + ], + ]); + } + public function testArrayReduceCallback(): void { $this->analyse([__DIR__ . '/data/array_reduce.php'], [ diff --git a/tests/PHPStan/Rules/Functions/data/bug-14408.php b/tests/PHPStan/Rules/Functions/data/bug-14408.php new file mode 100644 index 00000000000..725821c9dc2 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-14408.php @@ -0,0 +1,12 @@ +