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 positive: if ($city ?? false) #560

Closed
lyrixx opened this issue Oct 25, 2017 · 8 comments
Closed

False positive: if ($city ?? false) #560

lyrixx opened this issue Oct 25, 2017 · 8 comments

Comments

@lyrixx
Copy link
Contributor

lyrixx commented Oct 25, 2017

Hello.

There is a false positive here:

if ($city ?? false) { ... }

=> var $citiy is undefined

Thanks.

@ondrejmirtes
Copy link
Member

Hi,
cannot reproduce this. Can you reproduce it on phpstan.org? Which version are you using?

@lookyman
Copy link
Contributor

@ondrejmirtes
Copy link
Member

Thanks, that makes sense but wasn't included in the OP. Should be easy to fix.

@ondrejmirtes ondrejmirtes added this to the 0.9 milestone Oct 25, 2017
@ondrejmirtes ondrejmirtes removed this from the 0.9 milestone Nov 27, 2017
@ondrejmirtes ondrejmirtes added this to the NodeScopeResolver bugs milestone Jan 12, 2019
@lyrixx
Copy link
Contributor Author

lyrixx commented Jan 30, 2020

I re-run the example, and the output is a bit different
https://phpstan.org/r/237c0227-c613-4804-95e9-2286ae5a8556

@phpstan-bot
Copy link
Contributor

@lyrixx PHPStan now reports different result with your code snippet:

@@ @@
-3: If condition is always false.
-4: Undefined variable: $city
+4: Variable $city might not be defined.
Full report
Line Error
4 Variable $city might not be defined.

@phpstan-bot
Copy link
Contributor

@lyrixx After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-3: If condition is always false.
-4: Undefined variable: $city
+No errors

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@c4cc668

@github-actions
Copy link

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 Apr 29, 2021
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

4 participants