Commit c4e7c87
Fix non-negative-int generalized to int in for loop
- Fixed overly aggressive type generalization in MutatingScope::generalizeType()
for constant integers when values expand in both directions across loop iterations
- Instead of widening to plain `int`, now computes actual observed bounds, allowing
the next iteration to correctly determine stable vs growing bounds
- New regression test in tests/PHPStan/Analyser/nsrt/bug-12163.php
Closes phpstan/phpstan#121631 parent d32efcb commit c4e7c87
File tree
2 files changed
+40
-1
lines changed- src/Analyser
- tests/PHPStan/Analyser/nsrt
2 files changed
+40
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4112 | 4112 | | |
4113 | 4113 | | |
4114 | 4114 | | |
4115 | | - | |
| 4115 | + | |
| 4116 | + | |
| 4117 | + | |
| 4118 | + | |
| 4119 | + | |
| 4120 | + | |
| 4121 | + | |
| 4122 | + | |
| 4123 | + | |
| 4124 | + | |
| 4125 | + | |
| 4126 | + | |
| 4127 | + | |
4116 | 4128 | | |
4117 | 4129 | | |
4118 | 4130 | | |
| |||
| 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