@@ -2077,23 +2077,50 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
2077
2077
);
2078
2078
}
2079
2079
2080
- if ($ node instanceof Expr \StaticCall && $ node ->name instanceof Node \Identifier) {
2081
- if ($ this ->nativeTypesPromoted ) {
2080
+ if ($ node instanceof Expr \StaticCall) {
2081
+ if ($ node ->name instanceof Node \Identifier) {
2082
+ if ($ this ->nativeTypesPromoted ) {
2083
+ $ typeCallback = function () use ($ node ): Type {
2084
+ if ($ node ->class instanceof Name) {
2085
+ $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2086
+ } else {
2087
+ $ staticMethodCalledOnType = $ this ->getNativeType ($ node ->class );
2088
+ }
2089
+ $ methodReflection = $ this ->getMethodReflection (
2090
+ $ staticMethodCalledOnType ,
2091
+ $ node ->name ->name ,
2092
+ );
2093
+ if ($ methodReflection === null ) {
2094
+ return new ErrorType ();
2095
+ }
2096
+
2097
+ return ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2098
+ };
2099
+
2100
+ $ callType = $ typeCallback ();
2101
+ if ($ node ->class instanceof Expr) {
2102
+ return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ callType );
2103
+ }
2104
+
2105
+ return $ callType ;
2106
+ }
2107
+
2082
2108
$ typeCallback = function () use ($ node ): Type {
2083
2109
if ($ node ->class instanceof Name) {
2084
2110
$ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2085
2111
} else {
2086
- $ staticMethodCalledOnType = $ this ->getNativeType ($ node ->class );
2112
+ $ staticMethodCalledOnType = TypeCombinator:: removeNull ( $ this ->getType ($ node ->class ))-> getObjectTypeOrClassStringObjectType ( );
2087
2113
}
2088
- $ methodReflection = $ this ->getMethodReflection (
2114
+
2115
+ $ returnType = $ this ->methodCallReturnType (
2089
2116
$ staticMethodCalledOnType ,
2090
- $ node ->name ->name ,
2117
+ $ node ->name ->toString (),
2118
+ $ node ,
2091
2119
);
2092
- if ($ methodReflection === null ) {
2120
+ if ($ returnType === null ) {
2093
2121
return new ErrorType ();
2094
2122
}
2095
-
2096
- return ParametersAcceptorSelector::combineAcceptors ($ methodReflection ->getVariants ())->getNativeReturnType ();
2123
+ return $ returnType ;
2097
2124
};
2098
2125
2099
2126
$ callType = $ typeCallback ();
@@ -2104,30 +2131,14 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu
2104
2131
return $ callType ;
2105
2132
}
2106
2133
2107
- $ typeCallback = function () use ($ node ): Type {
2108
- if ($ node ->class instanceof Name) {
2109
- $ staticMethodCalledOnType = $ this ->resolveTypeByNameWithLateStaticBinding ($ node ->class , $ node ->name );
2110
- } else {
2111
- $ staticMethodCalledOnType = TypeCombinator::removeNull ($ this ->getType ($ node ->class ))->getObjectTypeOrClassStringObjectType ();
2112
- }
2113
-
2114
- $ returnType = $ this ->methodCallReturnType (
2115
- $ staticMethodCalledOnType ,
2116
- $ node ->name ->toString (),
2117
- $ node ,
2134
+ $ nameType = $ this ->getType ($ node ->name );
2135
+ if (count ($ nameType ->getConstantStrings ()) > 0 ) {
2136
+ return TypeCombinator::union (
2137
+ ...array_map (fn ($ constantString ) => $ this
2138
+ ->filterByTruthyValue (new BinaryOp \Identical ($ node ->name , new String_ ($ constantString ->getValue ())))
2139
+ ->getType (new Expr \StaticCall ($ node ->class , new Identifier ($ constantString ->getValue ()), $ node ->args )), $ nameType ->getConstantStrings ()),
2118
2140
);
2119
- if ($ returnType === null ) {
2120
- return new ErrorType ();
2121
- }
2122
- return $ returnType ;
2123
- };
2124
-
2125
- $ callType = $ typeCallback ();
2126
- if ($ node ->class instanceof Expr) {
2127
- return $ this ->getNullsafeShortCircuitingType ($ node ->class , $ callType );
2128
2141
}
2129
-
2130
- return $ callType ;
2131
2142
}
2132
2143
2133
2144
if ($ node instanceof PropertyFetch) {
0 commit comments