@@ -90,11 +90,6 @@ private function getPreliminarilyResolvedTypeFromFunctionCall(
90
90
return TypeUtils::toBenevolentUnion ($ defaultReturnType );
91
91
}
92
92
93
- $ stringOrArray = new UnionType ([new StringType (), new ArrayType (new MixedType (), new MixedType ())]);
94
- if (!$ stringOrArray ->isSuperTypeOf ($ subjectArgumentType )->yes ()) {
95
- return $ defaultReturnType ;
96
- }
97
-
98
93
$ replaceArgumentType = null ;
99
94
if (array_key_exists ($ functionReflection ->getName (), self ::FUNCTIONS_REPLACE_POSITION )) {
100
95
$ replaceArgumentPosition = self ::FUNCTIONS_REPLACE_POSITION [$ functionReflection ->getName ()];
@@ -109,12 +104,20 @@ private function getPreliminarilyResolvedTypeFromFunctionCall(
109
104
110
105
$ result = [];
111
106
112
- $ stringArgumentType = TypeCombinator::intersect (new StringType (), $ subjectArgumentType );
107
+ if ($ subjectArgumentType ->isString ()->yes ()) {
108
+ $ stringArgumentType = $ subjectArgumentType ;
109
+ } else {
110
+ $ stringArgumentType = TypeCombinator::intersect (new StringType (), $ subjectArgumentType );
111
+ }
113
112
if ($ stringArgumentType ->isString ()->yes ()) {
114
113
$ result [] = $ this ->getReplaceType ($ stringArgumentType , $ replaceArgumentType );
115
114
}
116
115
117
- $ arrayArgumentType = TypeCombinator::intersect (new ArrayType (new MixedType (), new MixedType ()), $ subjectArgumentType );
116
+ if ($ subjectArgumentType ->isArray ()->yes ()) {
117
+ $ arrayArgumentType = $ subjectArgumentType ;
118
+ } else {
119
+ $ arrayArgumentType = TypeCombinator::intersect (new ArrayType (new MixedType (), new MixedType ()), $ subjectArgumentType );
120
+ }
118
121
if ($ arrayArgumentType ->isArray ()->yes ()) {
119
122
$ keyShouldBeOptional = in_array (
120
123
$ functionReflection ->getName (),
0 commit comments