Skip to content

[perf] Skip RemoveUselessVarTagRector for nodes without a docblock - #8624

Merged
TomasVotruba merged 2 commits into
mainfrom
perf-remove-useless-var-tag-skip-nondoc
Oct 11, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
perf-remove-useless-var-tag-skip-nondoc

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to the RenameClassRector phpdoc-guard optimization.

RemoveUselessVarTagRector subscribes to Property, ClassConst and Expression, and called createFromNodeOrEmpty() on every visited node. A useless @var can only exist inside a docblock, so for the many Expression nodes without one the work was wasted - VarTagRemover::removeVarTagIfUseless() returns false whenever there is no @var tag.

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

Tests: rules-tests/DeadCode/Rector/Property/RemoveUselessVarTagRector (19) green, ECS + PHPStan level 8 clean.

TomasVotruba and others added 2 commits October 11, 2026 18:42
A useless @var tag can only live in a docblock. The rule subscribes to Property, ClassConst and Expression and built a PhpDocInfo for every one, including the many Expression nodes that carry no docblock. Guard with a cheap getDocComment() check so the phpdoc work runs only when a docblock exists; removeVarTagIfUseless already returns false without a @var tag, so behaviour is unchanged.
@TomasVotruba
TomasVotruba merged commit b664405 into main Oct 11, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-remove-useless-var-tag-skip-nondoc branch October 11, 2026 16:53
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