Skip to content

[DeadCode] Skip annotation docblocks in RemoveParentDelegatingClassMethodRector - #8459

Merged
TomasVotruba merged 2 commits into
mainfrom
fix-parent-delegating-annotation-docblock
Sep 4, 2026
Merged

[DeadCode] Skip annotation docblocks in RemoveParentDelegatingClassMethodRector#8459
TomasVotruba merged 2 commits into
mainfrom
fix-parent-delegating-annotation-docblock

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9887

RemoveParentDelegatingClassMethodRector removed a child method that only delegates to its parent even when the child method carried a docblock annotation such as @Route(...) or OpenAPI @OA\Get(...). Those annotations carry intent the parent does not have (routing, spec generation), so removing the method silently drops them.

The hasRefiningDocblock() bail-out only checked a fixed whitelist of tags (@param, @return, @deprecated, ...). It now bails on any docblock tag/annotation, so a delegating method with a meaningful docblock is kept.

Added skip_annotation_docblock.php.inc fixture covering the reported @Route case.

@TomasVotruba
TomasVotruba merged commit 3e10647 into main Sep 4, 2026
43 checks passed
@TomasVotruba
TomasVotruba deleted the fix-parent-delegating-annotation-docblock branch September 4, 2026 16:30
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.

RemoveParentDelegatingClassMethodRector removes different annotations on child classes

2 participants