FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=19782&edit=1

ID: 19782
Updated by: gsherwood@squiz.net
Reported By: contato@bernardosilva.com dot br
-Summary: Invalid found size functions in loop
+Summary: Invalid found size functions in loop when using
object operator
Status: Open
Type: Bug
Package: PHP_CodeSniffer
Operating System: All
Package Version: 1.4.3
PHP Version: 5.3.6
-Assigned To:
+Assigned To: squiz
Roadmap Versions:
New Comment:

-Summary: Invalid found size functions in loop
+Summary: Invalid found size functions in loop when
using object operator
-Assigned To:
+Assigned To: squiz



Previous Comments:
------------------------------------------------------------------------

[2013-01-11 17:33:59] dioubernardo

Description:
------------
The use of the word "count" generates an error
Squiz.PHP.DisallowSizeFunctionsInLoops.Found

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

Test script:
---------------
<?php

$a = new stdClass();
$a->count = 5;

do {
echo $a->count;
$a->count--;
} while($a->count);

?>

------------------------------------------------------------------------

Search Discussions

  • Gsherwood at Jan 13, 2013 at 9:11 pm
    Edit report at https://pear.php.net/bugs/bug.php?id=19782&edit=1

    ID: 19782
    Updated by: gsherwood@squiz.net
    Reported By: contato@bernardosilva.com dot br
    Summary: Invalid found size functions in loop when using
    object operator
    -Status: Assigned
    +Status: Closed
    Type: Bug
    Package: PHP_CodeSniffer
    Operating System: All
    Package Version: 1.4.3
    PHP Version: 5.3.6
    Assigned To: squiz
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed
    Fix committed to github repo:
    https://github.com/squizlabs/PHP_CodeSniffer/commit/42a568db42cf6e85e49c7e8e97
    2e460b44f1f121


    Previous Comments:
    ------------------------------------------------------------------------

    [2013-01-13 21:10:05] squiz

    -Summary: Invalid found size functions in loop
    +Summary: Invalid found size functions in loop when
    using object operator
    -Assigned To:
    +Assigned To: squiz


    ------------------------------------------------------------------------

    [2013-01-11 17:33:59] dioubernardo

    Description:
    ------------
    The use of the word "count" generates an error
    Squiz.PHP.DisallowSizeFunctionsInLoops.Found

    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

    Test script:
    ---------------
    <?php

    $a = new stdClass();
    $a->count = 5;

    do {
    echo $a->count;
    $a->count--;
    } while($a->count);

    ?>

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedJan 13, '13 at 9:10p
activeJan 13, '13 at 9:11p
posts2
users1
websitepear.php.net

1 user in discussion

Gsherwood: 2 posts

People

Translate

site design / logo © 2022 Grokbase