1.2.405. Empty Array Detection

Empty arrays may be detected with different solutions.

This analysis includes comparison to 0 with count, with ==, ===, != and !==, and comparison to empty arrays. Constants are not handled.

<?php

// comparison to empty array
$array === [];

// comparison of count()
count($array) === 0;

?>

1.2.405.1. Specs

Short name

Structures/ArrayCountTripleEqual

Rulesets

All, Preferences

Exakat since

2.4.7

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Available in

Entreprise Edition, Exakat Cloud