Repository navigation
Name the keys of array shapes that might not be lists with bleeding edge - #7309
Merged
Merged
Conversation
With bleeding edge, array{0: string, 1: int} is only maybe a list, but it
was described as array{string, int}, which is the way a list shape is
written. Errors then read "expects list<int|string>, array{string, int}
given", and the description pasted back into a PHPDoc meant a different
type. A shape with two or more keys that is not surely a list now names
its keys in describe() and toPhpDocNode(): array{0: string, 1: int}.
Shapes that surely are lists keep array{string, int}, and nothing changes
without bleeding edge.
turbo-ext: the same in ConstantArrayType.
Amp-Thread-ID: https://ampcode.com/threads/T-01a23bb9-e820-77ee-954b-8a308da670c2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With bleeding edge, a PHPDoc shape with explicit keys like
array{0: string, 1: int}is only maybe a list (cb32a53), but it was still described asarray{string, int}, which is how a list shape is written. Downstream projects got self-contradictory errors such as:and the description, pasted back into PHPDoc, meant a different type.
Now a shape with two or more keys that is not surely a list names its keys in
describe()andtoPhpDocNode():@return array{0: string, 1: int}@return array{string, int}array{0: string, 1: int}, rejected forlist<…>array{string, int}, acceptedarray{string, int}, acceptedarray{string, int}, acceptedShapes that surely are lists keep
array{X, Y}, and nothing changes without bleeding edge. The 42 changed expectations are all genuine maybe-lists: arrays afteruasort()/uksort(),array{0: …, 1?: …}narrowed bycount(), unsealed shapes andlocaltime()'s non-assoc return.turbo-ext mirrors the change in
ConstantArrayType.cpp; the full suite passes with and without the extension, and signature parity, smoke and side-by-side pass.