-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Warn on implicit bool to int conversion when using as array offset #10466
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
Comments
|
https://3v4l.org/1c57W no warning even on master |
the mistake is to fix that behavior since it will have to generate Type error on php 9 ex. echo false; rather sanitize and filter your inputs since $arr[null] = 'empty'; is the index with empty and valid string. |
This RFC has not been voted nor implemented. Frankly, the bool to int conversion here is at least logical as it is standard behaviour and follow the type juggling semantics of the function context. The bigger issue is the implicit null to string conversion, which creates an empty string. I've got those type juggling things in my rather, but this doesn't deserve its own issue IMHO. |
A warning for anything but
Here's a quick PoC. master...iluuu1994:php-src:array-offset-coercion-warning |
Might want to tie it in with #7173 as that also tackles the same part to a degree |
There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests. |
This issue is not stale. https://wiki.php.net/rfc/deprecate-boolean-string-coercion should be voted soon. |
@mvorisek We are not planning on voting on this RFC. |
There has not been any recent activity in this feature request. It will automatically be closed in 14 days if no further action is taken. Please see https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea to understand why we auto-close stale feature requests. |
Description
https://3v4l.org/TrG4u
using
bool
as array offset can be a mistake, also(string) false
=''
The text was updated successfully, but these errors were encountered: