Skip to content

Commit 89fb038

Browse files
phpstan-botclaude
andcommitted
Add test cases for wrong named argument types on union type with different parameter order
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5edbda6 commit 89fb038

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4112,7 +4112,24 @@ public function testBug14661(): void
41124112
$this->checkThisOnly = false;
41134113
$this->checkNullables = true;
41144114
$this->checkUnionTypes = true;
4115-
$this->analyse([__DIR__ . '/data/bug-14661.php'], []);
4115+
$this->analyse([__DIR__ . '/data/bug-14661.php'], [
4116+
[
4117+
'Parameter $a of method Bug14661\A::differentTypes() expects int, string given.',
4118+
76,
4119+
],
4120+
[
4121+
'Parameter $b of method Bug14661\A::differentTypes() expects string, int given.',
4122+
76,
4123+
],
4124+
[
4125+
'Parameter $a of method Bug14661\A::differentTypes() expects int, string given.',
4126+
77,
4127+
],
4128+
[
4129+
'Parameter $b of method Bug14661\A::differentTypes() expects string, int given.',
4130+
77,
4131+
],
4132+
]);
41164133
}
41174134

41184135
}

tests/PHPStan/Rules/Methods/data/bug-14661.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ function differentTypes(A|B $obj): void
7171
$obj->differentTypes(b: 'hello', a: 1);
7272
}
7373

74+
function differentTypesErrors(A|B $obj): void
75+
{
76+
$obj->differentTypes(a: 'hello', b: 1);
77+
$obj->differentTypes(b: 1, a: 'hello');
78+
}
79+
7480
function threeWayUnion(A|B|C $obj): void
7581
{
7682
$obj->mixedOrder(target: 'value');

0 commit comments

Comments
 (0)