Skip to content

[perf] Speed up DeadCode rules by deferring docblock parse and parent reflection behind cheap guards - #8667

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-dc-defer-docblock-and-parent-reflection
Oct 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-dc-defer-docblock-and-parent-reflection

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Performance refactor of 4 rules. No behavior change - all fixtures pass unchanged.

  • RemoveVoidDocblockFromMagicMethodRector - a cheap str_contains((string) $node->getDocComment(), "@return") check now runs before createFromNodeOrEmpty(), mirroring RemoveUselessReturnTagRector. getReturnTagValue() only reads plain @return tags, so the substring check is equivalent.
  • RemoveUnusedForeachKeyRector - the stale @var cleanup now parses the docblock only when @var is present in the doc comment.
  • RemoveParentDelegatingClassMethodRector - the structural isParentCallDelegatingParams() check now runs before hasRefiningDocblock() (docblock parse) and matchParentMethodReflection() (parent reflection).
  • RemoveParentDelegatingConstructorRector - the structural parent-call-args and parameter count/order checks now run before matchParentConstructorReflection() (parent reflection).

Reordering is safe: all moved checks are side-effect-free bail conditions that must all pass to proceed.

@TomasVotruba
TomasVotruba merged commit aee6fc8 into main Oct 15, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-dc-defer-docblock-and-parent-reflection branch October 15, 2026 19:35
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.

1 participant