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