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 cannot contain unions #6397

Open simPod opened 3 years ago

simPod commented 3 years ago

https://psalm.dev/r/baf0df5a1a

I wonder why Intersection types cannot contain unions

I wanted the type to implement either interface A or B and be of type static at the same time.

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

I found these snippets:

https://psalm.dev/r/baf0df5a1a ```php
orklah commented 3 years ago

Don't quote me on this but my best guess is that it was a solution to limit complexity of the implementation. I didn't yet work in this part of the code, but I expect this will be tricky to understand.

I'll flag this as enhancement, but I don't think I'll work on it unless it become part of PHP itself...

As a workaround, I'd suggest having both class implement a common interface...