Commit 7d5cdfc
Fix phpstan/phpstan#14096: By-reference variables in closures lose type after deferred application
- When multiple closures capture the same by-ref variable, deferred application
caused later closures to overwrite earlier modifications with their stale types
- Pass current scope as prevScope when applying deferred by-ref results so types
are unioned instead of replaced
- Guard processClosureScope against undefined variables in prevScope
- New regression test in tests/PHPStan/Analyser/nsrt/bug-14096.php1 parent dab4101 commit 7d5cdfc
File tree
4 files changed
+57
-4
lines changed- src/Analyser
- tests/PHPStan/Analyser/nsrt
4 files changed
+57
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3808 | 3808 | | |
3809 | 3809 | | |
3810 | 3810 | | |
3811 | | - | |
| 3811 | + | |
3812 | 3812 | | |
3813 | 3813 | | |
3814 | 3814 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3455 | 3455 | | |
3456 | 3456 | | |
3457 | 3457 | | |
3458 | | - | |
| 3458 | + | |
3459 | 3459 | | |
3460 | 3460 | | |
3461 | 3461 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| 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 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments