Skip to content

[perf] Skip NarrowArrayCollectionUnionReturnDocblockRector for nodes without a docblock - #8630

Merged
TomasVotruba merged 2 commits into
mainfrom
perf-narrow-arraycollection-skip-nondoc
Oct 11, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
perf-narrow-arraycollection-skip-nondoc

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to the RenameClassRector phpdoc-guard optimization.

NarrowArrayCollectionUnionReturnDocblockRector subscribes to ClassMethod and Function_, building a PhpDocInfo for every visited node to narrow a union @return tag. The tag only exists in a docblock, so guard the path behind getDocComment() !== null. Without one there is nothing to narrow, so behaviour is identical.

Tests green, ECS + PHPStan level 8 clean.

TomasVotruba and others added 2 commits October 11, 2026 19:22
…without a docblock

The rule subscribes to ClassMethod and Function_ and built a PhpDocInfo for every node to narrow a union @return tag. The tag only exists in a docblock; guard with getDocComment(). Without one there is no @return to narrow, so behaviour is unchanged.
@TomasVotruba
TomasVotruba merged commit a8ad07c into main Oct 11, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-narrow-arraycollection-skip-nondoc branch October 11, 2026 17:37
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