@@ -88,11 +88,6 @@ private function getPreliminarilyResolvedTypeFromFunctionCall(
8888 return TypeUtils::toBenevolentUnion ($ defaultReturnType );
8989 }
9090
91- $ stringOrArray = new UnionType ([new StringType (), new ArrayType (new MixedType (), new MixedType ())]);
92- if (!$ stringOrArray ->isSuperTypeOf ($ subjectArgumentType )->yes ()) {
93- return $ defaultReturnType ;
94- }
95-
9691 $ replaceArgumentType = null ;
9792 if (array_key_exists ($ functionReflection ->getName (), self ::FUNCTIONS_REPLACE_POSITION )) {
9893 $ replaceArgumentPosition = self ::FUNCTIONS_REPLACE_POSITION [$ functionReflection ->getName ()];
@@ -107,12 +102,20 @@ private function getPreliminarilyResolvedTypeFromFunctionCall(
107102
108103 $ result = [];
109104
110- $ stringArgumentType = TypeCombinator::intersect (new StringType (), $ subjectArgumentType );
105+ if ($ subjectArgumentType ->isString ()->yes ()) {
106+ $ stringArgumentType = $ subjectArgumentType ;
107+ } else {
108+ $ stringArgumentType = TypeCombinator::intersect (new StringType (), $ subjectArgumentType );
109+ }
111110 if ($ stringArgumentType ->isString ()->yes ()) {
112111 $ result [] = $ this ->getReplaceType ($ stringArgumentType , $ replaceArgumentType );
113112 }
114113
115- $ arrayArgumentType = TypeCombinator::intersect (new ArrayType (new MixedType (), new MixedType ()), $ subjectArgumentType );
114+ if ($ subjectArgumentType ->isArray ()->yes ()) {
115+ $ arrayArgumentType = $ subjectArgumentType ;
116+ } else {
117+ $ arrayArgumentType = TypeCombinator::intersect (new ArrayType (new MixedType (), new MixedType ()), $ subjectArgumentType );
118+ }
116119 if ($ arrayArgumentType ->isArray ()->yes ()) {
117120 $ keyShouldBeOptional = in_array (
118121 $ functionReflection ->getName (),
0 commit comments