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

optional return throw Cannot call method getId() on Bar|null #1196

Closed
jdeniau opened this issue Jul 10, 2018 · 1 comment
Closed

optional return throw Cannot call method getId() on Bar|null #1196

jdeniau opened this issue Jul 10, 2018 · 1 comment

Comments

@jdeniau
Copy link

jdeniau commented Jul 10, 2018

Summary of a problem or a feature request

optional return in function call report an wrong error

Code snippet that reproduces the problem

https://phpstan.org/r/1f7d9120dfb1ba424c1c00e2de646e24

Expected output

as getBar() return an object|null, the if return true only if getBar return an object, thus, we can call getId() on it.

testing explicitly strict equality with null works fine as showned here

@ondrejmirtes
Copy link
Member

Hi, duplicate of #1157.

@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