Skip to content

Commit a3f1200

Browse files
phpstan-botclaude
andcommitted
Add bug-14596 tests to CallMethodsRuleTest and CallStaticMethodsRuleTest
Assert that positional arguments after named arguments on method calls and static method calls report the expected error instead of crashing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3dac478 commit a3f1200

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4078,4 +4078,17 @@ public function testBug8048(): void
40784078
$this->analyse([__DIR__ . '/data/bug-8048.php'], []);
40794079
}
40804080

4081+
public function testBug14596(): void
4082+
{
4083+
$this->checkThisOnly = false;
4084+
$this->checkNullables = true;
4085+
$this->checkUnionTypes = true;
4086+
$this->analyse([__DIR__ . '/data/bug-14596.php'], [
4087+
[
4088+
'Named argument cannot be followed by a positional argument.',
4089+
11,
4090+
],
4091+
]);
4092+
}
4093+
40814094
}

tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,4 +1021,15 @@ public function testBug11894(): void
10211021
$this->analyse([__DIR__ . '/data/bug-11894.php'], []);
10221022
}
10231023

1024+
public function testBug14596(): void
1025+
{
1026+
$this->checkThisOnly = false;
1027+
$this->analyse([__DIR__ . '/data/bug-14596.php'], [
1028+
[
1029+
'Named argument cannot be followed by a positional argument.',
1030+
12,
1031+
],
1032+
]);
1033+
}
1034+
10241035
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Bug14596Methods;
4+
5+
class Foo {
6+
public function bar(int $a, int $b, int $c, string ...$rest): void {}
7+
public static function baz(int $a, int $b, int $c, string ...$rest): void {}
8+
}
9+
10+
function (Foo $obj): void {
11+
$obj->bar(1, 2, 3, d: 'foo', 5);
12+
Foo::baz(1, 2, 3, d: 'foo', 5);
13+
};

0 commit comments

Comments
 (0)