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

Call to function in_array() with arguments 'integer', array('integer'|'string') and true will always evaluate to true. #4129

Closed
leo108 opened this issue Nov 26, 2020 · 4 comments
Labels
Milestone

Comments

@leo108
Copy link

leo108 commented Nov 26, 2020

Bug report

Please check the code snippet for the detail

Code snippet that reproduces the problem

https://phpstan.org/r/2469d3b4-efd8-4ca3-9d2f-b094ad5159e1

Expected output

Should not have any error.

@leo108
Copy link
Author

leo108 commented Nov 26, 2020

After some research, I think the issue is here https://github.com/phpstan/phpstan-src/blob/0.12.57/src/Rules/Comparison/ImpossibleCheckTypeHelper.php#L191,

The result type is an UnionType of 'integer'|'string', the $argumentType is a ConstantStringType 'integer', I think the isSuperTypeOf() should return maybe instead of yes

@leo108
Copy link
Author

leo108 commented Nov 26, 2020

A proposed fix is here leo108/phpstan-src@d07936a, but it breaks many other tests.

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Nov 26, 2020
@ondrejmirtes
Copy link
Member

Looks like the same problem as: #3892

@github-actions
Copy link

github-actions bot commented May 4, 2021

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 4, 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

2 participants