Skip to content

Commit 706c9d0

Browse files
committed
Update RegexGroupParser.php
1 parent 70111ab commit 706c9d0

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/Type/Regex/RegexGroupParser.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,13 @@ public function parseGroups(string $regex): ?RegexAstWalkResult
111111
);
112112

113113
// we could handle numeric-string, in case we know the regex is delimited by ^ and $
114-
$accessories = [];
115114
if ($subjectAsGroupResult->isNonFalsy()->yes()) {
116-
$accessories[] = new AccessoryNonFalsyStringType();
115+
$astWalkResult = $astWalkResult->withSubjectBaseType(
116+
TypeCombinator::intersect(new StringType(), new AccessoryNonFalsyStringType()),
117+
);
117118
} elseif ($subjectAsGroupResult->isNonEmpty()->yes()) {
118-
$accessories[] = new AccessoryNonEmptyStringType();
119-
}
120-
121-
if ($accessories !== []) {
122-
$accessories[] = new StringType();
123-
124119
$astWalkResult = $astWalkResult->withSubjectBaseType(
125-
TypeCombinator::intersect(...$accessories),
120+
TypeCombinator::intersect(new StringType(), new AccessoryNonEmptyStringType()),
126121
);
127122
}
128123

0 commit comments

Comments
 (0)