Open AndrolGenhald opened 3 years ago
I found these snippets:
It seems that Psalm collapse non-empty-array<string, string>&array{foo?: string, bar?: string}
into array{bar?: string, foo?: string}<string, string>
which make it loose the non-empty part. This is probably cause by TypeCombiner. Not sure what effect it could have if we didn't. We could try.
About exhaustivity of array shapes, there's a debate about the syntax that should be used for that. I'll let PHPStan takes the lead on that and we'll follow with the syntax I think. Psalm current syntax is a bit weird and not consistent.
This works: https://psalm.dev/r/32b7137fa9 This doesn't: https://psalm.dev/r/6b95034171 This is a false negative: https://psalm.dev/r/be95fcaee2
It's also described as
array{...}<...>
instead ofnon-empty-array{...}<...>
: https://psalm.dev/r/abbebc2e18I'm also not sure I like the syntax,
array{...}&array<...>
seems to me like it should simplify toarray{...}
, since we're intersecting two types, andarray<...>
is a supertype ofarray{...}
. I think it would be nice to havearray{...}
be exhaustive (#5299) andarray(non-exhaustive){...}
orarray(nonstrict){...}
be a non-exhaustive object-like array (see #5560).