4 ms·
> When you document how something behaves in any particular case programmers are going to use it, especially in a case like this where the behavior is actually
by hakre 5y ago
> When you document how something behaves in any particular case programmers are going to use it, especially in a case like this where the behavior is actually useful.
This is true and also the reason of the extraordinary warning and the years-long phase-out.
The old count is not really a sharp-shooter, however once we got accustomed to it, we all have our habits.
I only once needed it, IIRC:
function good_old_count(mixed $mixed): int
{
return (is_array($mixed) || ($mixed instanceof Countable))
? count($mixed)
: ( (int) ( null !== $mixed ) )
;
}