public static function size($list)
    {
        if ($list === null)
            return 0;

        if (is_scalar($list) || is_resource($list))
            return 1;

        if (is_array($list) || $list instanceof \Countable)
            return count($list);

        if ($list instanceof \Traversable)
            return iterator_count($list);

        $count = 0;
        static::each($list, function() use (& $count) { $count++; });
        return $count;
    }
public static function size($list)
    {
        if ($list === null)
            return 0;

        if (is_scalar($list) || is_resource($list))
            return 1;

        if (is_array($list) || $list instanceof \Countable)
            return count($list);

        if ($list instanceof \Traversable)
            return iterator_count($list);

        $count = 0;
        static::each($list, function() use (& $count) { $count++; });
        return $count;
    }
public static function size ( $ list ) { if ( $ list === null ) return 0 ; if ( is_scalar ( $ list ) || is_resource ( $ list ) ) return 1 ; if ( is_array ( $ list ) || $ list instanceof \ Countable ) return count ( $ list ) ; if ( $ list instanceof \ Traversable ) return iterator_count ( $ list ) ; $ count = 0 ; static :: each ( $ list , function ( ) use ( & $ count ) { $ count ++ ; } ) ; return $ count ; }
Return the number of values in the list. This method will also accept scalars such as string, number and even
null or resources but will return 1 in that case.

@category Collection Functions

@param traversable $list the list of items

@return int
Return the number of values in the list . This method will also accept scalars such as string number and even null or resources but will return 1 in that case .