Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65953 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62919 invoked from network); 19 Feb 2013 14:12:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Feb 2013 14:12:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.54 as permitted sender) X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.128.54 mail-qe0-f54.google.com Received: from [209.85.128.54] ([209.85.128.54:39486] helo=mail-qe0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 93/98-17768-85883215 for ; Tue, 19 Feb 2013 09:12:40 -0500 Received: by mail-qe0-f54.google.com with SMTP id 1so3055773qeb.13 for ; Tue, 19 Feb 2013 06:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=HLKm78I09+YV3zZd2L+npdTXzxPtYa36AqGrpooTEQk=; b=jcPq7AKP6sPFqnfLTD0NeeL33MTrL6ldif9RSYNrEHLksFhwRZWMJ8tQ5GZHRUImHv UCbLebgSQzrqhvXivzyWSNq+krUlSdwTAotZ8xyeSo5CfEXGCSEFy22nlpEOEc2TK14b gtyUF0IcO+AnbkdssSoP2mMjw2DYhAMxGUebhrkTaKqGBFU7EdoFRrX/YCq6sRujXwdz Y1HLMjamBJP3B5wbn4aYSD+wAMz+4h6ACg8F7sHzBpxAOqqqy2T6IhNjGwtnFzaGYFrV BitP/CYuPPz6RbRxTVJycyL51iG+disNYA6GvEDowtkpRwDh7++j6G4JKGBz5UCppYSp Y/Rw== X-Received: by 10.224.184.130 with SMTP id ck2mr7213790qab.41.1361283157754; Tue, 19 Feb 2013 06:12:37 -0800 (PST) MIME-Version: 1.0 Sender: ekneuss@gmail.com Received: by 10.49.133.42 with HTTP; Tue, 19 Feb 2013 06:12:16 -0800 (PST) In-Reply-To: References: Date: Tue, 19 Feb 2013 15:12:16 +0100 X-Google-Sender-Auth: wWGQG0lwGprJ5MgAYIP25G2kvZY Message-ID: To: Derick Rethans Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=20cf30334c5b0e836904d6146fc4 Subject: Re: [PHP-DEV] [RFC] Allow non-scalar keys in foreach From: colder@php.net (Etienne Kneuss) --20cf30334c5b0e836904d6146fc4 Content-Type: text/plain; charset=UTF-8 On Tue, Feb 19, 2013 at 2:55 PM, Derick Rethans wrote: > 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). > I think this RFC is orthogonal to iterator_to_array supporting conversions from objects to keys. $array[$obj] = 42; does not call __toString (or __toKey), it throws a catchable fatal. IMO it would be inconsistent if iterator_to_array gracefully accepted objects as keys. --20cf30334c5b0e836904d6146fc4--