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

PHPStan mistakenly assumes that an array can pass the is_numeric() test #3133

Closed
morozov opened this issue Mar 29, 2020 · 8 comments
Closed
Labels
Milestone

Comments

@morozov
Copy link
Contributor

morozov commented Mar 29, 2020

Bug report

According to the documentation, is_numeric() finds whether a variable is a number or a numeric string. Although, PHPStan thinks that a variable that passes the is-numeric test can contain an array.

Code snippet that reproduces the problem

https://phpstan.org/r/d65e6a61-95bd-44ac-8093-5afe354bf16c

Expected output

No error

@Jean85
Copy link
Contributor

Jean85 commented Apr 14, 2020

I got the same issue, I attempted a solution with phpstan/phpstan-src#177.

@szepeviktor
Copy link
Contributor

szepeviktor commented Aug 22, 2020

Another test https://phpstan.org/r/29c215da-f552-4d7e-b225-251f923d80bb

@ondrejmirtes Could you start me up how to fix is_numeric handling?

@ondrejmirtes
Copy link
Member

I also wrote some tips here: phpstan/phpstan-src#177 (comment)

@szepeviktor
Copy link
Contributor

@ossinkine Now that you are fluent in PHPStan :) Could you help me in fixing is_numeric handling?

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@7f04f75

@morozov
Copy link
Contributor Author

morozov commented Aug 24, 2020

The issue is also not reproducible on the code where it was originally discovered and suppressed (doctrine/dbal#3799).

Thanks, @ondrejmirtes!

@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 May 13, 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