The count of elements from an array or Countable object is always greater than or equal to zero. So testing that the count is greater than or equal
to zero doesn’t make sense, since the result is always true
. Similarly testing that it is less than zero will always return
false
. Perhaps the intent was to check the non-emptiness of the object or array instead.
Noncompliant Code Example
if (count($arr) >= 0) { ... }
if (count($arr) < 0) { ... }
$result = count($arr) >= 0;
if (0 > count($arr)) { ... }
Compliant Solution
if (count($arr) != 0) { ... }
if (count($arr) > 0) { ... }