Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94347 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6203 invoked from network); 30 Jun 2016 22:50:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jun 2016 22:50:40 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.177 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.220.177 mail-qk0-f177.google.com Received: from [209.85.220.177] ([209.85.220.177:33459] helo=mail-qk0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 37/A8-14264-F32A5775 for ; Thu, 30 Jun 2016 18:50:40 -0400 Received: by mail-qk0-f177.google.com with SMTP id o76so60134974qke.0 for ; Thu, 30 Jun 2016 15:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oMr/1EMsIdNWnTSciptVLI/swqQx21eOVk1Kuk6HJkU=; b=xct1S1YrTy2Va6c1lOPMPDKaTdbvKq6M56yxsw2tucjn+NZhPHOBPlbVvvUOwGRGNC 8R+G2qGXT7/wzSDRgmBTnjWID6TkBX8KEkjjywuxQ0ndEmx338VQfQbry0WX6mdw7HKa xcKKFzUqPTGJuzH45aCdeBI5FmZyvgT6o/ZIcHvP8WlAHJYV/bQYul9MILuU0priK9b+ SjxeKZuAvOTh3Qg0jsyWgrMO88PTYifgT1eWWE2MWYgIru7f3WSbX5oGNsBMUvqxC2+b fOJChxlBKneqzw3Qg/iL32irM6avdKKhoLbskOF0VAhIcQmbXBD1BArsbIKpmfRwS7XQ zs2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oMr/1EMsIdNWnTSciptVLI/swqQx21eOVk1Kuk6HJkU=; b=MscU1+kp0OirI7Q8BhWcQZWo1HCFoJux5qvow0xs4tU7CIQzaxpmU5wEjXbBRrUR3q dkH50BHqByL0kYPjyA5k8Ofntrlb8NkGmAnDThW+OO1DdajwbC4RI47/BTN/YDl+5U9v KqVaU3FVapfw1QKsJ0gmrdqIuw975MpJM9q+6f8znZIosEAUdAE9SoQhlKA0YcHO27PO iLQxPRtn9tNqRkXgv6fs3tEIWXJVREbHbHVjwWboZzdAQL1JrVeeD2BHPpNww4QPCA0w RogijgoW8qHJOUhxgw8AI1f4fUk/Qwx6mtLcd6Fv7OLTpP1xCI6wA18E8SR3Lmx/LQEw NtCg== X-Gm-Message-State: ALyK8tKX3HBrNjrgU2US4hVwXFHTjJO6YRZcjfgPjE6zLEVKE8tppWdpTdbzcvlnhxDJy6RU4xGQ5VH21TleLQ== X-Received: by 10.37.20.7 with SMTP id 7mr5901888ybu.45.1467327037082; Thu, 30 Jun 2016 15:50:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.13.219.203 with HTTP; Thu, 30 Jun 2016 15:50:36 -0700 (PDT) In-Reply-To: References: <8284FE1F-70EE-4DB6-A945-0C57A4C99DCC@trowski.com> <16ef864f-8378-1af3-ddfb-21dc583a4b4a@gmx.de> <35132CB5-6E11-477F-8AC6-4374A7434D43@trowski.com> Date: Fri, 1 Jul 2016 00:50:36 +0200 Message-ID: To: Jeremy Mikola Cc: Aaron Piotrowski , PHP Internals Content-Type: multipart/alternative; boundary=001a113d3852d091f5053686b252 Subject: Re: [PHP-DEV] [RFC] Iterable From: nikita.ppv@gmail.com (Nikita Popov) --001a113d3852d091f5053686b252 Content-Type: text/plain; charset=UTF-8 On Thu, Jun 30, 2016 at 10:01 PM, Jeremy Mikola wrote: > On Sat, Jun 18, 2016 at 11:34 AM, Aaron Piotrowski > wrote: > > > > > I plan on bringing the iterable RFC (https://wiki.php.net/rfc/iterable) > > to a vote in about a week, does anyone have any further feedback on this > > proposal? > > > > Was there any discussion about a special allowance being made for stdClass? > > I've noted the is_iterable(new stdClass) example and ensuing "Object > Iteration" section: > > PHP allows any object to be used with foreach. However, iterable does not > > accept any object, only those implementing Traversable. Values accepted > > by iterable should be designed for iteration, not any set of values (such > > as the public properties of an object or a string). > > > > I'm on the fence if that second sentence applies to stdClass. Based on how > users typically end up with stdClass instances (e.g. casting arrays to an > object, json_decode()), I tend to think of them as logically equivalent to > associative arrays. To that end, I'd consider stdClass to be as "designed > for iteration" as any associative array -- if we can even say a stdClass > was designed at all :) > > As-is, the RFC requires users to either cast stdClass instances to an array > or decorate them with an Iterator (e.g. ArrayObject). I find this a bit > irksome, but it's certainly easy to work around. > > That said, I realize that voting is in progress and it's not my intention > to interrupt anything. I just wanted to relay a viewpoint that might not > have come up. > > -- > jeremy mikola > Instead of adding a special case to iterable, we could also make stdClass implement Traversable. (If we agree that stdClass is explicitly intended for iteration -- not so sure on that.) Nikita --001a113d3852d091f5053686b252--