Re: Make iterator_to_array() accept all iterables
| From: | Tim Düsterhus | Date: | Fri, 17 Jun 2022 17:21:18 +0000 |
| Subject: | Re: Make iterator_to_array() accept all iterables | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117987@lists.php.net to get a copy of this message | ||
Hi
On 6/17/22 18:06, Guilliam Xavier wrote:
I also came across those, while implementing the PR, but I intentionally did not touch them to keep the scope simple and because I think they are less likely to be used generally. -Just so that it can't be said that it hasn't been asked: what about iterator_count(), and iterator_apply()?https://github.com/php/php-src/pull/8819
iterator_apply() is easily replaced by a foreach loop, because the return value is pretty useless, so it is not likely that a nested function call is going to be used.
- For iterator_count() one could to count(iterator_to_array($foo)) if my proposal is merged. This come with a bit of overhead, but at least it's not as clunky as is_array($foo) ? $foo : iterator_to_array($foo)
If a RFC is desired, then I'd likely include all three of them with a vote for each, but I hope my proposal is simple enough to not require an RFC.
Best regards
Tim Düsterhus