1.2.308. Count() Is Not Negative

This rule reports when the Countable method count is poised to return a negative value.

It also reports when a call to count() is compared to a value that might be negative.

<?phpVersion

// count() shall not be below 0, so === is preferable here
if (count($array) <= 0) { }

?>

1.2.308.1. Specs

Short name

Structures/CountIsNotNegative

Rulesets

All, Analyze, Changed Behavior

Exakat since

2.6.6

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Available in

Entreprise Edition, Exakat Cloud