@@ -175,7 +175,7 @@ public function processFirstClassCallable(
175175 $ errors = array_merge ($ errors , $ this ->processCall ($ scope , $ callerType , $ methodName , $ line , $ nodeHash ));
176176 }
177177
178- if ($ callNode instanceof FuncCall && $ callNode ->name instanceof Name) {
178+ if ($ callNode instanceof FuncCall && $ callNode ->name instanceof Name && $ this -> reflectionProvider -> hasFunction ( $ callNode -> name , $ scope ) ) {
179179 $ functionReflection = $ this ->reflectionProvider ->getFunction ($ callNode ->name , $ scope );
180180 $ errors = array_merge ($ errors , $ this ->processThrowType ($ functionReflection ->getThrowType (), $ scope , $ line , $ nodeHash ));
181181 }
@@ -427,7 +427,7 @@ private function whitelistAllowedCallables(CallLike $node, Scope $scope): void
427427
428428 } elseif ($ node instanceof FuncCall && $ node ->name instanceof Name) {
429429 $ callerType = null ;
430- $ methodReflection = $ this ->reflectionProvider -> getFunction ($ node ->name , $ scope );
430+ $ methodReflection = $ this ->getFunctionReflection ($ node ->name , $ scope );
431431
432432 } elseif ($ node instanceof FuncCall && $ this ->isFirstClassCallableOrClosureOrArrowFunction ($ node ->name )) { // immediately called callable syntax
433433 $ this ->allowedCallables [spl_object_hash ($ node ->name )] = true ;
@@ -534,4 +534,11 @@ private function buildError(
534534 return $ builder ->build ();
535535 }
536536
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+
537544}
0 commit comments