Skip to content

Commit

Permalink
Don't use count() in a loop.
Browse files Browse the repository at this point in the history
Use do while so the count does not happen in a loop statement. This
makes the code linter happier.
  • Loading branch information
markstory committed Mar 23, 2014
1 parent 90ca41d commit 75fcc7c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Cake/TestSuite/CakeTestCase.php
Expand Up @@ -516,7 +516,8 @@ public function assertTags($string, $expected, $fullDebug = false) {
protected function _assertAttributes($assertions, $string) {
$asserts = $assertions['attrs'];
$explains = $assertions['explains'];
while (count($asserts) > 0) {
$len = count($asserts);
do {
$matches = false;
foreach ($asserts as $j => $assert) {
if (preg_match(sprintf('/^%s/s', $assert), $string, $match)) {
Expand All @@ -530,7 +531,8 @@ protected function _assertAttributes($assertions, $string) {
if ($matches === false) {
$this->assertTrue(false, 'Attribute did not match. Was expecting ' . $explains[$j]);
}
}
$len = count($asserts);
} while ($len > 0);
return $string;
}

Expand Down

0 comments on commit 75fcc7c

Please sign in to comment.