Commit 53b917a
Fix conditional expression filtering in processAlwaysIterableForeachScopeWithoutPollute
The previous approach (using $finalScope->conditionalExpressions filtered
to $this variables) lost valid conditional expressions that existed in
$this but not in $finalScope, causing false positives like "Call to an
undefined method PhpParser\Node::getReturnType()".
The correct approach: start from $this->conditionalExpressions (pre-foreach)
and remove only entries where a condition variable's type changed between
$this and $finalScope, indicating it was reassigned in the foreach body
and the conditional expression is stale. When a type change is detected,
the entire conditional expression key is removed (not individual holders)
to avoid partial/inconsistent state.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8163acb commit 53b917a
1 file changed
+10
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3870 | 3870 | | |
3871 | 3871 | | |
3872 | 3872 | | |
3873 | | - | |
3874 | | - | |
3875 | | - | |
3876 | | - | |
3877 | | - | |
3878 | | - | |
| 3873 | + | |
| 3874 | + | |
3879 | 3875 | | |
3880 | | - | |
| 3876 | + | |
| 3877 | + | |
| 3878 | + | |
| 3879 | + | |
3881 | 3880 | | |
3882 | 3881 | | |
3883 | 3882 | | |
| 3883 | + | |
| 3884 | + | |
| 3885 | + | |
| 3886 | + | |
3884 | 3887 | | |
3885 | | - | |
3886 | | - | |
3887 | | - | |
3888 | | - | |
3889 | 3888 | | |
3890 | | - | |
3891 | 3889 | | |
3892 | 3890 | | |
3893 | 3891 | | |
| |||
0 commit comments