Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77522 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85326 invoked from network); 23 Sep 2014 10:41:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Sep 2014 10:41:33 -0000 Authentication-Results: pb1.pair.com header.from=mike.php.net@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mike.php.net@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.181 as permitted sender) X-PHP-List-Original-Sender: mike.php.net@gmail.com X-Host-Fingerprint: 209.85.212.181 mail-wi0-f181.google.com Received: from [209.85.212.181] ([209.85.212.181:36326] helo=mail-wi0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/0D-09206-C5E41245 for ; Tue, 23 Sep 2014 06:41:33 -0400 Received: by mail-wi0-f181.google.com with SMTP id z2so4745921wiv.2 for ; Tue, 23 Sep 2014 03:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=jhqpdyEsyjmtY2fgIQhbhb8qus1XgoKEKkvlgoPXZ+0=; b=Qtp6S6Y91XohInCkNUaD6gvveQ+FGyvFx/MrhVMSqqab+XrFP8+41spBt9qbYJyaKp 84vKA86Ea2eY6XnvyJtceF3MBq0i/uIi+eV6IeB6H8t7AjGK1lXzGQY067FzWbe8afrl AmLKKxjyLkCyjuW/5Vy9Q3kk6Wn/dGY0rSb92UeNBAQfsPGGlUglnT9L87WlA7hoTi4B krQjl4wt/YAL3Ynwy6J+xaI1K04ScTfgq+sAgZ9jY5P2/unFM1ur0nDXB1rqT+wum48U +ZOqxMCHoBQoyo2q2VuftYorg24ue0skEjq2rX6323MObn1t4emDf6aJKImWu1OhxPLR PBWw== X-Received: by 10.181.27.132 with SMTP id jg4mr2398611wid.28.1411468889783; Tue, 23 Sep 2014 03:41:29 -0700 (PDT) Received: from [192.168.4.120] (178-18-170-101.customer.bnet.at. [178.18.170.101]) by mx.google.com with ESMTPSA id et1sm15443545wjd.11.2014.09.23.03.41.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Sep 2014 03:41:28 -0700 (PDT) Sender: Michael Wallner Message-ID: <54214E57.3080200@php.net> Date: Tue, 23 Sep 2014 12:41:27 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: Leigh CC: Nicolai Scheer , PHP Internals References: <54213481.8080700@php.net> <54213ECC.5080204@php.net> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Invokation on __toString() for object used as array key From: mike@php.net (Michael Wallner) On 2014-09-23 11:45, Leigh wrote: > On 23 September 2014 10:35, Michael Wallner wrote: >> On 2014-09-23 11:15, Leigh wrote: >>> He doesn't want to add the object as a key, he wants to invoke __toString(). >> >> Did I write that? > > No, you didn't, sorry. > > I just didn't see how an object with an explicit method to convert it > to a string compared to using a resource straight up as a key. If you > were implying the resource would be cast to int, then I get the > comparison. > > Does it really make bugs that hard to find? You'd expect the user to > know when they're using this behaviour when they write the code... > well, I would. > > I suppose explicit casting removes any ambiguity, we use > $a[(int)$resource] all the time for arrays of sockets and that's > served us fine over the years. Hmm, thinking about it > $a[(string)$object] is a lot clearer than having some magic sort it > out. You're right, I'll retreat now :) > I'm a "victim" of $array[(int) $resource] myself. I just tried to explain that the behavior is intentional and not an oversight. That doesn't mean that is set in stone for all times. -- Regards, Mike