Skip to content

[perf] Speed up CodeQuality rules with cheap guards before type resolution, reflection and subtree walks - #8664

Merged
TomasVotruba merged 2 commits into
mainfrom
fix-9932-readonly-anon-class-attribute
Oct 15, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
fix-9932-readonly-anon-class-attribute

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

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

Each rule ran an expensive op (type resolution, reflection, or a node-finder subtree walk) before a cheap check that can bail first:

  • ThrowWithPreviousExceptionRector - isFirstClassCallable() now runs before resolveExceptionArgumentPosition() (reflection).
  • RepeatedOrEqualToInArrayRector - the Equal node walk is now done lazily inside the $identicals !== [] branch (its only use), so an expression with no Identical skips it.
  • RepeatedAndNotEqualToNotInArrayRector - same, the NotEqual walk is done only when $notIdenticals is non-empty.
  • SimplifyEmptyCheckOnEmptyArrayRector - the allowed-expression instanceof check now runs before $scope->getType().
  • IssetOnPropertyObjectToPropertyExistsRector - the ArrayDimFetch bail now runs before shouldSkipForPropertyTypeDeclaration() and matchPropertyTypeClassReflection() (reflection + getType).
  • TernaryEmptyArrayArrayDimFetchToCoalesceRector - the areNodesEqual() comparison now runs before getType().
  • InlineIsAInstanceOfRector - the second argument shape (Variable / ClassConstFetch) is checked before isFirstObjectType() (getType).

Reordering is safe: all moved checks are side-effect-free bail conditions, and each lazily-computed value is used only in the branch it was moved into.

@TomasVotruba
TomasVotruba merged commit 749f8b3 into main Oct 15, 2026
121 of 127 checks passed
@TomasVotruba
TomasVotruba deleted the fix-9932-readonly-anon-class-attribute branch October 15, 2026 19:34
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