psalm
psalm copied to clipboard
Covariant template not supported call-site
https://psalm.dev/r/766ceeaa45
PHPStan supports the following syntax https://phpstan.org/blog/whats-up-with-template-covariant#call-site-variance (and is very picky about you not using it), but Psalm produced an invalid PHPDoc error.
I found these snippets:
https://psalm.dev/r/766ceeaa45
<?php
/**
* @template T of object
*/
class Foo {
public function do(): void {}
}
/**
* @param Foo<covariant object> $f
*/
function bar(Foo $f): void {
$f->do();
}
Psalm output (using commit ef3b018):
ERROR: UndefinedDocblockClass - 11:12 - Docblock-defined class, interface or enum named covariantobject does not exist