@@ -94,27 +94,38 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
9494 }
9595
9696 $ capturedArrayType = new ConstantArrayType (
97- [
98- new ConstantIntegerType (0 ),
99- new ConstantIntegerType (1 )], [$ stringType , IntegerRangeType::fromInterval (0 , null )
100- ],
97+ [new ConstantIntegerType (0 ), new ConstantIntegerType (1 )], [$ stringType , IntegerRangeType::fromInterval (0 , null )],
10198 [2 ],
10299 [],
103100 TrinaryLogic::createYes ()
104101 );
102+
105103 $ valueType = $ stringType ;
106104 if ($ flagArg !== null ) {
107105 $ flagState = $ this ->bitwiseFlagAnalyser ->bitwiseOrContainsConstant ($ flagArg ->value , $ scope , 'PREG_SPLIT_OFFSET_CAPTURE ' );
108106 if ($ flagState ->yes ()) {
109- return TypeUtils::toBenevolentUnion (
110- TypeCombinator::union (
111- TypeCombinator::intersect (
112- new ArrayType (new IntegerType (), $ capturedArrayType ),
113- new AccessoryArrayListType ()
114- ),
115- new ConstantBooleanType (false )
116- )
117- );
107+ if ($ subjectType ->isNonEmptyString ()->yes ()) {
108+ return TypeUtils::toBenevolentUnion (
109+ TypeCombinator::union (
110+ TypeCombinator::intersect (
111+ new ArrayType (new IntegerType (), $ capturedArrayType ),
112+ new NonEmptyArrayType (),
113+ new AccessoryArrayListType (),
114+ ),
115+ new ConstantBooleanType (false )
116+ )
117+ );
118+ } else {
119+ return TypeUtils::toBenevolentUnion (
120+ TypeCombinator::union (
121+ TypeCombinator::intersect (
122+ new ArrayType (new IntegerType (), $ capturedArrayType ),
123+ new AccessoryArrayListType (),
124+ ),
125+ new ConstantBooleanType (false )
126+ )
127+ );
128+ }
118129 }
119130 if ($ flagState ->maybe ()) {
120131 $ valueType = TypeCombinator::union (new StringType (), $ capturedArrayType );
0 commit comments