Skip to content

[perf] Speed up callable param type rules by deferring type resolution until shape confirmed - #8662

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-skip-type-resolution-until-shape
Oct 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-skip-type-resolution-until-shape

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

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

Each rule resolved a type or parsed a docblock before confirming the call/param shape it needs could even match:

  • AddClosureParamTypeFromIterableMethodCallRector - the cheap callUsesClosures() arg check now runs before getType($node->var) and the method reflection lookup, so method calls with no closure argument bail first.
  • AddParamArrayDocblockBasedOnCallableNativeFuncCallRector - the callback-argument shape checks (arg present, arrow/closure, param count, typed params) now run before getNativeType($arrayArgValue), so a call whose callback is not a typed closure never resolves the array native type.
  • AddParamTypeSplFixedArrayRector - the docblock info is now parsed lazily, only once a param is confirmed to be an SplFixedArray type, so functions with no such param no longer parse their docblock.

Reordering is safe: the moved checks are side-effect-free bail conditions, and the lazy docblock is created before its first use.

@TomasVotruba
TomasVotruba merged commit 9cc6fd3 into main Oct 15, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the tv-perf-skip-type-resolution-until-shape branch October 15, 2026 11:24
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