Skip to content

[perf] Resolve method name before receiver type in reflection and AST resolvers - #8682

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-hoist-name-guard
Oct 16, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-hoist-name-guard

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Hoists the cheap methodName === null guard above the expensive nodeTypeResolver->getType() call on the receiver in three hot per-call resolvers. When the call name is unresolvable the methods bail, so the full PHPStan type resolution on the receiver was wasted on that path.

  • ReflectionResolver::resolveMethodReflectionFromStaticCall
  • ReflectionResolver::resolveMethodReflectionFromMethodCall
  • AstResolver::resolveClassMethodFromCall

Pure statement reorder, behaviour unchanged - the name check is independent of the resolved type. Matches the ordering the sibling resolvePropertyReflectionFromPropertyFetch already uses.

Validated locally: ECS and PHPStan level 8 clean on both files, rules-tests/TypeDeclaration + rules-tests/DeadCode green (1765 tests).

@TomasVotruba
TomasVotruba merged commit 2d8dce0 into main Oct 16, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-hoist-name-guard branch October 16, 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