Commit b07a1ab
Fix phpstan/phpstan#14411: Incorrect type narrowing with dependent types
- In createConditionalExpressions(), type guards were created for variables
whose branch types overlapped, allowing narrowing of one variable to
incorrectly narrow a dependent variable from a different branch
- Added a disjointness check: a variable is only used as a type guard when
its "our" branch type and "their" branch type don't overlap
- New regression test in tests/PHPStan/Analyser/nsrt/bug-14411.php1 parent b70fb0f commit b07a1ab
File tree
2 files changed
+41
-0
lines changed- src/Analyser
- tests/PHPStan/Analyser/nsrt
2 files changed
+41
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3580 | 3580 | | |
3581 | 3581 | | |
3582 | 3582 | | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
3583 | 3590 | | |
3584 | 3591 | | |
3585 | 3592 | | |
| |||
| 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 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
0 commit comments