Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'], [
Expand Down
12 changes: 12 additions & 0 deletions tests/PHPStan/Rules/Functions/data/bug-14408.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Bug14408;

// This should report an error: sprintf does not accept unknown named parameters
sprintf(format: '%s', foo: 'bar');

// This should be fine: named parameter matches the signature
sprintf(format: '%s %s', values: 'hello');

// call_user_func should accept unknown named args (forwards to callback)
call_user_func('strtolower', str: 'HELLO');
Loading