vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.55k stars 659 forks source link

Intersection types don't allow arrays #7600

Open danog opened 2 years ago

danog commented 2 years ago

I find it often useful to use intersection types to enhance the keys of an array, but psalm doesn't like it: https://psalm.dev/r/125b383b8b

psalm-github-bot[bot] commented 2 years ago

I found these snippets:

https://psalm.dev/r/125b383b8b ```php
orklah commented 2 years ago

This is just missing support for intersections between templates and keyed array. The intersection in itself is ok: https://psalm.dev/r/9384c60365

This should probably not be hard to fix and we have one or two similar issues (intersection with aliased types)

psalm-github-bot[bot] commented 2 years ago

I found these snippets:

https://psalm.dev/r/9384c60365 ```php
kkmuffme commented 1 year ago

Especially with v5 unsealed arrays and restrictReturnTypes this is a more common issue now

kkmuffme commented 10 months ago

It seems this worked previously? https://github.com/vimeo/psalm/pull/3064