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

PHPDoc @return $this on interface causes covariant error #6462

Closed
Kingdutch opened this issue Jan 25, 2022 · 3 comments
Closed

PHPDoc @return $this on interface causes covariant error #6462

Kingdutch opened this issue Jan 25, 2022 · 3 comments
Labels
Milestone

Comments

@Kingdutch
Copy link

Bug report

Adding @return $this to an interface function will cause PHPStan to report a covariant error, even though the $this returned by the implementing class should satisfy.

Code snippet that reproduces the problem

https://phpstan.org/r/a65e6de5-f29c-456d-8047-dda161734892

Expected output

No errors

Did PHPStan help you today? Did it make you happy in any way?

Absolutely! Caught some bugs in things I had mistyped as well as some logic flaws. So after fixing that code review was smooth sailing :D

@ondrejmirtes
Copy link
Member

Hi, it looks like this is just an inheritDoc issue, repeating @return $this works: https://phpstan.org/r/2cbec6e2-2583-40d5-8762-f6c18a89b7c5

It's still a bug, just a minor one. And thank you for your kind words! :)

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#2803

Copy link

github-actions bot commented Jan 9, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants