Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96726 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67458 invoked from network); 3 Nov 2016 16:44:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Nov 2016 16:44:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=dlundgren@syberisle.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dlundgren@syberisle.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain syberisle.net designates 96.126.116.40 as permitted sender) X-PHP-List-Original-Sender: dlundgren@syberisle.net X-Host-Fingerprint: 96.126.116.40 mail.syberisle.net Received: from [96.126.116.40] ([96.126.116.40:37435] helo=li341-40.members.linode.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/9E-34238-5696B185 for ; Thu, 03 Nov 2016 11:44:21 -0500 Received: from localhost (admin.local [127.0.0.1]) by li341-40.members.linode.com (Postfix) with ESMTP id AE5F425253 for ; Thu, 3 Nov 2016 12:44:18 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at syberisle.net Received: from li341-40.members.linode.com ([127.0.0.1]) by localhost (syberisle.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DsyP_7-M3Ixl for ; Thu, 3 Nov 2016 12:44:18 -0400 (EDT) Received: from oo-laptop.local (cpe-65-29-233-211.wi.res.rr.com [65.29.233.211]) (Authenticated sender: dlundgren@syberisle.net) by li341-40.members.linode.com (Postfix) with ESMTPSA id 0A92225252 for ; Thu, 3 Nov 2016 12:44:17 -0400 (EDT) To: internals@lists.php.net References: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> Message-ID: Date: Thu, 3 Nov 2016 11:44:17 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Allow Iterator to be used with current, next, reset, key functions From: dlundgren@syberisle.net (David Lundgren) Thank you everyone for your feedback. Nikita's post about wrapping the array with an ArrayIterator provides the best approach to allow an array or Traversable to be used. This will also provide the greatest backwards compatible usage for those of us writing user code that would need to be compatible with 5.6 and 7.x. I think it would be bad to remove these functions and force users to wrap arrays with ArrayIterator, just to manually iterate an array. After spending a little time looking through how these functions are being used in frameworks and libraries, removing them seems like it will cause more harm than good, even in a future version of the language. Toward Andrea's suggestion of replacing the IAP in these functions, I'll take a look and see what I can come up with. Considering the current usage of these functions, I don't think this will generate a lot of overhead. Again, thanks for the feedback! Dave On 10/26/16 8:42 AM, David Lundgren wrote: > Greetings, > > As suggested by several reviewers of a PR[1] I recently submitted, I'd > like to get feedback on letting custom Iterators be used in the current, > next, reset, and key functions. If this is something to move forward > with, I'll need some help with the RFC process. > > Recent experiences trying to use these functions with a custom Iterator, > and a bug[2], led me to try and fix this. BC will occur when an object > implementing Iterator is passed to one of the functions, as the > interface methods will be called, instead of returning the objects > properties. The old behavior should be maintained for classes that do > not implement Iterator. > > [1] https://github.com/php/php-src/pull/2176 > [2] https://bugs.php.net/bug.php?id=49369 > > Thanks, > Dave > -- David Lundgren dlundgren@syberisle.net GPG: 0x26F54D7F