Skip to content

The use of count() inside a loop condition is not allowed. #186

@matt-bernhardt

Description

@matt-bernhardt

The latest runs of PHPCS on Travis (including on #170) have returned this error message:

FILE: ...ordpress/src/wp-content/themes/MITlibraries-parent/functions.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 584 | ERROR | The use of count() inside a loop condition is not allowed;
     |       | assign the return value to a variable and use the variable in
     |       | the loop condition instead
     |       | (Squiz.PHP.DisallowSizeFunctionsInLoops.Found)
----------------------------------------------------------------------

The fix seems to be pretty easy, just move the count() function outside of the loop structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions