Commit 1df597b
Fix match expression with post/pre-increment condition using wrong type
- MutatingScope::enterMatch() re-evaluated the condition type after the
scope had already been updated by processing the increment expression,
causing $i++ to be seen as int<1, max> instead of int<0, max>
- Pass the pre-computed condition type and native type from
NodeScopeResolver to enterMatch() so it uses the correct types
- New regression test in tests/PHPStan/Rules/Comparison/data/bug-11310.php
Closes phpstan/phpstan#113101 parent 8717c5d commit 1df597b
File tree
4 files changed
+44
-4
lines changed- src/Analyser
- tests/PHPStan/Rules/Comparison
- data
4 files changed
+44
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2987 | 2987 | | |
2988 | 2988 | | |
2989 | 2989 | | |
2990 | | - | |
| 2990 | + | |
2991 | 2991 | | |
2992 | 2992 | | |
2993 | 2993 | | |
| |||
3001 | 3001 | | |
3002 | 3002 | | |
3003 | 3003 | | |
3004 | | - | |
3005 | | - | |
| 3004 | + | |
| 3005 | + | |
3006 | 3006 | | |
3007 | 3007 | | |
3008 | 3008 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4179 | 4179 | | |
4180 | 4180 | | |
4181 | 4181 | | |
| 4182 | + | |
4182 | 4183 | | |
4183 | 4184 | | |
4184 | 4185 | | |
4185 | 4186 | | |
4186 | 4187 | | |
4187 | 4188 | | |
4188 | | - | |
| 4189 | + | |
4189 | 4190 | | |
4190 | 4191 | | |
4191 | 4192 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
449 | 460 | | |
| 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 | + | |
0 commit comments