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 "Call to function is_array() with mixed will always evaluate to true." #4999

Closed
tugmaks opened this issue May 13, 2021 · 9 comments
Labels
Milestone

Comments

@tugmaks
Copy link

tugmaks commented May 13, 2021

Bug report

After bumping phpstan/phpstan from 0.12.86 to 0.12.87

Code snippet that reproduces the problem

https://phpstan.org/r/f44414ae-c1bd-436f-898d-6270c5a39268

Expected output

no errors

@tugmaks tugmaks changed the title False positive False positive "Call to function is_array() with mixed will always evaluate to true." May 13, 2021
@limingxinleo
Copy link

#4995

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@187921e

@b-viguier
Copy link

Hi @ondrejmirtes 👋 😃
Thanks for this quick fix! Unfortunately, I still encounter the same message in 0.12.88 on a slightly different example:
https://phpstan.org/r/cea39a2f-9e36-4f01-87b6-2a135901ccac

Do you think it may be related? If not, I can open a distinct issue for more clarity.

@ondrejmirtes ondrejmirtes reopened this May 17, 2021
@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone May 17, 2021
@phpstan-bot
Copy link
Contributor

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

@@ @@
-13: Call to function is_array() with mixed will always evaluate to true.
+No errors

@phpstan-bot
Copy link
Contributor

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

@@ @@
-13: Call to function is_array() with mixed will always evaluate to true.
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
Full report
Line Error
-1 Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40Run PHPStan with --debug option and post the stack trace to:https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md

@phpstan-bot
Copy link
Contributor

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

@@ @@
-13: Call to function is_array() with mixed will always evaluate to true.
+19: Method HelloWorld::parsePhone() should return string|null but return statement is missing.
+19: Static method HelloWorld::parsePhone() is unused.
Full report
Line Error
19 `Method HelloWorld::parsePhone() should return string
19 Static method HelloWorld::parsePhone() is unused.

@tugmaks tugmaks closed this as completed Feb 2, 2022
@ondrejmirtes ondrejmirtes reopened this Feb 28, 2022
@staabm
Copy link
Contributor

staabm commented Dec 14, 2022

@ondrejmirtes this one seems fixed and regression test is already committed in https://github.com/phpstan/phpstan-src/blob/1.9.x/tests/PHPStan/Rules/Comparison/data/bug-4999.php

@ondrejmirtes
Copy link
Member

Thanks!

@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 Jan 15, 2023
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

6 participants