Skip to content

Commit 9adf2dd

Browse files
committed
wip
1 parent e6c5d51 commit 9adf2dd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Type/Php/RegexArrayShapeMatcher.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,18 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
123123
$trailingOptionals++;
124124
}
125125

126-
$onlyOptionalTopLevelGroupIndex = $this->getOnlyOptionalTopLevelGroupIndex($groupList);
126+
$onlyOptionalTopLevelGroupId = $this->getOnlyOptionalTopLevelGroupId($groupList);
127127
$onlyTopLevelAlternation = $this->getOnlyTopLevelAlternation($groupList);
128128
$flags ??= 0;
129129

130130
if (
131131
!$matchesAll
132132
&& $wasMatched->yes()
133-
&& $onlyOptionalTopLevelGroupIndex !== null
133+
&& $onlyOptionalTopLevelGroupId !== null
134134
) {
135135
// if only one top level capturing optional group exists
136136
// we build a more precise tagged union of a empty-match and a match with the group
137-
$groupList[$onlyOptionalTopLevelGroupIndex] = $groupList[$onlyOptionalTopLevelGroupIndex]->forceNonOptional();
137+
$groupList[$onlyOptionalTopLevelGroupId] = $groupList[$onlyOptionalTopLevelGroupId]->forceNonOptional();
138138

139139
$combiType = $this->buildArrayType(
140140
$groupList,
@@ -156,7 +156,7 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
156156
return $combiType;
157157
} elseif (
158158
!$matchesAll
159-
&& $onlyOptionalTopLevelGroupIndex === null
159+
&& $onlyOptionalTopLevelGroupId === null
160160
&& $onlyTopLevelAlternation !== null
161161
&& !$wasMatched->no()
162162
) {
@@ -228,10 +228,10 @@ private function matchRegex(string $regex, ?int $flags, TrinaryLogic $wasMatched
228228
/**
229229
* @param array<int, RegexCapturingGroup> $captureGroups
230230
*/
231-
private function getOnlyOptionalTopLevelGroupIndex(array $captureGroups): ?int
231+
private function getOnlyOptionalTopLevelGroupId(array $captureGroups): ?int
232232
{
233233
$groupIndex = null;
234-
foreach ($captureGroups as $i => $captureGroup) {
234+
foreach ($captureGroups as $captureGroup) {
235235
if (!$captureGroup->isTopLevel()) {
236236
continue;
237237
}
@@ -244,7 +244,7 @@ private function getOnlyOptionalTopLevelGroupIndex(array $captureGroups): ?int
244244
return null;
245245
}
246246

247-
$groupIndex = $i;
247+
$groupIndex = $captureGroup->getId();
248248
}
249249

250250
return $groupIndex;

0 commit comments

Comments
 (0)