Commit f555f50
committed
Fix null coalesce type inference for correlated int range variables
- Fixed getCoalesceType() in MutatingScope to avoid over-narrowing the right
side of ?? when conditional expressions from scope merging make correlated
variables all null together
- The fix uses the narrowed scope only when it successfully removes null from
the right type (useful for `if ($a || $b) { $a ?? $b }` patterns), and
falls back to the unfiltered type otherwise
- New regression test in tests/PHPStan/Analyser/nsrt/bug-14213.php
Closes phpstan/phpstan#142131 parent 1340aeb commit f555f50
File tree
2 files changed
+34
-1
lines changed- src/Analyser
- tests/PHPStan/Analyser/nsrt
2 files changed
+34
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6536 | 6536 | | |
6537 | 6537 | | |
6538 | 6538 | | |
6539 | | - | |
| 6539 | + | |
| 6540 | + | |
| 6541 | + | |
| 6542 | + | |
| 6543 | + | |
| 6544 | + | |
| 6545 | + | |
6540 | 6546 | | |
6541 | 6547 | | |
6542 | 6548 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
0 commit comments