@@ -175,7 +175,7 @@ public function processFirstClassCallable(
175
175
$ errors = array_merge ($ errors , $ this ->processCall ($ scope , $ callerType , $ methodName , $ line , $ nodeHash ));
176
176
}
177
177
178
- if ($ callNode instanceof FuncCall && $ callNode ->name instanceof Name) {
178
+ if ($ callNode instanceof FuncCall && $ callNode ->name instanceof Name && $ this -> reflectionProvider -> hasFunction ( $ callNode -> name , $ scope ) ) {
179
179
$ functionReflection = $ this ->reflectionProvider ->getFunction ($ callNode ->name , $ scope );
180
180
$ errors = array_merge ($ errors , $ this ->processThrowType ($ functionReflection ->getThrowType (), $ scope , $ line , $ nodeHash ));
181
181
}
@@ -427,7 +427,7 @@ private function whitelistAllowedCallables(CallLike $node, Scope $scope): void
427
427
428
428
} elseif ($ node instanceof FuncCall && $ node ->name instanceof Name) {
429
429
$ callerType = null ;
430
- $ methodReflection = $ this ->reflectionProvider -> getFunction ($ node ->name , $ scope );
430
+ $ methodReflection = $ this ->getFunctionReflection ($ node ->name , $ scope );
431
431
432
432
} elseif ($ node instanceof FuncCall && $ this ->isFirstClassCallableOrClosureOrArrowFunction ($ node ->name )) { // immediately called callable syntax
433
433
$ this ->allowedCallables [spl_object_hash ($ node ->name )] = true ;
@@ -534,4 +534,11 @@ private function buildError(
534
534
return $ builder ->build ();
535
535
}
536
536
537
+ private function getFunctionReflection (Name $ functionName , Scope $ scope ): ?FunctionReflection
538
+ {
539
+ return $ this ->reflectionProvider ->hasFunction ($ functionName , $ scope )
540
+ ? $ this ->reflectionProvider ->getFunction ($ functionName , $ scope )
541
+ : null ;
542
+ }
543
+
537
544
}
0 commit comments