@@ -132,6 +132,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
132
132
133
133
$ onlyOptionalTopLevelGroup = $ this ->getOnlyOptionalTopLevelGroup ($ groupList );
134
134
$ onlyTopLevelAlternation = $ this ->getOnlyTopLevelAlternation ($ groupList );
135
+ $ flags ??= 0 ;
135
136
136
137
if (
137
138
!$ matchesAll
@@ -147,14 +148,14 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
147
148
$ groupList ,
148
149
$ wasMatched ,
149
150
$ trailingOptionals ,
150
- $ flags ?? 0 ,
151
+ $ flags ,
151
152
$ markVerbs ,
152
153
$ matchesAll ,
153
154
);
154
155
155
- if (!$ this ->containsUnmatchedAsNull ($ flags ?? 0 , $ matchesAll )) {
156
+ if (!$ this ->containsUnmatchedAsNull ($ flags , $ matchesAll )) {
156
157
$ combiType = TypeCombinator::union (
157
- new ConstantArrayType ([new ConstantIntegerType (0 )], [new StringType ( )], [0 ], [], true ),
158
+ new ConstantArrayType ([new ConstantIntegerType (0 )], [$ this -> createSubjectValueType ( $ flags , $ matchesAll )], [0 ], [], true ),
158
159
$ combiType ,
159
160
);
160
161
}
@@ -180,7 +181,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
180
181
$ group ->forceNonOptional ();
181
182
} elseif (
182
183
$ group ->getAlternationId () === $ onlyTopLevelAlternation ->getId ()
183
- && !$ this ->containsUnmatchedAsNull ($ flags ?? 0 , $ matchesAll )
184
+ && !$ this ->containsUnmatchedAsNull ($ flags , $ matchesAll )
184
185
) {
185
186
unset($ comboList [$ groupId ]);
186
187
}
@@ -190,7 +191,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
190
191
$ comboList ,
191
192
$ wasMatched ,
192
193
$ trailingOptionals ,
193
- $ flags ?? 0 ,
194
+ $ flags ,
194
195
$ markVerbs ,
195
196
$ matchesAll ,
196
197
);
@@ -203,8 +204,8 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
203
204
}
204
205
}
205
206
206
- if ($ isOptionalAlternation && !$ this ->containsUnmatchedAsNull ($ flags ?? 0 , $ matchesAll )) {
207
- $ combiTypes [] = new ConstantArrayType ([new ConstantIntegerType (0 )], [new StringType ( )], [0 ], [], true );
207
+ if ($ isOptionalAlternation && !$ this ->containsUnmatchedAsNull ($ flags , $ matchesAll )) {
208
+ $ combiTypes [] = new ConstantArrayType ([new ConstantIntegerType (0 )], [$ this -> createSubjectValueType ( $ flags , $ matchesAll )], [0 ], [], true );
208
209
}
209
210
210
211
return TypeCombinator::union (...$ combiTypes );
@@ -214,7 +215,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
214
215
$ groupList ,
215
216
$ wasMatched ,
216
217
$ trailingOptionals ,
217
- $ flags ?? 0 ,
218
+ $ flags ,
218
219
$ markVerbs ,
219
220
$ matchesAll ,
220
221
);
@@ -288,7 +289,7 @@ private function buildArrayType(
288
289
// first item in matches contains the overall match.
289
290
$ builder ->setOffsetValueType (
290
291
$ this ->getKeyType (0 ),
291
- $ this ->createSubjectValueType ($ wasMatched , $ flags , $ matchesAll ),
292
+ $ this ->createSubjectValueType ($ flags , $ matchesAll ),
292
293
$ this ->isSubjectOptional ($ wasMatched , $ matchesAll ),
293
294
);
294
295
@@ -351,7 +352,7 @@ private function isSubjectOptional(TrinaryLogic $wasMatched, bool $matchesAll):
351
352
return !$ wasMatched ->yes ();
352
353
}
353
354
354
- private function createSubjectValueType (TrinaryLogic $ wasMatched , int $ flags , bool $ matchesAll ): Type
355
+ private function createSubjectValueType (int $ flags , bool $ matchesAll ): Type
355
356
{
356
357
$ subjectValueType = TypeCombinator::removeNull ($ this ->getValueType (new StringType (), $ flags , $ matchesAll ));
357
358
0 commit comments