1.2.30. Always Positive Comparison¶
When comparing them to 0, the following expressions are always true and should be avoided.
<?php
$a = [1, 2, 3];
var_dump(count($a) >= 0);
var_dump(count($a) < 0);
?>
1.2.30.1. Suggestions¶
Compare count() to non-zero values
Use empty()
1.2.30.2. Specs¶
Short name |
Structures/NeverNegative |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
Examples |
|
Available in |