Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Covariant template not supported call-site #10892

Open
pkly opened this issue Apr 10, 2024 · 1 comment
Open

Covariant template not supported call-site #10892

pkly opened this issue Apr 10, 2024 · 1 comment

Comments

@pkly
Copy link

pkly commented Apr 10, 2024

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.

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant