psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Covariant template not supported call-site

Open pkly opened this issue 10 months ago • 1 comments

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.

pkly avatar Apr 10 '24 06:04 pkly

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

psalm-github-bot[bot] avatar Apr 10 '24 06:04 psalm-github-bot[bot]