Skip to content

Commit

Permalink
Merge branch refs/heads/1.12.x into 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot authored Dec 20, 2024
2 parents 8fd217a + defd406 commit fa95faf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Type/Regex/RegexGroupParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ private function isMaybeEmptyNode(TreeNode $node, string $patternModifiers, bool
if ($literal !== '' && $literal !== '0') {
$isNonFalsy = true;
}
return false;
return $literal === '';
}

foreach ($node->getChildren() as $child) {
Expand Down
19 changes: 19 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-12297.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Bug12297;

use function PHPStan\Testing\assertType;

function doFoo($s) {
if (preg_match('/(^.+)/', $s, $matches) === 1) {
assertType('non-empty-string', $matches[1]);
}

if (preg_match('/(.+$)/', $s, $matches) === 1) {
assertType('non-empty-string', $matches[1]);
}

if (preg_match('/(^.+$)/', $s, $matches) === 1) {
assertType('non-empty-string', $matches[1]);
}
}

0 comments on commit fa95faf

Please sign in to comment.