Skip to content

Conversation

@carlos-granados
Copy link
Contributor

The StaticCallOnNonStaticToInstanceCallRector rule was skipping the case where the static call was to a method that was implemented in the same class or a superclass. But it should actually only skip if it is a superclass. For the same class, it makes more sense to convert the call to a method call to the current instance.

Fixes rectorphp/rector#9613

When calling a non-static method statically from within the same class,
convert to $this->method() instead of skipping. This eliminates the
PHP deprecation warning for non-static method called statically.

Calls to ancestor methods (e.g., Grandpa::method() from a descendant)
are still skipped as they are valid non-static usage.
@TomasVotruba TomasVotruba merged commit 5ce62c7 into rectorphp:main Feb 3, 2026
57 checks passed
@TomasVotruba
Copy link
Member

Looks good to me, thank you

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not fixing statics within a class properly

2 participants