Skip to content

Commit 47b54f9

Browse files
committed
Update RegexGroupParser.php
1 parent 83d466e commit 47b54f9

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

Diff for: src/Type/Regex/RegexGroupParser.php

+4-9
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)