Suggestion: remove #[Override] where no matching parent method exists.
Feature Request
https://3v4l.org/GNlaC https://getrector.com/demo/4fb89aa4-219b-4f41-84a3-e3fa2a0cf625
Diff
<?php
interface ParentInterface
{
public function foo(): void;
}
final class ChildClass implements ParentInterface
{
public function foo(): void
{
echo 'foo';
}
- #[\Override]
public function bar(): void
{
echo 'bar';
}
}
(new ChildClass())->bar();
Never mind, this is something PHPStan already warns us about (fatal error).
This would be great dead code rule though 👌
I am thinking on the contrary, the fatal error is expected, when you have fatal error, you can immediatelly see there is BC break, and you can see the upgrade guide how to upgrade the child class correctly, eg: to use new method, then you see if you can use some configurable rector rule to upgrade it available, or create your own custom rector rule to upgrade to new method.
Removing the #[\Override] will cause silent check of available method in parent, make invalid change.
Males sense, this would have to be handled by PHPStan.
This issue has been automatically locked because it has been closed for 150 days. Please open a new issue if you have a similar problem.