@@ -85,55 +85,54 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
8585 if (count ($ patternConstantTypes ) === 0 || count ($ subjectConstantTypes ) === 0 ) {
8686 $ returnNonEmptyStrings = $ flagArg !== null && $ this ->bitwiseFlagAnalyser ->bitwiseOrContainsConstant ($ flagArg ->value , $ scope , 'PREG_SPLIT_NO_EMPTY ' )->yes ();
8787 if ($ returnNonEmptyStrings ) {
88- $ stringType = TypeCombinator::intersect (
88+ $ returnStringType = TypeCombinator::intersect (
8989 new StringType (),
9090 new AccessoryNonEmptyStringType ()
9191 );
9292 } else {
93- $ stringType = new StringType ();
93+ $ returnStringType = new StringType ();
9494 }
9595
9696 $ capturedArrayType = new ConstantArrayType (
97- [new ConstantIntegerType (0 ), new ConstantIntegerType (1 )], [$ stringType , IntegerRangeType::fromInterval (0 , null )],
97+ [new ConstantIntegerType (0 ), new ConstantIntegerType (1 )], [$ returnStringType , IntegerRangeType::fromInterval (0 , null )],
9898 [2 ],
9999 [],
100100 TrinaryLogic::createYes ()
101101 );
102102
103- $ valueType = $ stringType ;
103+ $ returnInternalValueType = $ returnStringType ;
104104 if ($ flagArg !== null ) {
105105 $ flagState = $ this ->bitwiseFlagAnalyser ->bitwiseOrContainsConstant ($ flagArg ->value , $ scope , 'PREG_SPLIT_OFFSET_CAPTURE ' );
106106 if ($ flagState ->yes ()) {
107- $ arrayType = TypeCombinator::intersect (
107+ $ capturedArrayListType = TypeCombinator::intersect (
108108 new ArrayType (new IntegerType (), $ capturedArrayType ),
109109 new AccessoryArrayListType (),
110110 );
111111
112112 if ($ subjectType ->isNonEmptyString ()->yes ()) {
113- $ arrayType = TypeCombinator::intersect ($ arrayType , new NonEmptyArrayType ());
113+ $ capturedArrayListType = TypeCombinator::intersect ($ capturedArrayListType , new NonEmptyArrayType ());
114114 }
115115
116116 return TypeUtils::toBenevolentUnion (
117- TypeCombinator::union ($ arrayType , new ConstantBooleanType (false ))
117+ TypeCombinator::union ($ capturedArrayListType , new ConstantBooleanType (false ))
118118 );
119119 }
120120 if ($ flagState ->maybe ()) {
121- $ valueType = TypeCombinator::union (new StringType (), $ capturedArrayType );
121+ $ returnInternalValueType = TypeCombinator::union (new StringType (), $ capturedArrayType );
122122 }
123123 }
124124
125- $ arrayType = TypeCombinator::intersect (new ArrayType (new MixedType (), $ valueType ), new AccessoryArrayListType ());
125+ $ returnListType = TypeCombinator::intersect (new ArrayType (new MixedType (), $ returnInternalValueType ), new AccessoryArrayListType ());
126126 if ($ subjectType ->isNonEmptyString ()->yes ()) {
127- $ arrayType = TypeCombinator::intersect (
128- $ arrayType ,
127+ $ returnListType = TypeCombinator::intersect (
128+ $ returnListType ,
129129 new NonEmptyArrayType (),
130- new AccessoryArrayListType (),
131130 );
132131 }
133132
134133 return TypeUtils::toBenevolentUnion (
135134 TypeCombinator::union (
136- $ arrayType ,
135+ $ returnListType ,
137136 new ConstantBooleanType (false )
138137 )
139138 );
@@ -153,18 +152,20 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
153152 $ valueConstantArray = ConstantArrayTypeBuilder::createEmpty ();
154153 $ valueConstantArray ->setOffsetValueType (new ConstantIntegerType (0 ), new ConstantStringType ($ value [0 ]));
155154 $ valueConstantArray ->setOffsetValueType (new ConstantIntegerType (1 ), new ConstantIntegerType ($ value [1 ]));
156- $ valueType = $ valueConstantArray ->getArray ();
155+ $ returnInternalValueType = $ valueConstantArray ->getArray ();
157156 } else {
158- $ valueType = new ConstantStringType ($ value );
157+ $ returnInternalValueType = new ConstantStringType ($ value );
159158 }
160- $ constantArray ->setOffsetValueType (new ConstantIntegerType ($ key ), $ valueType );
159+ $ constantArray ->setOffsetValueType (new ConstantIntegerType ($ key ), $ returnInternalValueType );
161160 }
161+
162162 $ resultTypes [] = $ constantArray ->getArray ();
163163 }
164164 }
165165 }
166166 }
167167 }
168+
168169 return TypeCombinator::union (...$ resultTypes );
169170 }
170171}
0 commit comments