In PHP 7.2, a Warning was added while trying to count uncountable things. After that, everyone was forced to search and change their code, to avoid it. Usually, the following piece of code became standard:

if ( is_array ( $foo ) || $foo instanceof Countable ) { // $foo is countable }

This condition, to check if a variable “is countable”, is also very common in methods that return the count of the elements: