Bug Report
| Subject |
Details |
| Rector version |
last dev-main |
| Installed as |
composer dependency |
Minimal PHP Code Causing Issue
See https://getrector.org/demo/0cba1567-b1f4-46f8-8dc6-3d639741939c
<?php
class A {
public function method() {
$this->foo();
}
public function foo() {
echo 'HI' . PHP_EOL;
}
}
class B extends A {
public function method() {
// this call is allowed, same as parent::method()
A::method();
}
}
class C extends B {
public function method() {
// this is also a valid call, but Rector does not recognize it
A::method();
}
}
(new C)->method();
Responsible rules
StaticCallOnNonStaticToInstanceCallRector
Expected Behavior
Rector correctly recognizes that B extends A so calling A::method() from its overridden implementation is not a problematic static method call.
C also extends A, and calling A::method() from inside C::method() is valid (it’s also recognized in other languages like C++), so it should be left unchanged. But Rector does not recognize it as such.