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 condition is always false." when using variable function #2191

Closed
phrounz opened this issue Jun 6, 2019 · 4 comments
Closed
Labels
Milestone

Comments

@phrounz
Copy link
Contributor

phrounz commented Jun 6, 2019

Version used: PHPStan 0.11.8

Offending code

More precisely, the following piece of code:

$rollback_tr = false;
$result = $function($rollback_tr); // $function takes an argument by reference
if ($rollback_tr) {

Expected output:
No errors

Output:
If condition is always false.

@phrounz phrounz changed the title False positive "If condition is always false." when using function variable False positive "If condition is always false." when using variable function Jun 6, 2019
@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jun 6, 2019
@phpstan-bot
Copy link
Contributor

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

@@ @@
-10: If condition is always false.
+10: If condition is always false.
+16: Function myFunction() has no return typehint specified.
+16: Function myFunction() has parameter $rollback_tr with no typehint specified.
Full report
Line Error
10 Function myFunction() has parameter $rollback_tr with no typehint specified.
16 Function myFunction() has parameter $rollback_tr with no typehint specified.
16 Function myFunction() has parameter $rollback_tr with no typehint specified.

@phpstan-bot
Copy link
Contributor

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

@@ @@
-10: If condition is always false.
+16: Function myFunction() has no return typehint specified.
+16: Function myFunction() has parameter $rollback_tr with no typehint specified.
Full report
Line Error
16 Function myFunction() has no return typehint specified.
16 Function myFunction() has parameter $rollback_tr with no typehint specified.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@109bf99

@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 Oct 14, 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

3 participants