Skip to content

Infer precise array shape unions in array unpacking - #6447

Open
klimick wants to merge 2 commits into
phpstan:2.2.xfrom
klimick:more-prescice-shape-in-spread
Open

klimick wants to merge 2 commits into
phpstan:2.2.xfrom
klimick:more-prescice-shape-in-spread

Conversation

@klimick

@klimick klimick commented Sep 15, 2026

Copy link
Copy Markdown

This PR preserves correlations between constant array variants during array unpacking instead of collapsing them into a single shape with optional keys.

It handles string-key overwrites, integer-key renumbering, optional offsets, and combinations of explicit and unpacked elements.
Precise expansion is limited to 32 combinations, with the existing approximation retained as a fallback for larger products.

The new behavior is guarded by the preciseArrayShapeUnpacking bleeding-edge feature toggle.
Regression tests cover both precise and approximated inference.

@klimick
klimick force-pushed the more-prescice-shape-in-spread branch from 3f2227c to c5c57eb Compare September 15, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant