Skip to content

[perf] Speed up ConvertStaticToSelfRector by deferring scope fetching until static member access is found - #8801

Open
alfredbez wants to merge 1 commit into
rectorphp:mainfrom
alfredbez:fix/rector-perf-convert-static-to-self-lazy-scope
Open

alfredbez wants to merge 1 commit into
rectorphp:mainfrom
alfredbez:fix/rector-perf-convert-static-to-self-lazy-scope

Conversation

@alfredbez

Copy link
Copy Markdown
Contributor

In ConvertStaticToSelfRector, ScopeFetcher::fetch($node) and $scope->getClassReflection() were called immediately upon entering every Class_ node. For classes containing no static:: calls, property fetches, or constant fetches, resolving scope and reflection is unnecessary.

Reproducer

final class WithoutStaticAccess
{
    public function run(string $value): string
    {
        return strtoupper($value);
    }
}

Expected Behavior

ConvertStaticToSelfRector should inspect member fetches and filter out non-static calls or dynamic member references before fetching scope, resolving class reflection lazily only when an eligible static access is found.

@alfredbez
alfredbez force-pushed the fix/rector-perf-convert-static-to-self-lazy-scope branch from 107a197 to f2c7ecb Compare October 24, 2026 01:03
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.

1 participant