File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
tests/PHPStan/Rules/Functions Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -545,6 +545,20 @@ public function testBugNumberFormatNamedArguments(): void
545545 $ this ->analyse ([__DIR__ . '/data/number-format-named-arguments.php ' ], []);
546546 }
547547
548+ public function testBug14408 (): void
549+ {
550+ if (PHP_VERSION_ID < 80000 ) {
551+ $ this ->markTestSkipped ('Test requires PHP 8.0 ' );
552+ }
553+
554+ $ this ->analyse ([__DIR__ . '/data/bug-14408.php ' ], [
555+ [
556+ 'Unknown parameter $foo in call to function sprintf. ' ,
557+ 6 ,
558+ ],
559+ ]);
560+ }
561+
548562 public function testArrayReduceCallback (): void
549563 {
550564 $ this ->analyse ([__DIR__ . '/data/array_reduce.php ' ], [
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug14408 ;
4+
5+ // This should report an error: sprintf does not accept unknown named parameters
6+ sprintf (format: '%s ' , foo: 'bar ' );
7+
8+ // This should be fine: named parameter matches the signature
9+ sprintf (format: '%s %s ' , values: 'hello ' );
10+
11+ // call_user_func should accept unknown named args (forwards to callback)
12+ call_user_func ('strtolower ' , str: 'HELLO ' );
You can’t perform that action at this time.
0 commit comments