Skip to content

StaticCallOnNonStaticToInstanceCallRector rule fails to check static context #9647

@ActualFab

Description

@ActualFab

Bug Report

Subject Details
Rector version v2.3.6

Given a laravel Model with a scope, we can invoke it using both $modelnstance->scope() and Model::scope().
Now given that this model also has a static function to perfom some task, within this function we MUST use Model::scope() since the method itself is static.

A rector pass will trigger the StaticCallOnNonStaticToInstanceCallRector rule on that line and propose to change it to $this->scope()

Minimal PHP Code Causing Issue

Not an easy one to reproduce in demo, since it involves Laravel Proxy Magic.

Expected Behaviour

This rule should additionally make sure that the eventual method context is not static before applying/proposing the fix.


First time ever I run into an issue with rector and I use it on quite large code bases, so thank you and keep up the good work !

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions