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

Considers variable as null when failing in_array #3013

Closed
eigan opened this issue Feb 21, 2020 · 4 comments · Fixed by phpstan/phpstan-src#2230
Closed

Considers variable as null when failing in_array #3013

eigan opened this issue Feb 21, 2020 · 4 comments · Fixed by phpstan/phpstan-src#2230
Labels
Milestone

Comments

@eigan
Copy link

eigan commented Feb 21, 2020

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/73c7b029-ffbf-4b15-b6fe-19a5f6ee43d5

Note that removing the last argument to is_array() will give the expected output.

Expected output

Should be no error.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Feb 21, 2020
@eigan
Copy link
Author

eigan commented Apr 24, 2020

Some more related cases: https://phpstan.org/r/58821a86-a033-4c9f-a36d-609a34bd9d3b

@phpstan-bot
Copy link
Contributor

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

@@ @@
+PHP 8.0 (2 errors)
+==========
+
+14: If condition is always false.
+14: Only booleans are allowed in an if condition, null given.
+
+PHP 7.1 – 7.4 (1 error)
+==========
+
 14: If condition is always false.
Full report

PHP 8.0 (2 errors)

Line Error
14 If condition is always false.
14 If condition is always false.

PHP 7.1 – 7.4 (1 error)

Line Error
14 Only booleans are allowed in an if condition, null given.

@VincentLanglet
Copy link
Contributor

Removing the === true solve the issue
https://phpstan.org/r/f67f8043-f085-43ef-9672-7529c7c9a7e2

I'll try to understand what this mean.

@github-actions
Copy link

github-actions bot commented May 7, 2023

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 May 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants