Req #78274 [Opn]: iterator_to_array($array) should return the $array
| From: | cmb@php.net | Date: | Thu, 11 Jul 2019 12:09:44 +0000 |
| Subject: | Req #78274 [Opn]: iterator_to_array($array) should return the $array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-221706@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78274&edit=1
ID: 78274
Updated by: cmb@php.net
Reported by: Wes dot nospam at example dot org
Summary: iterator_to_array($array) should return the $array
Status: Open
Type: Feature/Change Request
Package: *General Issues
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
FWIW, there has been an RFC proposing iterable_to_array()[1],
which has been declined.
[1] <https://wiki.php.net/rfc/iterable_to_array-and-iterable_count>
Previous Comments:
------------------------------------------------------------------------
[2019-07-11 07:32:24] daverandom@php.net
Worth noting that the function is named *iterator*_to_array(), not *iterable*_to_array().
I'm not necessarily against extending the functionality like this, but in that case for
consistency I would rather rename this function iterable_to_array() and retain iterator_to_array()
as an alias.
------------------------------------------------------------------------
[2019-07-11 06:51:13] Wes dot nospam at example dot org
Description:
------------
Argument 1 passed to iterator_to_array() must implement interface Traversable, array given.
Would be great to improve the behavior, possibly as follows:
iterator_to_array($array, TRUE); must return the array as is,
iterator_to_array($array, FALSE); must return array_values($array)
Thank you in advance
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78274&edit=1