-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MutatingScope - process left side of BooleanAnd and BooleanOr before …
…getting type of the whole expression Closes phpstan/phpstan#5365 Closes phpstan/phpstan#6551
- Loading branch information
1 parent
ddf64ef
commit 989dd6f
Showing
7 changed files
with
106 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Bug5365; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
function (): void { | ||
$matches = []; | ||
$pattern = '#^C\s+(?<productId>\d+)$#i'; | ||
$subject = 'C 1234567890'; | ||
|
||
$found = (bool)preg_match( $pattern, $subject, $matches ) && isset( $matches['productId'] ); | ||
assertType('bool', $found); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Bug6551; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
function (): void { | ||
$data = [ | ||
'c1' => 12, | ||
'rasd' => 13, | ||
'c34' => 15, | ||
]; | ||
|
||
foreach ($data as $key => $value) { | ||
$match = []; | ||
if (false === preg_match('/^c(\d+)$/', $key, $match) || empty($match)) { | ||
continue; | ||
} | ||
var_dump($key); | ||
var_dump($value); | ||
} | ||
}; | ||
|
||
function (): void { | ||
$data = [ | ||
'c1' => 12, | ||
'rasd' => 13, | ||
'c34' => 15, | ||
]; | ||
|
||
foreach ($data as $key => $value) { | ||
if (false === preg_match('/^c(\d+)$/', $key, $match) || empty($match)) { | ||
continue; | ||
} | ||
var_dump($key); | ||
var_dump($value); | ||
} | ||
}; | ||
|
||
function (): void { | ||
$data = [ | ||
'c1' => 12, | ||
'rasd' => 13, | ||
'c34' => 15, | ||
]; | ||
|
||
foreach ($data as $key => $value) { | ||
$match = []; | ||
assertType('bool', preg_match('/^c(\d+)$/', $key, $match) || empty($match)); | ||
} | ||
}; | ||
|
||
function (): void { | ||
$data = [ | ||
'c1' => 12, | ||
'rasd' => 13, | ||
'c34' => 15, | ||
]; | ||
|
||
foreach ($data as $key => $value) { | ||
assertType('bool', preg_match('/^c(\d+)$/', $key, $match) || empty($match)); | ||
} | ||
}; |