Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96687 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67714 invoked from network); 1 Nov 2016 02:13:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Nov 2016 02:13:16 -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:60337] helo=li341-40.members.linode.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/F4-25911-B3AF7185 for ; Mon, 31 Oct 2016 21:13:15 -0500 Received: from localhost (admin.local [127.0.0.1]) by li341-40.members.linode.com (Postfix) with ESMTP id 48DAF25253 for ; Mon, 31 Oct 2016 22:13:12 -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 CMtVd2U0u2EK for ; Mon, 31 Oct 2016 22:13:11 -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 D754525252 for ; Mon, 31 Oct 2016 22:13:11 -0400 (EDT) To: internals@lists.php.net References: <44244cfd-c8ad-e0a9-4e70-380a8a8c940c@syberisle.net> Message-ID: <8d341888-d565-f857-8ec8-dcd24759ffe8@syberisle.net> Date: Mon, 31 Oct 2016 21:13:11 -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: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Re: Allow Iterator to be used with current, next, reset, key functions From: dlundgren@syberisle.net (David Lundgren) On 10/31/16 9:02 AM, Andrea Faulds wrote: > > 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. > I hadn't thought about that particular use case. I also hadn't ever tried using these functions on non-arrays before I recently attempted using them with an Iterator. > What would be the proposed alternative in that case? Reflection? I would think that Reflection would be necessary to get the private/protected properties, but these functions currently allow iteration over private/protected properties of an object. This should be limited to public properties similar to the way foreach is limited. But that's another issue. > 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. As a user it came as a surprise that I couldn't use an Iterator where an array was being used, as they are used interchangeable in some other contexts. I'll also admit that I don't normally read the docs until I have problems. The behavior with passing objects to those functions is only documented by a user comment. Dave -- David Lundgren dlundgren@syberisle.net GPG: 0x26F54D7F