In plain English: count() works on arrays and on objects that implement
Countable. Passing a string, number, boolean, or null is an error in PHP 8.
Why it matters: The code throws a TypeError instead of returning a length,
so the request or job can fail at runtime.
count('hello'); // TypeError
sizeof(42); // TypeError
count(null); // TypeError
count($items); // $items is an array
sizeof($collection); // $collection implements Countable
strlen($text); // use strlen() for strings
count() or sizeof() with a string literalcount() or sizeof() with an integer or float literalcount() or sizeof() with a boolean or null literalCountable.strlen() for strings.count() when the value is a scalar.Countable object when you need a count.E0051 has no configuration options and is enabled by default.