Skip to content

Commit ffa1824

Browse files
committed
simplify
1 parent 2eecc47 commit ffa1824

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Type/Php/RegexArrayShapeMatcher.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
132132

133133
$onlyOptionalTopLevelGroup = $this->getOnlyOptionalTopLevelGroup($groupList);
134134
$onlyTopLevelAlternation = $this->getOnlyTopLevelAlternation($groupList);
135+
$flags ??= 0;
135136

136137
if (
137138
!$matchesAll
@@ -147,12 +148,12 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
147148
$groupList,
148149
$wasMatched,
149150
$trailingOptionals,
150-
$flags ?? 0,
151+
$flags,
151152
$markVerbs,
152153
$matchesAll,
153154
);
154155

155-
if (!$this->containsUnmatchedAsNull($flags ?? 0, $matchesAll)) {
156+
if (!$this->containsUnmatchedAsNull($flags, $matchesAll)) {
156157
$combiType = TypeCombinator::union(
157158
new ConstantArrayType([new ConstantIntegerType(0)], [$this->createSubjectValueType($flags, $matchesAll)], [0], [], true),
158159
$combiType,
@@ -180,7 +181,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
180181
$group->forceNonOptional();
181182
} elseif (
182183
$group->getAlternationId() === $onlyTopLevelAlternation->getId()
183-
&& !$this->containsUnmatchedAsNull($flags ?? 0, $matchesAll)
184+
&& !$this->containsUnmatchedAsNull($flags, $matchesAll)
184185
) {
185186
unset($comboList[$groupId]);
186187
}
@@ -190,7 +191,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
190191
$comboList,
191192
$wasMatched,
192193
$trailingOptionals,
193-
$flags ?? 0,
194+
$flags,
194195
$markVerbs,
195196
$matchesAll,
196197
);
@@ -203,7 +204,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
203204
}
204205
}
205206

206-
if ($isOptionalAlternation && !$this->containsUnmatchedAsNull($flags ?? 0, $matchesAll)) {
207+
if ($isOptionalAlternation && !$this->containsUnmatchedAsNull($flags, $matchesAll)) {
207208
$combiTypes[] = new ConstantArrayType([new ConstantIntegerType(0)], [$this->createSubjectValueType($flags, $matchesAll)], [0], [], true);
208209
}
209210

@@ -214,7 +215,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
214215
$groupList,
215216
$wasMatched,
216217
$trailingOptionals,
217-
$flags ?? 0,
218+
$flags,
218219
$markVerbs,
219220
$matchesAll,
220221
);

0 commit comments

Comments
 (0)