Open ciaranmcnulty opened 1 year ago
I found these snippets:
Psalm doesn't support having two array in a union and will always try to combine them into a single notation. When doing so, it will try to loose minimal meaning but in this case, it's forced to loose the "one of the offset is defined"
Can the reasons for not supporting it be addressed now there are sealed types?
and the result of array_key_exists seems just plain wrong
Sealed types don't really change the subject. The core issue is that there is only one slot for arrays in a Union. It's just a design limitation.
It can be addressed but it gonna be a big work.
And yeah, we shouldn't infer anything with array_key_exists here, you can create an issue for that
Incorrect example removedhttps://psalm.dev/r/5f8c0cdbd3
I may be misunderstanding things but in latest psalm my var
$union
is definitely either an array withBOOP
key only or withBEEP
key only.However it gets normalised to
array{BEEP?: ..., BOOP?: ...}
with various odd side effects, including after an array_key_exists psalm seems to think both keys are definitely set