public function empty($subject) : bool
    {
        if (!$subject) {
            // Stringed zero - '0' - is not empty.
            return $subject !== '0';
        }
        if (is_object($subject)) {
            if ($subject instanceof \Countable) {
                return !count($subject);
            }
            if ($subject instanceof \Traversable) {
                // No need to check/use ArrayObject|ArrayIterator, because
                // those are both Countable (checked before this check).

                // Have to iterate; horrible.
                foreach ($subject as $ignore) {
                    return false;
                }
                return true;
            }
            if ($subject instanceof \ArrayAccess) {
                return false;
            }
            return !get_object_vars($subject);
        }
        return false;
    }
public function empty($subject) : bool
    {
        if (!$subject) {
            // Stringed zero - '0' - is not empty.
            return $subject !== '0';
        }
        if (is_object($subject)) {
            if ($subject instanceof \Countable) {
                return !count($subject);
            }
            if ($subject instanceof \Traversable) {
                // No need to check/use ArrayObject|ArrayIterator, because
                // those are both Countable (checked before this check).

                // Have to iterate; horrible.
                foreach ($subject as $ignore) {
                    return false;
                }
                return true;
            }
            if ($subject instanceof \ArrayAccess) {
                return false;
            }
            return !get_object_vars($subject);
        }
        return false;
    }
public function empty ( $ subject ) : bool { if ( ! $ subject ) { // Stringed zero - '0' - is not empty. return $ subject !== '0' ; } if ( is_object ( $ subject ) ) { if ( $ subject instanceof \ Countable ) { return ! count ( $ subject ) ; } if ( $ subject instanceof \ Traversable ) { // No need to check/use ArrayObject|ArrayIterator, because // those are both Countable (checked before this check). // Have to iterate; horrible. foreach ( $ subject as $ ignore ) { return false ; } return true ; } if ( $ subject instanceof \ ArrayAccess ) { return false ; } return ! get_object_vars ( $ subject ) ; } return false ; }
Subject is null, falsy or array|object is empty.

NB: Stringed zero - '0' - is _not_ empty.

ArrayAccess that is neither Countable nor Traversable fails validation,
because no means of accessing it's content.

@param mixed $subject

@return bool
Subject is null falsy or array|object is empty .