Skip to content

Fix class scope refresh losing method scope when class node is already in class - #8725

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-class-scope-refresh
Oct 20, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix-class-scope-refresh

Conversation

@samsonasik

@samsonasik samsonasik commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

On downgrade process, given the following code:

    public function run(array $items): array
    {
        $result = [];
        foreach ($items as $item) {
            $result = [...$result, ...$items];
        }

        return $result;
    }

It cause change:

- $result = array_merge($result, $items);
+ $result = array_merge(is_array($result) ? $result : iterator_to_array($result), is_array($items) ? $items : iterator_to_array($items));

Which invalid due to losing method scope. This PR fix it with process class stmts directly instead and only fixable via ChangedNodeScopeRefresher

@TomasVotruba
TomasVotruba merged commit b595739 into main Oct 20, 2026
48 of 50 checks passed
@TomasVotruba
TomasVotruba deleted the fix-class-scope-refresh branch October 20, 2026 10:37
@TomasVotruba

Copy link
Copy Markdown
Member

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants