Open VincentLanglet opened 1 year ago
I found these snippets:
Do you mean @template-covariant? This has been supported since a long time: https://psalm.dev/docs/annotating_code/templated_annotations/#template-covariance
Do you mean @template-covariant? This has been supported since a long time: psalm.dev/docs/annotating_code/templated_annotations/#template-covariance
No, I mean https://phpstan.org/blog/guide-to-call-site-generic-variance#call-site-variance
It's when you use
/** @param Collection<covariant Animal> $animals */
to enjoy some of the covariant feature for a non-covariant template in a specific method.
See https://phpstan.org/r/5689cf72-aca5-4bbc-9593-1ffdf182731b for example.
That would be awesome!
PHPStan introduced call-site variance https://phpstan.org/blog/guide-to-call-site-generic-variance But Psalm doesn't support the syntax so far. https://psalm.dev/r/8244015134
Would it be something possible ? A first step could be at least to not report an error for Foo<*> and consider Foo
Then there will be
Foo<covariant Bar>
andFoo<contravariant Bar>