13
13
use TomasVotruba \UnusedPublic \Configuration ;
14
14
15
15
/**
16
- * @implements Collector<FuncCall , non-empty-array<string>|null>
16
+ * @implements Collector<Expr\Array_ , non-empty-array<string>|null>
17
17
*/
18
- final readonly class CallbackFunctionCollector implements Collector
18
+ final readonly class CallableTypeCollector implements Collector
19
19
{
20
20
public function __construct (
21
21
private Configuration $ configuration ,
@@ -24,11 +24,11 @@ public function __construct(
24
24
25
25
public function getNodeType (): string
26
26
{
27
- return FuncCall ::class;
27
+ return Expr \Array_ ::class;
28
28
}
29
29
30
30
/**
31
- * @param FuncCall $node
31
+ * @param Expr\Array_ $node
32
32
* @return string[]|null
33
33
*/
34
34
public function processNode (Node $ node , Scope $ scope ): ?array
@@ -37,16 +37,7 @@ public function processNode(Node $node, Scope $scope): ?array
37
37
return null ;
38
38
}
39
39
40
- if ($ this ->shouldSkipNode ($ node )) {
41
- return null ;
42
- }
43
-
44
- $ args = $ node ->getArgs ();
45
- if (count ($ args ) < 1 ) {
46
- return null ;
47
- }
48
-
49
- $ callableType = $ scope ->getType ($ args [0 ]->value );
40
+ $ callableType = $ scope ->getType ($ node );
50
41
if (! $ callableType instanceof ConstantArrayType) {
51
42
return null ;
52
43
}
@@ -72,20 +63,4 @@ public function processNode(Node $node, Scope $scope): ?array
72
63
return $ classMethodReferences ;
73
64
}
74
65
75
- /**
76
- * @param FuncCall $node
77
- */
78
- private function shouldSkipNode (Node $ node ): bool
79
- {
80
- // unable to resolve method name
81
- if ($ node ->name instanceof Expr) {
82
- return true ;
83
- }
84
-
85
- return !in_array (
86
- strtolower ($ node ->name ->toString ()),
87
- ['call_user_func ' , 'register_shutdown_function ' ],
88
- true
89
- );
90
- }
91
66
}
0 commit comments