On Fri, Jun 17, 2022, at 10:20 AM, Tim Düsterhus wrote:
> Hi Internals
>
> I've come across a case where it would've been useful if 
> `iterator_to_array()` would accept iterable instead of Traversable to 
> avoid checking whether the input variable already is an array.
>
> To not repeat what I've already written in my proposed PR, please see:
>
>    https://github.com/php/php-src/pull/8819
>
> for more details.
>
> In response to my question whether this would require an RFC or whether 
> this is simple enough, cmb pointed to a previous RFC that proposed 
> *adding* a new function `iterable_to_array()` which was declined:
>
>    https://wiki.php.net/rfc/iterable_to_array-and-iterable_count
>
> cmb also suggested that for this reason this topic should at least be 
> shortly discussed on the list, which I intend to do with this email:
>
> - Do you believe that my PR requires an RFC / do you want to see an RFC 
> for this?
> - Would you object to extending 'iterator_to_array' from Traversable to 
> iterable (i.e. to Traversable|array)?

I support this; my only wrinkle would be that it's still a long name compared 
to what many languages have for this functionality, but I suppose that ship has 
long since sailed. :-)

Since it's a strictly type-widening change with no BC implications I can think 
of, I am impartial on RFC or not.  If it's going to get an RFC, though, that 
needs to be posted, like, immediately if it's going to get into 8.2.

--Larry Garfield

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to