Commit 996ad98
Defer by-ref closure scope modifications after all args are processed
processClosureNode returned a scope with by-ref captured variable
modifications already applied. In processArgs, this polluted the
scope used for evaluating subsequent arguments - but closures are
not called during argument evaluation, so by-ref changes cannot
have taken effect yet.
The fix separates the by-ref data (closureResultScope, byRefUses)
from the returned scope in ProcessClosureResult and lets callers
decide when to apply it. The standalone closure call site applies
immediately, while processArgs defers it until after all arguments
are processed - same pattern as the existing deferral of
processImmediatelyCalledCallable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 2a92c7b commit 996ad98
3 files changed
Lines changed: 40 additions & 2 deletions
File tree
- src/Analyser
- tests/PHPStan/Rules/Methods/data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3493 | 3493 | | |
3494 | 3494 | | |
3495 | 3495 | | |
3496 | | - | |
| 3496 | + | |
3497 | 3497 | | |
3498 | 3498 | | |
3499 | 3499 | | |
| |||
5142 | 5142 | | |
5143 | 5143 | | |
5144 | 5144 | | |
5145 | | - | |
| 5145 | + | |
5146 | 5146 | | |
5147 | 5147 | | |
5148 | 5148 | | |
| |||
5551 | 5551 | | |
5552 | 5552 | | |
5553 | 5553 | | |
| 5554 | + | |
| 5555 | + | |
5554 | 5556 | | |
5555 | 5557 | | |
5556 | 5558 | | |
| |||
5662 | 5664 | | |
5663 | 5665 | | |
5664 | 5666 | | |
| 5667 | + | |
5665 | 5668 | | |
5666 | 5669 | | |
5667 | 5670 | | |
| |||
5753 | 5756 | | |
5754 | 5757 | | |
5755 | 5758 | | |
| 5759 | + | |
| 5760 | + | |
| 5761 | + | |
| 5762 | + | |
5756 | 5763 | | |
5757 | 5764 | | |
5758 | 5765 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
30 | 43 | | |
31 | 44 | | |
32 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
0 commit comments