@@ -311,6 +311,10 @@ private function processClassExpr(Stmt $stmt, StaticCall $expr, Expr $class, Gen
311311 }
312312 $ scope = $ classResult ->scope ;
313313
314+ $ normalizedMethodCall = $ expr ;
315+ $ methodReflection = null ;
316+ $ parametersAcceptor = null ;
317+ $ staticMethodCalledOnType = TypeCombinator::removeNull ($ classResult ->type )->getObjectTypeOrClassStringObjectType ();
314318 if ($ expr ->name instanceof Expr) {
315319 $ nameResult = yield new ExprAnalysisRequest ($ stmt , $ expr ->name , $ scope , $ context ->enterDeep (), $ alternativeNodeCallback );
316320 $ hasYield = $ hasYield || $ nameResult ->hasYield ;
@@ -344,7 +348,6 @@ private function processClassExpr(Stmt $stmt, StaticCall $expr, Expr $class, Gen
344348 $ nativeMethodReturnType = $ nativeMethodReturnTypeGen ->getReturn ();
345349 }
346350
347- $ staticMethodCalledOnType = TypeCombinator::removeNull ($ classResult ->type )->getObjectTypeOrClassStringObjectType ();
348351 $ methodName = $ expr ->name ->toString ();
349352 $ staticMethodCalledOnType = $ scope ->filterTypeWithMethod ($ staticMethodCalledOnType , $ methodName );
350353 if ($ staticMethodCalledOnType !== null && $ staticMethodCalledOnType ->hasMethod ($ methodName )->yes ()) {
@@ -357,31 +360,35 @@ private function processClassExpr(Stmt $stmt, StaticCall $expr, Expr $class, Gen
357360 $ methodReflection ->getNamedArgumentsVariants (),
358361 )))->value ;
359362 yield new RestoreStorageRequest ($ storage );
360- $ normalizedMethodCall = ArgumentsNormalizer::reorderStaticCallArguments ($ parametersAcceptor , $ expr );
361- $ methodReturnTypeGen = $ this ->methodCallHelper ->methodCallReturnType (
362- $ scope ,
363- $ methodReflection ,
364- $ parametersAcceptor ,
365- $ normalizedMethodCall ,
366- $ staticMethodCalledOnType ->getObjectClassNames (),
367- );
368- yield from $ methodReturnTypeGen ;
369- $ methodReturnType = $ methodReturnTypeGen ->getReturn ();
370- if ($ methodReturnType === null ) {
371- $ methodReturnType = new ErrorType ();
372- } else {
373- $ methodReturnTypeGen = $ this ->nullsafeShortCircuitingHelper ->getNullsafeShortCircuitingType ($ class , $ methodReturnType );
374- yield from $ methodReturnTypeGen ;
375- $ methodReturnType = $ methodReturnTypeGen ->getReturn ();
376- }
377- } else {
378- $ methodReturnType = new ErrorType ();
363+ $ normalizedMethodCall = ArgumentsNormalizer::reorderStaticCallArguments ($ parametersAcceptor , $ expr ) ?? $ expr ;
379364 }
380365 }
381366
382- $ argsResultGen = $ this ->argsHandler ->processArgs ($ stmt , null , null , null , $ expr , $ scope , $ context , $ alternativeNodeCallback );
367+ $ argsResultGen = $ this ->argsHandler ->processArgs ($ stmt , null , null , null , $ normalizedMethodCall , $ scope , $ context , $ alternativeNodeCallback );
383368 yield from $ argsResultGen ;
384369 $ argsResult = $ argsResultGen ->getReturn ();
370+
371+ if ($ methodReflection !== null && $ parametersAcceptor !== null && $ staticMethodCalledOnType !== null ) {
372+ $ methodReturnTypeGen = $ this ->methodCallHelper ->methodCallReturnType (
373+ $ scope ,
374+ $ methodReflection ,
375+ $ parametersAcceptor ,
376+ $ normalizedMethodCall ,
377+ $ staticMethodCalledOnType ->getObjectClassNames (),
378+ );
379+ yield from $ methodReturnTypeGen ;
380+ $ methodReturnType = $ methodReturnTypeGen ->getReturn ();
381+ if ($ methodReturnType === null ) {
382+ $ methodReturnType = new ErrorType ();
383+ } else {
384+ $ methodReturnTypeGen = $ this ->nullsafeShortCircuitingHelper ->getNullsafeShortCircuitingType ($ class , $ methodReturnType );
385+ yield from $ methodReturnTypeGen ;
386+ $ methodReturnType = $ methodReturnTypeGen ->getReturn ();
387+ }
388+ } else {
389+ $ methodReturnType = new ErrorType ();
390+ }
391+
385392 $ scope = $ argsResult ->scope ;
386393
387394 return new ExprAnalysisResult (
0 commit comments