1.2.310. 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.
<?php
// count() shall not be below 0, so === is preferable here
if (count($array) <= 0) { }
?>
1.2.310.1. Specs¶
Short name |
Structures/CountIsNotNegative |
Rulesets |
|
Exakat since |
2.6.6 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |