@@ -2113,34 +2113,28 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
2113
2113
if ($ node instanceof MethodCall) {
2114
2114
if ($ node ->name instanceof Node \Identifier) {
2115
2115
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 ),
2134
2118
$ node ->name ->name ,
2135
- $ node ,
2136
2119
);
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 ();
2139
2124
}
2140
- return $ returnType ;
2141
- };
2142
2125
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 );
2144
2138
}
2145
2139
2146
2140
$ nameType = $ this ->getType ($ node ->name );
@@ -2172,50 +2166,43 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
2172
2166
if ($ node instanceof Expr \StaticCall) {
2173
2167
if ($ node ->name instanceof Node \Identifier) {
2174
2168
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
+ }
2191
2183
2192
- $ callType = $ typeCallback ();
2193
2184
if ($ node ->class instanceof Expr) {
2194
2185
return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ callType );
2195
2186
}
2196
2187
2197
2188
return $ callType ;
2198
2189
}
2199
2190
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
+ }
2206
2196
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
+ }
2217
2205
2218
- $ callType = $ typeCallback ();
2219
2206
if ($ node ->class instanceof Expr) {
2220
2207
return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ callType );
2221
2208
}
0 commit comments