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

Reusing previous assertions on the result of a getter is sometimes wrong #1253

Closed
arnaud-lb opened this issue Jul 20, 2018 · 1 comment
Closed

Comments

@arnaud-lb
Copy link
Contributor

Summary of a problem or a feature request

PHPStan remembers previous assertions about the result of a getter, and reuses that information for subsequent calls of the same getter. Sometimes, the getter can return something else.

Code snippet that reproduces the problem

https://phpstan.org/r/9320295e0a0f4c21589f5df1fd071bbe

Expected output

PHPStan should not emit a warning here

@ondrejmirtes
Copy link
Member

Hi, thanks, although this is too similar to #1157 where there's already some discussion.
To avoid your problem, modify your code like this: https://phpstan.org/r/67f303bca9a6a950efdc76454b366e79

@lock lock bot locked as resolved and limited conversation to collaborators Dec 20, 2019
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