Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96673 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16907 invoked from network); 31 Oct 2016 14:02:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Oct 2016 14:02:26 -0000 X-Host-Fingerprint: 137.50.157.117 oa-edu-157-117.wireless.abdn.ac.uk Received: from [137.50.157.117] ([137.50.157.117:3826] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/0E-25911-1FE47185 for ; Mon, 31 Oct 2016 09:02:25 -0500 Message-ID: To: internals@lists.php.net References: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> Date: Mon, 31 Oct 2016 14:02:21 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 MIME-Version: 1.0 In-Reply-To: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 137.50.157.117 Subject: Re: Allow Iterator to be used with current, next, reset, key functions From: ajf@ajf.me (Andrea Faulds) Hi David, David Lundgren wrote: > 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. A concern that strikes me is that it's possible some existing code uses these functions precisely because they don't support Iterators, because the author wants to iterate over an object's properties. What would be the proposed alternative in that case? Reflection? I think it's unfortunate that PHP has two iteration behaviours for objects, namely iterating over properties, and custom iterators. I think those ought to be separate, rather than the latter overriding the former. Thanks! -- Andrea Faulds https://ajf.me/