Skip to content

Infer precise array shape unions in array unpacking - #6447

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

klimick wants to merge 2 commits into
phpstan:2.3.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
@ondrejmirtes
ondrejmirtes changed the base branch from 2.2.x to 2.3.x November 1, 2026 11:53
@ondrejmirtes
ondrejmirtes force-pushed the more-prescice-shape-in-spread branch 3 times, most recently from e5a074c to a6c17c9 Compare November 1, 2026 12:41
@ondrejmirtes
ondrejmirtes force-pushed the more-prescice-shape-in-spread branch from a6c17c9 to 8e994fe Compare November 1, 2026 13: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