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

False error: "Call to an undefined method ParentClass::getBar()" #3141

Closed
ThomasLandauer opened this issue Apr 2, 2020 · 2 comments
Closed

Comments

@ThomasLandauer
Copy link
Contributor

Bug report

Probably the same as #2874

phpstan/phpstan 0.12.18

Code snippet that reproduces the problem

https://phpstan.org/r/21d50449-fe46-45db-bf63-c5659fc13147

Situation: Parent class with return $this in a Setter. Then instantiate an object of a child class, call the setter, then some other method of the child class.

The root of the problem seems to be the return type self (line 6). phpstan obviously interprets this as ParentClass, not as Child

@ondrejmirtes
Copy link
Member

You need @return static: https://phpstan.org/r/9f27ade2-df84-47dd-a233-a8488992678e

@lock
Copy link

lock bot commented May 5, 2020

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.
BTW: Did you know that PHPStan now has a brand new website with a user guide, guide to writing analyser-friendly PHP code, and a guide to developing PHPStan extensions? Visit phpstan.org today!

@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants