rspec/rules/S1155/php/rule.adoc

18 lines
294 B
Plaintext
Raw Normal View History

2021-01-27 13:42:22 +01:00
Using ``++count()++`` to test for emptiness works, but using ``++empty()++`` makes the code more readable and can be more performant
2020-06-30 12:47:33 +02:00
== Noncompliant Code Example
----
if (count($a) > 0) { // Noncompliant
echo $a[0];
}
----
== Compliant Solution
----
if (!empty($a)) {
echo $a[0];
}
----