@@ -2042,34 +2042,28 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
2042
2042
if ($ node instanceof MethodCall) {
2043
2043
if ($ node ->name instanceof Node \Identifier) {
2044
2044
if ($ this ->nativeTypesPromoted ) {
2045
- $ typeCallback = function () use ($ node ): Type {
2046
- $ methodReflection = $ this ->getMethodReflection (
2047
- $ this ->getNativeType ($ node ->var ),
2048
- $ node ->name ->name ,
2049
- );
2050
- if ($ methodReflection === null ) {
2051
- return new ErrorType ();
2052
- }
2053
-
2054
- return ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2055
- };
2056
-
2057
- return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ typeCallback ());
2058
- }
2059
-
2060
- $ typeCallback = function () use ($ node ): Type {
2061
- $ returnType = $ this ->methodCallReturnType (
2062
- $ this ->getType ($ node ->var ),
2045
+ $ methodReflection = $ this ->getMethodReflection (
2046
+ $ this ->getNativeType ($ node ->var ),
2063
2047
$ node ->name ->name ,
2064
- $ node ,
2065
2048
);
2066
- if ($ returnType === null ) {
2067
- return new ErrorType ();
2049
+ if ($ methodReflection === null ) {
2050
+ $ returnType = new ErrorType ();
2051
+ } else {
2052
+ $ returnType = ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2068
2053
}
2069
- return $ returnType ;
2070
- };
2071
2054
2072
- return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ typeCallback ());
2055
+ return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ returnType );
2056
+ }
2057
+
2058
+ $ returnType = $ this ->methodCallReturnType (
2059
+ $ this ->getType ($ node ->var ),
2060
+ $ node ->name ->name ,
2061
+ $ node ,
2062
+ );
2063
+ if ($ returnType === null ) {
2064
+ $ returnType = new ErrorType ();
2065
+ }
2066
+ return $ this ->getNullsafeShortCircuitingType ($ node ->var , $ returnType );
2073
2067
}
2074
2068
2075
2069
$ nameType = $ this ->getType ($ node ->name );
@@ -2101,50 +2095,43 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
2101
2095
if ($ node instanceof Expr \StaticCall) {
2102
2096
if ($ node ->name instanceof Node \Identifier) {
2103
2097
if ($ this ->nativeTypesPromoted ) {
2104
- $ typeCallback = function () use ($ node ): Type {
2105
- if ($ node ->class instanceof Name) {
2106
- $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2107
- } else {
2108
- $ staticMethodCalledOnType = $ this ->getNativeType ($ node ->class );
2109
- }
2110
- $ methodReflection = $ this ->getMethodReflection (
2111
- $ staticMethodCalledOnType ,
2112
- $ node ->name ->name ,
2113
- );
2114
- if ($ methodReflection === null ) {
2115
- return new ErrorType ();
2116
- }
2117
-
2118
- return ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2119
- };
2098
+ if ($ node ->class instanceof Name) {
2099
+ $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2100
+ } else {
2101
+ $ staticMethodCalledOnType = $ this ->getNativeType ($ node ->class );
2102
+ }
2103
+ $ methodReflection = $ this ->getMethodReflection (
2104
+ $ staticMethodCalledOnType ,
2105
+ $ node ->name ->name ,
2106
+ );
2107
+ if ($ methodReflection === null ) {
2108
+ $ callType = new ErrorType ();
2109
+ } else {
2110
+ $ callType = ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2111
+ }
2120
2112
2121
- $ callType = $ typeCallback ();
2122
2113
if ($ node ->class instanceof Expr) {
2123
2114
return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ callType );
2124
2115
}
2125
2116
2126
2117
return $ callType ;
2127
2118
}
2128
2119
2129
- $ typeCallback = function () use ($ node ): Type {
2130
- if ($ node ->class instanceof Name) {
2131
- $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2132
- } else {
2133
- $ staticMethodCalledOnType = TypeCombinator::removeNull ($ this ->getType ($ node ->class ))->getObjectTypeOrClassStringObjectType ();
2134
- }
2120
+ if ($ node ->class instanceof Name) {
2121
+ $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2122
+ } else {
2123
+ $ staticMethodCalledOnType = TypeCombinator::removeNull ($ this ->getType ($ node ->class ))->getObjectTypeOrClassStringObjectType ();
2124
+ }
2135
2125
2136
- $ returnType = $ this ->methodCallReturnType (
2137
- $ staticMethodCalledOnType ,
2138
- $ node ->name ->toString (),
2139
- $ node ,
2140
- );
2141
- if ($ returnType === null ) {
2142
- return new ErrorType ();
2143
- }
2144
- return $ returnType ;
2145
- };
2126
+ $ callType = $ this ->methodCallReturnType (
2127
+ $ staticMethodCalledOnType ,
2128
+ $ node ->name ->toString (),
2129
+ $ node ,
2130
+ );
2131
+ if ($ callType === null ) {
2132
+ $ callType = new ErrorType ();
2133
+ }
2146
2134
2147
- $ callType = $ typeCallback ();
2148
2135
if ($ node ->class instanceof Expr) {
2149
2136
return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ callType );
2150
2137
}
0 commit comments