Skip to content

[perf] Skip reflection in RemoveDuplicatedReturnSelfDocblockRector without a docblock - #8631

Merged
TomasVotruba merged 2 commits into
mainfrom
perf-remove-dup-return-self-skip-nondoc
Oct 11, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
perf-remove-dup-return-self-skip-nondoc

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to the RenameClassRector phpdoc-guard optimization.

RemoveDuplicatedReturnSelfDocblockRector resolved a ClassReflection and built a PhpDocInfo for every self/static returning method. A duplicated @return tag can only live in a docblock, so a method without one is always a no-op.

Add a getDocComment() !== null guard right after the self/static check and before the reflection resolution, so doc-less methods skip both the reflection and the phpdoc work. Behaviour identical.

Tests green, ECS + PHPStan level 8 clean.

TomasVotruba and others added 2 commits October 11, 2026 19:23
…thout a docblock

The rule resolved a ClassReflection and built a PhpDocInfo for every self/static returning method. A duplicated @return tag can only live in a docblock, so add a getDocComment() guard before the reflection resolution. A method without a docblock is a no-op anyway, so this skips the reflection work for it. Behaviour unchanged.
@TomasVotruba
TomasVotruba merged commit ab2b764 into main Oct 11, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-remove-dup-return-self-skip-nondoc branch October 11, 2026 17:38
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.

2 participants