-
Notifications
You must be signed in to change notification settings - Fork 48
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
Warn about implicit cast to int when using bool values as array keys. #121
Comments
While Paslm is giving me the following output:
|
Hi, I disagree, PHPStan correctly knows what's going on, it's not a bug to do I'm moving this to phpstan-strict-rules where it'd make more sense, but it's not a good fit for the default PHPStan ruleset in the core. |
I agree it could be a good rule to add. Looking at @ondrejmirtes how do you see such feature ? Should it be a new Rule in the strict-rule repository or can it be an option in the phpstan config, which would be used in the rule
with
|
Feature request
When using bool values as array keys, then these keys are implicitly casted to integers. This will cause problems when a strict comparison
===
is applied on these keys.Example Code:
The expected output (if boolean is assumed a valid array key) when running the code is
but because of int cast, the output is
Therefore PHPStan should output the following error messages for the given code:
The text was updated successfully, but these errors were encountered: