Skip to content

[perf] Speed up legacy Php rules with cheap guards before reflection and type lookup - #8672

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

TomasVotruba merged 1 commit into
mainfrom
tv-perf-legacy-php-cheap-guard

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

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

  • SensitiveConstantNameRector (Php73) - the already-uppercase check and the special-character str_contains bails now run before reflectionProvider->hasConstant(); since most constant names are already uppercase, the reflection lookup is skipped in the common case.
  • ExportToReflectionFunctionRector (Php74) - the first-argument presence check now runs before getType($node->class).
  • IsIterableRector (Php71) - shouldSkip() now checks the PHP version before reflectionProvider->hasFunction() (semantically identical, skips the function reflection lookup when the version already provides is_iterable).
  • RemoveExtraParametersRector (Php71) - isFirstClassCallable() now runs before resolving the function/method reflection.
  • ThisCallOnStaticMethodToStaticCallRector (Php70) - isFirstClassCallable() now runs before staticAnalyzer->isStaticMethod().

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

@TomasVotruba
TomasVotruba merged commit 81b5d9f into main Oct 16, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-legacy-php-cheap-guard 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