Skip to content

[TypeDeclaration] Speed up StrictArrayParamDimFetchRector with cheap syntactic bail before reflection - #8654

Merged
TomasVotruba merged 1 commit into
mainfrom
perf-strict-array-param-dim-fetch
Oct 14, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
perf-strict-array-param-dim-fetch

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Rule fires on every ClassMethod, Function_ and Closure. After the untyped-param check it ran the parent-class reflection guards (hasParentClassMethod, isTypeGuardedClass) and then per-param getType traversal - even for the common case where an untyped param is never used in an array dim fetch.

This adds a cheap syntactic pre-scan: one traversal that looks for an ArrayDimFetch whose var is one of the untyped params, with no getType and no reflection. When nothing matches, the rule bails out before any reflection or type resolution happens.

…syntactic bail before reflection

Skip the parent-class reflection guards and per-param type resolution when
no untyped param is used in an array dim fetch at all. The pre-scan is a
purely syntactic traversal (no getType, no reflection), so the common case
of untyped params that are never dim-fetched bails out early.
@TomasVotruba
TomasVotruba merged commit b97ee43 into main Oct 14, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the perf-strict-array-param-dim-fetch branch October 14, 2026 21:42
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