Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65951 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58988 invoked from network); 19 Feb 2013 13:55:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Feb 2013 13:55:32 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:34017] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/D7-17768-35483215 for ; Tue, 19 Feb 2013 08:55:32 -0500 Received: from localhost (xdebug.org [127.0.0.1]) by xdebug.org (Postfix) with ESMTPS id 5F283DE13D; Tue, 19 Feb 2013 13:55:27 +0000 (GMT) Date: Tue, 19 Feb 2013 13:55:27 +0000 (GMT) X-X-Sender: derick@whisky.home.derickrethans.nl To: Etienne Kneuss cc: Nikita Popov , PHP internals In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] [RFC] Allow non-scalar keys in foreach From: derick@php.net (Derick Rethans) Gah, no top posting! On Tue, 19 Feb 2013, Etienne Kneuss wrote: > On Tue, Feb 19, 2013 at 2:25 PM, Derick Rethans wrote: > > > On Tue, 19 Feb 2013, Nikita Popov wrote: > > > > > This RFC proposes to remove the type-restrictions on Iterator keys > > > used in foreach: > > > > > > https://wiki.php.net/rfc/foreach-non-scalar-keys > > > > > > I took over Levi's RFC and added a patch for it. > > > > Under "Open Questions" you write: > > > > > What should be done with the keys that are valid in the iterator, > > > but not in the array? I think the best approach would be to just > > > set the array keys with the exact same semantics as PHP would do > > > (i.e. with all casts and warnings). > > > > Would __toString be called in case the key was an object? > I think the warning can stay as-is, __toString is not necessarily > available so casting to string in all occasions is probably not what > we want. I think it should cast to a string if possible. You are now making iterator_to_array not work with the new feature, and I find that a bit silly. Whether it should be __toString (or __toKey) I don't really care, but this new support for objects should be supported everywhere (and that includes iterator_to_array). cheers, Derick