vimeo / psalm

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

further adventures in the saga of "am I doing it wrong?" (the answer is probably yes) #1277

Closed SignpostMarv closed 5 years ago

SignpostMarv commented 5 years ago

So I've been pruning out code from my projects that psalm renders superfluous, but I've still not quite groked appropriate use of @template-*

One of the possible issues that I'm getting is that some of the code in a class was split across two different traits (for reasons of Scrutinizer's code quality score being gameable).

Only problem is that I think I've messed up the template inheritance tags ?

If you can spare a moment in your undoubtedly busy schedule to identify what I'm doing wrong (as I doubt I've broken something in psalm this time), your help would be gratefully appreciated.

muglug commented 5 years ago

Is it possible to reproduce the problem into something that fits in getpsalm.org?

SignpostMarv commented 5 years ago

this isn't quite the same thing, but seems to be similar enough to get started? https://getpsalm.org/r/5a157dbbc3

SignpostMarv commented 5 years ago

tl:dr; it seems that using union types w/ @template is a bad idea.

muglug commented 5 years ago

Yes, sorry - I just commented in https://github.com/vimeo/psalm/pull/1285#issuecomment-460842272

muglug commented 5 years ago

BUT intersection types should be fine

muglug commented 5 years ago

I've ticketed that here: https://github.com/vimeo/psalm/issues/1287

muglug commented 5 years ago

though if stuff still doesn't work after that's fixed feel free to create more

SignpostMarv commented 5 years ago

oh I'm happy with this being closed- I've taken the option of rather than specifying T0&T1, to actually implement & require interface T0andT1 extends T0, T1 {} :P