@@ -221,8 +221,6 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
221221 $ innerParameters = $ innerParametersAcceptor ->getParameters ();
222222 $ innerArgs = $ innerFuncCall ->getArgs ();
223223
224- $ innerCalleeReflection = null ;
225-
226224 foreach ($ innerArgs as $ i => $ innerArg ) {
227225 $ argValue = $ innerArg ->value ;
228226 if ($ argValue instanceof Variable && $ argValue ->name === 'this ' ) {
@@ -240,17 +238,29 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
240238 continue ;
241239 }
242240
243- if ($ innerCalleeReflection === null && $ innerFuncCall ->name instanceof Expr) {
241+ $ innerCalleeReflections = [];
242+ if ($ innerFuncCall ->name instanceof Expr) {
244243 $ calledOnType = $ scope ->getType ($ innerFuncCall ->name );
245- $ callableAcceptors = $ calledOnType ->getCallableParametersAcceptors ($ scope );
246- $ innerCalleeReflection = count ($ callableAcceptors ) === 1
247- ? $ callableAcceptors [0 ]->getCalleeReflection ()
248- : false ;
244+ if (!$ calledOnType ->isCallable ()->no ()) {
245+ $ innerCalleeReflections = array_map (
246+ static fn (CallableParametersAcceptor $ callableAcceptor ) => $ callableAcceptor ->getCalleeReflection (),
247+ $ calledOnType ->getCallableParametersAcceptors ($ scope ),
248+ );
249+ }
250+ } elseif ($ this ->reflectionProvider ->hasFunction ($ innerFuncCall ->name , $ scope )) {
251+ $ innerCalleeReflections = [$ this ->reflectionProvider ->getFunction ($ innerFuncCall ->name , $ scope )];
249252 }
250- if ($ innerCalleeReflection === null ) {
251- $ innerCalleeReflection = false ;
253+
254+ if ($ innerCalleeReflections === []) {
255+ $ byRefType = $ nodeScopeResolver ->resolveByRefParameterType ($ innerFuncCall , null , $ innerParameter , $ scope );
256+ } else {
257+ $ byRefTypes = [];
258+ foreach ($ innerCalleeReflections as $ innerCalleeReflection ) {
259+ $ byRefTypes [] = $ nodeScopeResolver ->resolveByRefParameterType ($ innerFuncCall , $ innerCalleeReflection , $ innerParameter , $ scope );
260+ }
261+ $ byRefType = TypeCombinator::union (...$ byRefTypes );
252262 }
253- $ byRefType = $ nodeScopeResolver -> resolveByRefParameterType ( $ innerFuncCall , $ innerCalleeReflection !== false ? $ innerCalleeReflection : null , $ innerParameter , $ scope );
263+
254264 $ scope = $ nodeScopeResolver ->processVirtualAssign (
255265 $ scope ,
256266 $ storage ,
0 commit comments