Skip to content

Commit 99c2052

Browse files
committed
fix
1 parent e8a9b5d commit 99c2052

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Type/Php/RegexGroupParser.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,9 @@ private function walkGroupAst(
365365
&& count($children) > 0
366366
) {
367367
$isNonEmpty = TrinaryLogic::createYes();
368-
$isNonFalsy = TrinaryLogic::createYes();
368+
if (!$inAlternation) {
369+
$isNonFalsy = TrinaryLogic::createYes();
370+
}
369371
} elseif ($ast->getId() === '#quantification') {
370372
[$min] = $this->getQuantificationRange($ast);
371373

tests/PHPStan/Analyser/nsrt/preg_match_shapes.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,16 @@ function (string $s): void {
612612
assertType("array{string, non-empty-string}", $matches);
613613
}
614614
};
615+
616+
function (string $s): void {
617+
if (preg_match('/Price: (a|0)/', $s, $matches)) {
618+
assertType("array{string, non-empty-string}", $matches);
619+
}
620+
};
621+
622+
function (string $s): void {
623+
if (preg_match('/Price: (aa|0)/', $s, $matches)) {
624+
assertType("array{string, non-empty-string}", $matches);
625+
}
626+
};
627+

0 commit comments

Comments
 (0)