aik099 / CodingStandard

The PHP_CodeSniffer coding standard I'm using on all of my projects
BSD 3-Clause "New" or "Revised" License
5 stars 2 forks source link

Report usage of "&" in foreach declaration as an error #80

Open aik099 opened 9 years ago

aik099 commented 9 years ago

Using & inside foreach declaration results in reference being kept after foreach is done interating and can lead to hard to catch errors.

foreach ($array as &$element) { ... }
foreach ($array as &$key => &$element) { ... }
foreach ($array as $key => &$element) { ... }
foreach ($array as &$key => $element) { ... }