Skip to content

[perf] Skip NestedAnnotationToAttributeRector for nodes without a docblock - #8628

Merged
TomasVotruba merged 2 commits into
mainfrom
perf-nested-annotation-to-attribute-skip-nondoc
Oct 11, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
perf-nested-annotation-to-attribute-skip-nondoc

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to the RenameClassRector phpdoc-guard optimization.

NestedAnnotationToAttributeRector subscribes to Property, Class_ and Param and built a PhpDocInfo for every visited node. Its attribute groups come only from docblock doctrine annotations, and it reprints an existing docblock rather than adding one, so a node without a docblock always ends in return null.

Guard the phpdoc path behind getDocComment() !== null. Behaviour identical.

Tests: rules-tests/Php80/Rector/Property/NestedAnnotationToAttributeRector (10) green, ECS + PHPStan level 8 clean.

TomasVotruba and others added 2 commits October 11, 2026 18:56
…block

The rule subscribes to Property, Class_ and Param and built a PhpDocInfo for every node. The attribute groups come only from docblock doctrine annotations and it reprints an existing docblock, so a node without one always returns null. Guard the phpdoc path behind getDocComment(). Behaviour unchanged.
@TomasVotruba
TomasVotruba force-pushed the perf-nested-annotation-to-attribute-skip-nondoc branch from db26b43 to e2270d7 Compare October 11, 2026 16:56
@TomasVotruba
TomasVotruba merged commit ceab323 into main Oct 11, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-nested-annotation-to-attribute-skip-nondoc branch October 11, 2026 17:05
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