-
Notifications
You must be signed in to change notification settings - Fork 15
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
Do not trigger for unused value in foreach loop with key used #65
Comments
That's an interesting idea. I could have the sniff ignore variables created that way, but in the mean time you can do this: Configure
|
I think it would be a good idea to make this a new configuration option. Maybe |
Thanks good idea. The small issue with $ignored is, that some time in x years, someone else will go through the code and will have no idea what the value of the array actually is in case he wants to use it now, so he first needs to debug it or I add additional superflous comments. |
That's a good point. I do think that this comes up often enough to at least be an option. Once we have that, we can consider if we want that option to be on by default. |
Sometimes I have to only use the keys of an array. Using an foreach loop is faster than first doing array_keys() and then looping.
However it will always report the $value as unused (bc it is unused).
If would be nice if it would NOT report the $value as unused if the $key is used:
(or if that is too complicated, maybe not at all if its a key => value foreach loop)
foreach ( $array as $key => $value ) {
The text was updated successfully, but these errors were encountered: