Repository navigation
[perf] Speed up Php rules with cheap name and structural guards before type resolution and reflection - #8671
Merged
TomasVotruba merged 1 commit intoOct 16, 2026
Conversation
…e type resolution and reflection
TomasVotruba
deleted the
tv-perf-php-cheap-guard-before-type-reflection
branch
October 16, 2026 06:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Performance refactor of 6 rules. No behavior change - all fixtures pass unchanged.
AddEscapeArgumentRector(Php84) - the named-arg and argument-count bails now run beforeisObjectType(SplFileObject).MyCLabsMethodCallToEnumConstRector/SpatieEnumMethodCallToEnumConstRector(Php81) - the handled method-name check now runs beforeisObjectType(), so calls to other method names skip the type resolution. The redundant trailing name branch is folded away.StrEndsWithRector(Php80) - thecount($args) < 2bail now runs beforevalueResolver->isValue().AddParamBasedOnParentClassMethodRector(Php80) - the parent method name check (=== "query") now short-circuits beforeClassReflection::is("PDO"), so the ancestry check runs only for a parentquery()method.AddTypeToConstRector(Php83) - parent reflections are now resolved lazily (only once a constant passes the cheap guards), andcanBeInherited()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.