vimeo / psalm

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

Add support for certain pseudo-type intersections e.g. `literal-string&non-empty-string` #9628

Open ZebulanStanphill opened 1 year ago

ZebulanStanphill commented 1 year ago

PHPStan supports intersections of certain pseudo-types, which I find to be quite useful and use a lot in my projects:

Unfortunately, Psalm currently appears to only accept intersections of object types. https://psalm.dev/r/4ef9f549b4

I am aware that Psalm supports some equivalent single pseudo-types like non-empty-literal-string, and PHPStan even added support for some of these recently; but it seems counterintuitive that the intersection form wouldn't just work, and some of the IDE tooling I'm using right now in VS Code only supports the simpler pseudo-types and intersections.

psalm-github-bot[bot] commented 1 year ago

I found these snippets:

https://psalm.dev/r/4ef9f549b4 ```php