Skip to content

Commit 5ea87f0

Browse files
committed
Update RegexGroupParser.php
1 parent 943ecc8 commit 5ea87f0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Type/Regex/RegexGroupParser.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ public function parseGroups(string $regex): ?RegexAstWalkResult
102102
RegexAstWalkResult::createEmpty(),
103103
);
104104

105+
$subjectAsGroupResult = $this->walkGroupAst(
106+
$ast,
107+
false,
108+
false,
109+
$modifiers,
110+
RegexGroupWalkResult::createEmpty(),
111+
);
112+
if ($subjectAsGroupResult->isNonEmpty()->yes()) {
113+
$astWalkResult = $astWalkResult->withSubjectBaseType(
114+
TypeCombinator::intersect(new StringType(), new AccessoryNonEmptyStringType())
115+
);
116+
}
117+
105118
return $astWalkResult;
106119
}
107120

@@ -260,12 +273,6 @@ private function walkRegexAst(
260273
$astWalkResult,
261274
);
262275

263-
if ($alternation === null && !$inOptionalQuantification) {
264-
$astWalkResult = $astWalkResult->withSubjectBaseType(
265-
TypeCombinator::intersect(new StringType(), new AccessoryNonEmptyStringType())
266-
);
267-
}
268-
269276
if ($ast->getId() !== '#alternation') {
270277
continue;
271278
}

0 commit comments

Comments
 (0)