Skip to content

Commit 4fd7a28

Browse files
phpstan-botclaude
andcommitted
Add test cases for trait method collision resolution with insteadof and as alias
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 984090f commit 4fd7a28

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/PHPStan/Rules/Classes/data/trait-method-collisions.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,44 @@ class PartialCollision
7575
{
7676
use TraitC, TraitD;
7777
}
78+
79+
trait TraitE
80+
{
81+
public function smallTalk(): void
82+
{
83+
}
84+
85+
public function bigTalk(): void
86+
{
87+
}
88+
}
89+
90+
trait TraitF
91+
{
92+
public function smallTalk(): void
93+
{
94+
}
95+
96+
public function bigTalk(): void
97+
{
98+
}
99+
}
100+
101+
// Should not report - all collisions resolved via insteadof in both directions
102+
class Talker
103+
{
104+
use TraitE, TraitF {
105+
TraitF::smallTalk insteadof TraitE;
106+
TraitE::bigTalk insteadof TraitF;
107+
}
108+
}
109+
110+
// Should not report - collisions resolved via insteadof with alias
111+
class AliasedTalker
112+
{
113+
use TraitE, TraitF {
114+
TraitF::smallTalk insteadof TraitE;
115+
TraitE::bigTalk insteadof TraitF;
116+
TraitF::bigTalk as talk;
117+
}
118+
}

0 commit comments

Comments
 (0)