File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ private function getMethodName(CallLike $call): ?string
200
200
*/
201
201
private function getReflectionsWithMethod (Type $ type , string $ methodName ): iterable
202
202
{
203
- $ classReflections = $ type ->getObjectClassReflections ();
203
+ $ classReflections = $ type ->getObjectTypeOrClassStringObjectType ()-> getObjectClassReflections ();
204
204
205
205
foreach ($ classReflections as $ classReflection ) {
206
206
if ($ classReflection ->hasMethod ($ methodName )) {
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ public static function provideFiles(): iterable
90
90
yield 'dead-in-parent-1 ' => [__DIR__ . '/data/DeadMethodRule/dead-in-parent-1.php ' ];
91
91
yield 'indirect-interface ' => [__DIR__ . '/data/DeadMethodRule/indirect-interface.php ' ];
92
92
yield 'attribute ' => [__DIR__ . '/data/DeadMethodRule/attribute.php ' ];
93
+ yield 'call-on-class-string ' => [__DIR__ . '/data/DeadMethodRule/class-string.php ' ];
93
94
yield 'array-map-1 ' => [__DIR__ . '/data/DeadMethodRule/array-map-1.php ' ];
94
95
yield 'provider-default ' => [__DIR__ . '/data/DeadMethodRule/providers/default.php ' ];
95
96
yield 'provider-symfony ' => [__DIR__ . '/data/DeadMethodRule/providers/symfony.php ' , 80_000 ];
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace ClassStringCall ;
4
+
5
+ class ClassWithMethod {
6
+
7
+ public static function someMethod (): void {}
8
+ }
9
+
10
+ /**
11
+ * @param class-string<ClassWithMethod> $class
12
+ */
13
+ function test (string $ class ): void {
14
+ $ class ::someMethod ();
15
+ }
You can’t perform that action at this time.
0 commit comments