Skip to content

[TypeDeclaration] Skip private method param called with ArrayAccess arg in StrictArrayParamDimFetchRector - #8648

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-9927-strict-array-param-arrayaccess-caller
Oct 12, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix-9927-strict-array-param-arrayaccess-caller

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9927

StrictArrayParamDimFetchRector added an array type hint based on $param[...] dim fetch usage, but an object implementing \ArrayAccess also supports [] access. When such an object was passed, the added array type caused a TypeError.

A private method is only reachable from inside its own class, so all of its callers are visible in the same file. This adds a guard that, for a private method, scans those callers and skips adding array when any positional argument resolves to an ArrayAccess object type.

Public methods are left unchanged, since their callers can live in other files and cannot be fully resolved here.

@TomasVotruba
TomasVotruba merged commit 613c740 into main Oct 12, 2026
49 checks passed
@TomasVotruba
TomasVotruba deleted the fix-9927-strict-array-param-arrayaccess-caller branch October 12, 2026 17:26
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.

StrictArrayParamDimFetchRector does not respect objects implementing \ArrayAccess interface

1 participant