Skip to content

Keep the keys of both shapes when intersecting shapes that may have unlisted keys - #7223

Merged
ondrejmirtes merged 1 commit into
2.3.xfrom
intersect-legacy-shapes-keep-keys
Nov 27, 2026
Merged

ondrejmirtes merged 1 commit into
2.3.xfrom
intersect-legacy-shapes-keep-keys

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

A shape that is neither sealed nor unsealed may hold keys it does not list, so its intersection with another shape now keeps the keys only one of them lists, with that shape's value. Before, ArrayAlgebra::tryIntersectShapeWithArray() rebuilt the result from the keys of one shape only, so Report&array{column: string, metadata: array{columns: …}} lost reportData, metadata.metrics and metadata.dimension.

The same rebuild existed before ea8e0a3, but the old pairwise loop only reached it for one order of the members; the intersect pipeline reaches it for both.

Closes phpstan/phpstan#15855

…nlisted keys

A shape that is neither sealed nor unsealed may hold keys it does not
list, so its intersection with another shape keeps the keys only one of
them lists, with that shape's value. Before, the intersection was rebuilt
from the keys of one shape only, so array{a: int}&array{b: int} became
array{a: int}.

Amp-Thread-ID: https://ampcode.com/threads/T-01a21c49-c694-75f7-8560-fafa01a38f9d
@ondrejmirtes
ondrejmirtes merged commit be6a761 into 2.3.x Nov 27, 2026
879 of 917 checks passed
@ondrejmirtes
ondrejmirtes deleted the intersect-legacy-shapes-keep-keys branch November 27, 2026 13:50
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.

Intersecting two array shapes keeps only one of them (since phpstan-src ea8e0a356, #7195)

1 participant