Skip to content

[perf] Speed up Transform and EarlyReturn rules with cheap guards before type checks and walks - #8670

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-misc-cheap-guard-before-type-walk
Oct 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-misc-cheap-guard-before-type-walk

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

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

  • WrapReturnRector - isObjectType() now runs after the method-name match, so the object type is only resolved when a method name matches the configured wrap.
  • ArrayDimFetchToMethodCallRector - the configured method lookup and its null check now run before isObjectType(), so a config entry with no method for the current magic handler skips the type check.
  • PreparedValueToEarlyReturnRector - the cheap areNodesEqual($assign->var, $returnedExpr) check now runs before the findFirst() subtree walk.
  • ReturnEarlyIfVariableRector - the assign-target structural checks (Variable, not static/global, not by-ref, matches the returned variable) now run before the docblock is parsed.

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

@TomasVotruba
TomasVotruba merged commit 76eda1a into main Oct 15, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-misc-cheap-guard-before-type-walk branch October 15, 2026 21:33
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