A Short Rant About Coding Conventions

Yesterday's article actually got me a little amped up about coding conventions  Comparing a while loop against a foreach loop of an array  because I never thought I would actually have to do a comparison between a while loop and a foreach loop on an array! If we go back and revisit the post, I was reviewing a recent CakePHP commit for an optimization on the Hash class. The code in question is three separate blocks of code that leverage the array_shift function to get the next value in the array with a foreach loop instead.I truly have no preference in any style, but what I do ask is that you at least pick one style yourself! Here is the original code in question:

while (($key = array_shift($parts)) !== null) { }

do { $token = array_shift($tokens); } while (!empty($tokens));

$ok = true; while ($ok) { if (empty($conditions)) { break; } $cond = array_shift($conditions); }