Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117987 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55737 invoked from network); 17 Jun 2022 15:33:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jun 2022 15:33:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 122A8180087 for ; Fri, 17 Jun 2022 10:21:21 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 17 Jun 2022 10:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1655486479; bh=+hN6sYWAJZ4U+ZThtjG4SM9PwNCaJi+1bbsFB3pgxW8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=iBbbGoGM3dddKJ18B+UtZukErbrcza7rituzUbfRxcj8f3VJre+E4dULURCXYyyjt B6WgXkBqZfe3qDVdwm2OvjlmrzatU2FaUkg91FwcWuIfYf9QJx5IpP+lyBdW2181LJ EzzOQyTuumj0/IxI0kwOopFOiWzDHkT+tbMiZ1+s40W/CtSuYJNzn+e29UzqKJ4VtP YpnACHvFn1J5OWvS2E7aFHrM/5v8ftWbUAwuMwbfKY4Fj7+7+cpiIcKD7bOEwG+4p+ 7V8YJNGvD2UN4eMJV4QtoRVThIaolHFS4bVvH1TR7d+6kwOZq7aS0XTZ1ViqNWtqbr locU2wPeRscKA== Message-ID: <4af09139-7db0-e701-69e0-de527afcfc6c@bastelstu.be> Date: Fri, 17 Jun 2022 19:21:18 +0200 MIME-Version: 1.0 Content-Language: en-US To: Guilliam Xavier Cc: PHP internals References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Make iterator_to_array() accept all iterables From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi On 6/17/22 18:06, Guilliam Xavier wrote: >> https://github.com/php/php-src/pull/8819 > > Just so that it can't be said that it hasn't been asked: what about > iterator_count(), and iterator_apply()? 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. - `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