Skip to content

[perf] Speed up type declaration rules by resolving reflection only when needed - #8663

Merged
TomasVotruba merged 2 commits into
mainfrom
tv-perf-resolve-reflection-when-needed
Oct 15, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
tv-perf-resolve-reflection-when-needed

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

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

Each rule did reflection or a subtree walk before a cheaper check could rule the node out:

  • ReturnTypeFromStrictFluentReturnRector - the inferred return type is now checked for StaticType/ObjectType before resolveClassReflection(), so a method that does not return self/static/this never resolves the class reflection.
  • ReturnTypeFromStrictTypedPropertyRector - the hasOnlyReturnWithExpr() shape check now runs before the per-return resolvePropertyReflectionFromPropertyFetch() loop.
  • PropertyTypeFromStrictSetterGetterRector - the getter/setter type match (the rule's selective precondition) now runs before the isAssignedInConstructor() walk, so a property with no matching getter/setter skips the constructor scan.
  • ChildDoctrineRepositoryClassTypeRector - the entity type is resolved from the @extends docblock, so a class with no doc comment bails before isObjectType().

Reordering is safe: all moved checks are side-effect-free bail conditions.

@TomasVotruba
TomasVotruba merged commit 07055c6 into main Oct 15, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-resolve-reflection-when-needed branch October 15, 2026 11:25
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.

2 participants