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
Bug Report
Given a laravel Model with a scope, we can invoke it using both
$modelnstance->scope()andModel::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
StaticCallOnNonStaticToInstanceCallRectorrule 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