Skip to content

[DeadCode] Add RemoveParentDelegatingClassMethodRector#8204

Merged
TomasVotruba merged 2 commits into
mainfrom
dead-code-remove-parent-delegating-class-method
Jul 23, 2026
Merged

[DeadCode] Add RemoveParentDelegatingClassMethodRector#8204
TomasVotruba merged 2 commits into
mainfrom
dead-code-remove-parent-delegating-class-method

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Complements RemoveParentDelegatingConstructorRector, which only handles __construct(). Any other method whose body is a single parent::sameMethod($sameParams) call does nothing either.

 final class SomeCommand extends Command
 {
-    protected function configure(): void
-    {
-        parent::configure();
-    }
 }

Return-value delegation is covered too:

 final class SomeReader extends AbstractReader
 {
-    public function read(string $path): string
-    {
-        return parent::read($path);
-    }
 }

Skipped when removal would change behavior or signature:

  • __construct() (other rule owns it)
  • final, abstract, private, by-ref returning methods
  • body with more than the single parent call, or delegating to a different parent method
  • visibility or static-ness differing from parent (public function configure() over a protected parent)
  • param type / return type narrower than parent
  • params with defaults, variadic, by-ref, or attributes
  • method attributes, or @param/@return docblocks refining types

@TomasVotruba
TomasVotruba merged commit e46bfd9 into main Jul 23, 2026
66 checks passed
@TomasVotruba
TomasVotruba deleted the dead-code-remove-parent-delegating-class-method branch July 23, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant