Commit 4457c55
Fix incorrect dependent type inference after repeated boolean checks
- Fixed conditional expression resolution in filterBySpecifiedTypes to intersect types
instead of overwriting when multiple conditional expressions fire for the same target
- When two conditionals with the same guard produced different types (one more specific
than the other), the less specific type could overwrite specifiedExpressions, causing
cascading wrong matches that led to variables being incorrectly narrowed to *NEVER*
- New regression test in tests/PHPStan/Analyser/nsrt/bug-14211.php
Closes phpstan/phpstan#142111 parent 0b8e988 commit 4457c55
2 files changed
Lines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3833 | 3833 | | |
3834 | 3834 | | |
3835 | 3835 | | |
3836 | | - | |
| 3836 | + | |
| 3837 | + | |
| 3838 | + | |
| 3839 | + | |
| 3840 | + | |
| 3841 | + | |
| 3842 | + | |
| 3843 | + | |
| 3844 | + | |
3837 | 3845 | | |
3838 | 3846 | | |
3839 | 3847 | | |
| |||
| 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 | + | |
0 commit comments