Skip to content

Widen the values of a lone shape instead of degrading it to an oversized array - #7239

Merged
ondrejmirtes merged 1 commit into
2.3.xfrom
widen-values-of-lone-shape
Nov 28, 2026
Merged

ondrejmirtes merged 1 commit into
2.3.xfrom
widen-values-of-lone-shape

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

SharedKeyShapeWidening widened the values of the shapes only once it folded two or more of them. A single shape over the limit because of the shapes nested in it, such as array{header: ..., message: non-empty-array<...>} built in nested loops, went straight to OversizedArrayWidening and lost all its keys, so optional keys such as 'transaction' were no longer reported as possibly missing. The lone shape now keeps its keys and only its values widen.

The issue's snippet infers the 2.3.6 type again and reports both Offset 'transaction' might not exist errors.

Closes phpstan/phpstan#15869

Amp thread: https://ampcode.com/threads/T-01a22094-706b-72f3-83ff-6df2ad61c23f

…zed array

SharedKeyShapeWidening widened the values of the shapes only once it
folded two or more of them. A single shape over the limit because of the
shapes nested in it, such as array{header: ..., message: non-empty-array<...>}
built in nested loops, went straight to OversizedArrayWidening and lost
all its keys, so optional keys such as 'transaction' were no longer
reported as possibly missing. The lone shape now keeps its keys and only
its values widen.

Amp-Thread-ID: https://ampcode.com/threads/T-01a22094-706b-72f3-83ff-6df2ad61c23f
@ondrejmirtes
ondrejmirtes merged commit 5b1f8b5 into 2.3.x Nov 28, 2026
558 of 564 checks passed
@ondrejmirtes
ondrejmirtes deleted the widen-values-of-lone-shape branch November 28, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant