Skip to content

[perf] Speed up Php rules with cheap name and structural guards before type resolution and reflection - #8671

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-php-cheap-guard-before-type-reflection
Oct 16, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-php-cheap-guard-before-type-reflection

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

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

  • AddEscapeArgumentRector (Php84) - the named-arg and argument-count bails now run before isObjectType(SplFileObject).
  • MyCLabsMethodCallToEnumConstRector / SpatieEnumMethodCallToEnumConstRector (Php81) - the handled method-name check now runs before isObjectType(), so calls to other method names skip the type resolution. The redundant trailing name branch is folded away.
  • StrEndsWithRector (Php80) - the count($args) < 2 bail now runs before valueResolver->isValue().
  • AddParamBasedOnParentClassMethodRector (Php80) - the parent method name check (=== "query") now short-circuits before ClassReflection::is("PDO"), so the ancestry check runs only for a parent query() method.
  • AddTypeToConstRector (Php83) - parent reflections are now resolved lazily (only once a constant passes the cheap guards), and canBeInherited() is checked before the parent-guarded reflection lookup.

Reordering is safe: all moved checks are side-effect-free bail conditions, and the lazily-computed parent reflections are resolved before first use.

@TomasVotruba
TomasVotruba merged commit 323fb23 into main Oct 16, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-php-cheap-guard-before-type-reflection branch October 16, 2026 06: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