On Mi, 2018-06-20 at 03:55 +0200, Michael Moravec wrote: > Hello internals, > > I'd like to propose two new functions for PHP 7.3: > iterable_to_array() and > iterable_count() > > These functions are supposed to work with iterables (7.1 pseudotype) > - both arrays and iterators, unlike iterator_*() functions which only > work with iterators. >
Is there any reason not to extend the existing functions to also allow arrays? Also for the count one: Mind that iterator_count()/iterable_count() doesn't respect the Countable interface and consumes the iterator, which might not be resetable. A slightly better choice might be (is_array($iterable) || implements_countable($iterable)) ? count($iterable) : iterator_count($iterable) And even then I would put a warning sign against blindly using it on any iterator. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php