Skip to content

Enable allowUnusedForeachVariables and allowUnusedCaughtExceptions #73

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

Merged
merged 5 commits into from
Feb 15, 2019

Conversation

sirbrillig
Copy link
Owner

@sirbrillig sirbrillig commented Feb 13, 2019

This changes the defaults for two options, allowUnusedForeachVariables and allowUnusedCaughtExceptions, from false to true.

The reason behind this change is similar to that behind #59; the situations that these options allow are very common. Specifically, due to PHP language idioms, these are common patterns:

foreach( $array as $key => $value ) {
  echo $value; // $key is unused, but this is much more efficient than running `array_values()` first
}
try {
  do_something_risky();
} catch ( \Exception $err ) {
  echo 'There was a problem'; // $err is unused, but the exception must be assigned
}

Fixes #72

@sirbrillig sirbrillig merged commit f72e025 into master Feb 15, 2019
@sirbrillig sirbrillig deleted the enable-more-defaults branch February 15, 2019 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant