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 false" #6443

Closed
gilbertsoft opened this issue Jan 22, 2022 · 8 comments
Labels
Milestone

Comments

@gilbertsoft
Copy link

Bug report

Looks PHPStan is reporting a false positive "Call to function is_array() with mixed will always evaluate to false" in some circumstances.

Code snippet that reproduces the problem

https://phpstan.org/r/f4b7baf4-e5ac-4cb5-9f46-5dabb7296eb7

Expected output

No error.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Feb 1, 2022
@brainfoolong
Copy link

Hi. Here another one. Since 1.4.8 our tests fail with same code. 1.4.6 works fine.

https://phpstan.org/r/40c172a9-8989-439b-aaa3-3e1aa6d524de

@wolffc
Copy link

wolffc commented Mar 31, 2022

i stumbled on this issue as well and created an minimal testcase
https://phpstan.org/r/e443e996-53ea-4ce5-beef-ec5502b7e6f6

@stingray-11
Copy link

stingray-11 commented Apr 1, 2022

I'm getting a very similar error. The message itself looks like what it's saying can't be correct. The problem might be more general than just is_array(). Call to function is_string() with string|false will always evaluate to false.

@ondrejmirtes
Copy link
Member

@lightray22 Please attach a phpstan.org/try example.

@stingray-11
Copy link

stingray-11 commented Apr 2, 2022

Here is an example showing both the is_array and is_string errors together.

https://phpstan.org/r/12877267-faa1-4cbc-a025-3ca641b6f53a

@phpstan-bot
Copy link
Contributor

@gilbertsoft After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet:

@@ @@
-47: Call to function is_array() with mixed will always evaluate to false.
+38: Cannot access offset 'gilbertsoft/typo3…' on mixed.
+40: Cannot access offset 'gilbertsoft/typo3…' on mixed.
+46: Cannot access offset 'changes' on mixed.
+47: Call to function is_array() with mixed will always evaluate to false.
+47: Cannot access offset 'applied-changes' on mixed.
+54: Cannot access offset 'preferred-install…' on mixed.
Full report
Line Error
38 Cannot access offset 'gilbertsoft/typo3…' on mixed.
40 Cannot access offset 'gilbertsoft/typo3…' on mixed.
46 Cannot access offset 'changes' on mixed.
47 Call to function is_array() with mixed will always evaluate to false.
47 Cannot access offset 'applied-changes' on mixed.
54 Cannot access offset 'preferred-install…' on mixed.

@phpstan-bot
Copy link
Contributor

@brainfoolong After the latest push in 1.8.x, PHPStan now reports different result with your code snippet:

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

@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 Aug 13, 2022
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