33namespace PHPStan \Rules \DeadCode ;
44
55use PhpParser \Node ;
6- use PhpParser \Node \Expr \ FuncCall ;
6+ use PhpParser \Node \Stmt \ Expression ;
77use PHPStan \Analyser \Scope ;
88use PHPStan \Collectors \Collector ;
99use PHPStan \Reflection \ReflectionProvider ;
1010
1111/**
12- * @implements Collector<FuncCall , array{string, int}>
12+ * @implements Collector<Node\Stmt\Expression , array{string, int}>
1313 */
1414class PossiblyPureFuncCallCollector implements Collector
1515{
@@ -20,20 +20,23 @@ public function __construct(private ReflectionProvider $reflectionProvider)
2020
2121 public function getNodeType (): string
2222 {
23- return FuncCall ::class;
23+ return Expression ::class;
2424 }
2525
2626 public function processNode (Node $ node , Scope $ scope )
2727 {
28- if (!$ node ->name instanceof Node \Name) {
28+ if (!$ node ->expr instanceof Node \Expr \FuncCall) {
29+ return null ;
30+ }
31+ if (!$ node ->expr ->name instanceof Node \Name) {
2932 return null ;
3033 }
3134
32- if (!$ this ->reflectionProvider ->hasFunction ($ node ->name , $ scope )) {
35+ if (!$ this ->reflectionProvider ->hasFunction ($ node ->expr -> name , $ scope )) {
3336 return null ;
3437 }
3538
36- $ functionReflection = $ this ->reflectionProvider ->getFunction ($ node ->name , $ scope );
39+ $ functionReflection = $ this ->reflectionProvider ->getFunction ($ node ->expr -> name , $ scope );
3740 if (!$ functionReflection ->isPure ()->maybe ()) {
3841 return null ;
3942 }
0 commit comments