@@ -2113,34 +2113,28 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
21132113 if ($ node instanceof MethodCall) {
21142114 if ($ node ->name instanceof Node \Identifier) {
21152115 if ($ this ->nativeTypesPromoted ) {
2116- $ typeCallback = function () use ($ node ): Type {
2117- $ methodReflection = $ this ->getMethodReflection (
2118- $ this ->getNativeType ($ node ->var ),
2119- $ node ->name ->name ,
2120- );
2121- if ($ methodReflection === null ) {
2122- return new ErrorType ();
2123- }
2124-
2125- return ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2126- };
2127-
2128- return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ typeCallback ());
2129- }
2130-
2131- $ typeCallback = function () use ($ node ): Type {
2132- $ returnType = $ this ->methodCallReturnType (
2133- $ this ->getType ($ node ->var ),
2116+ $ methodReflection = $ this ->getMethodReflection (
2117+ $ this ->getNativeType ($ node ->var ),
21342118 $ node ->name ->name ,
2135- $ node ,
21362119 );
2137- if ($ returnType === null ) {
2138- return new ErrorType ();
2120+ if ($ methodReflection === null ) {
2121+ $ returnType = new ErrorType ();
2122+ } else {
2123+ $ returnType = ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
21392124 }
2140- return $ returnType ;
2141- };
21422125
2143- return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ typeCallback ());
2126+ return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ returnType );
2127+ }
2128+
2129+ $ returnType = $ this ->methodCallReturnType (
2130+ $ this ->getType ($ node ->var ),
2131+ $ node ->name ->name ,
2132+ $ node ,
2133+ );
2134+ if ($ returnType === null ) {
2135+ $ returnType = new ErrorType ();
2136+ }
2137+ return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ returnType );
21442138 }
21452139
21462140 $ nameType = $ this ->getType ($ node ->name );
@@ -2172,50 +2166,43 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
21722166 if ($ node instanceof Expr \StaticCall) {
21732167 if ($ node ->name instanceof Node \Identifier) {
21742168 if ($ this ->nativeTypesPromoted ) {
2175- $ typeCallback = function () use ($ node ): Type {
2176- if ($ node ->class instanceof Name) {
2177- $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2178- } else {
2179- $ staticMethodCalledOnType = $ this ->getNativeType ($ node ->class );
2180- }
2181- $ methodReflection = $ this ->getMethodReflection (
2182- $ staticMethodCalledOnType ,
2183- $ node ->name ->name ,
2184- );
2185- if ($ methodReflection === null ) {
2186- return new ErrorType ();
2187- }
2188-
2189- return ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2190- };
2169+ if ($ node ->class instanceof Name) {
2170+ $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2171+ } else {
2172+ $ staticMethodCalledOnType = $ this ->getNativeType ($ node ->class );
2173+ }
2174+ $ methodReflection = $ this ->getMethodReflection (
2175+ $ staticMethodCalledOnType ,
2176+ $ node ->name ->name ,
2177+ );
2178+ if ($ methodReflection === null ) {
2179+ $ callType = new ErrorType ();
2180+ } else {
2181+ $ callType = ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2182+ }
21912183
2192- $ callType = $ typeCallback ();
21932184 if ($ node ->class instanceof Expr) {
21942185 return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ callType );
21952186 }
21962187
21972188 return $ callType ;
21982189 }
21992190
2200- $ typeCallback = function () use ($ node ): Type {
2201- if ($ node ->class instanceof Name) {
2202- $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2203- } else {
2204- $ staticMethodCalledOnType = TypeCombinator::removeNull ($ this ->getType ($ node ->class ))->getObjectTypeOrClassStringObjectType ();
2205- }
2191+ if ($ node ->class instanceof Name) {
2192+ $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2193+ } else {
2194+ $ staticMethodCalledOnType = TypeCombinator::removeNull ($ this ->getType ($ node ->class ))->getObjectTypeOrClassStringObjectType ();
2195+ }
22062196
2207- $ returnType = $ this ->methodCallReturnType (
2208- $ staticMethodCalledOnType ,
2209- $ node ->name ->toString (),
2210- $ node ,
2211- );
2212- if ($ returnType === null ) {
2213- return new ErrorType ();
2214- }
2215- return $ returnType ;
2216- };
2197+ $ callType = $ this ->methodCallReturnType (
2198+ $ staticMethodCalledOnType ,
2199+ $ node ->name ->toString (),
2200+ $ node ,
2201+ );
2202+ if ($ callType === null ) {
2203+ $ callType = new ErrorType ();
2204+ }
22172205
2218- $ callType = $ typeCallback ();
22192206 if ($ node ->class instanceof Expr) {
22202207 return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ callType );
22212208 }
@@ -2250,19 +2237,16 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
22502237 return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ nativeType );
22512238 }
22522239
2253- $ typeCallback = function () use ($ node ): Type {
2254- $ returnType = $ this ->propertyFetchType (
2255- $ this ->getType ($ node ->var ),
2256- $ node ->name ->name ,
2257- $ node ,
2258- );
2259- if ($ returnType === null ) {
2260- return new ErrorType ();
2261- }
2262- return $ returnType ;
2263- };
2240+ $ returnType = $ this ->propertyFetchType (
2241+ $ this ->getType ($ node ->var ),
2242+ $ node ->name ->name ,
2243+ $ node ,
2244+ );
2245+ if ($ returnType === null ) {
2246+ $ returnType = new ErrorType ();
2247+ }
22642248
2265- return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ typeCallback () );
2249+ return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ returnType );
22662250 }
22672251
22682252 $ nameType = $ this ->getType ($ node ->name );
@@ -2313,25 +2297,21 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
23132297 return $ nativeType ;
23142298 }
23152299
2316- $ typeCallback = function () use ($ node ): Type {
2317- if ($ node ->class instanceof Name) {
2318- $ staticPropertyFetchedOnType = $ this ->resolveTypeByName ($ node ->class );
2319- } else {
2320- $ staticPropertyFetchedOnType = TypeCombinator::removeNull ($ this ->getType ($ node ->class ))->getObjectTypeOrClassStringObjectType ();
2321- }
2300+ if ($ node ->class instanceof Name) {
2301+ $ staticPropertyFetchedOnType = $ this ->resolveTypeByName ($ node ->class );
2302+ } else {
2303+ $ staticPropertyFetchedOnType = TypeCombinator::removeNull ($ this ->getType ($ node ->class ))->getObjectTypeOrClassStringObjectType ();
2304+ }
23222305
2323- $ returnType = $ this ->propertyFetchType (
2324- $ staticPropertyFetchedOnType ,
2325- $ node ->name ->toString (),
2326- $ node ,
2327- );
2328- if ($ returnType === null ) {
2329- return new ErrorType ();
2330- }
2331- return $ returnType ;
2332- };
2306+ $ fetchType = $ this ->propertyFetchType (
2307+ $ staticPropertyFetchedOnType ,
2308+ $ node ->name ->toString (),
2309+ $ node ,
2310+ );
2311+ if ($ fetchType === null ) {
2312+ $ fetchType = new ErrorType ();
2313+ }
23332314
2334- $ fetchType = $ typeCallback ();
23352315 if ($ node ->class instanceof Expr) {
23362316 return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ fetchType );
23372317 }
0 commit comments