Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65697 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51928 invoked from network); 6 Feb 2013 16:47:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Feb 2013 16:47:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:37820] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/11-45907-A1982115 for ; Wed, 06 Feb 2013 11:47:23 -0500 Received: by mail-vc0-f171.google.com with SMTP id p1so993567vcq.30 for ; Wed, 06 Feb 2013 08:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=iqlCOlIP0Ys5RW/WFpWMzyjW7P0FvazgB8VRgU5NTDk=; b=kUQM0vT7kPSu03VkawpB+powv99IZ7QQBZNorrick6Zavv/LDF4cISTc5NJD3cSbih XB2XCm9NAjMn+cfEtfnBUuowljNe2OIDV1nwLHsvV9Z1j7vixrVZeHF0kZmBVRrCG00+ DDh2xPhTlTBeqDiUBx+EvDmglOsaavn5aMEocRnzS+SfbjE+qQaSbIpP+X9+rY3JFOe0 8xZi/xOZpdGBJvRHDpjAYBOZR213mjhGHUCodFlSjBPvzuw3uEGrOSZxHgEwkQNhagFz 0PGp7fa3si6ykmhiqRiq6CO+7eMjhTMS9P6vTlmu0IUpbClp6TPFj8lwXzPJy9meQpjg YnkQ== MIME-Version: 1.0 X-Received: by 10.58.6.177 with SMTP id c17mr29628994vea.60.1360169235854; Wed, 06 Feb 2013 08:47:15 -0800 (PST) Received: by 10.58.56.137 with HTTP; Wed, 6 Feb 2013 08:47:15 -0800 (PST) In-Reply-To: References: Date: Wed, 6 Feb 2013 11:47:15 -0500 Message-ID: To: Etienne Kneuss Cc: Mike Willbanks , PHP Internals Content-Type: multipart/alternative; boundary=047d7b67824823355204d5111428 Subject: Re: [PHP-DEV] ArrayAccess/ArrayObject return by reference From: ircmaxell@gmail.com (Anthony Ferrara) --047d7b67824823355204d5111428 Content-Type: text/plain; charset=ISO-8859-1 Perhaps there's another way out of this. A simple way would be to introduce an ArrayAccessReference interface in core that adds the references to the getters/setters... It's perhaps not the cleanest, but it solves the BC issues... Anthony On Wed, Feb 6, 2013 at 11:42 AM, Etienne Kneuss wrote: > I assume it would be possible technically but might break (at least by > issuing E_STRICT) a lot of code if we forced ArrayObject::offsetGet to > return a reference. > > Think of all the subclasses that extend ArrayObject who currently do not do > that? > > Other than that, returning a ref where it previously didn't can have all > kinds of undesirable and hard-to-track consequences. > > Best, > > > On Wed, Feb 6, 2013 at 4:27 PM, Mike Willbanks wrote: > > > Looking at: http://lxr.php.net/xref/PHP_5_5/Zend/zend_interfaces.c#538it > > seems that ArrayAccess at the moment can not be returned by a reference. > > I'm wondering if there was a technical reason behind this or if it is > now > > a BC reason? > > > > Anyhow; I was attempting to dig through the source code a bit more last > > night to see why ArrayObject could not overload the function declaration > of > > offsetGet to force a return by reference aka: function > &offsetGet($key)... > > which works now for ArrayAccess but not for ArrayObject. I believe it > has > > to deal with ArrayObject inheriting ArrayAccess? Is there a way to allow > > ArrayObject to change the function declaration in this way? My PHP > > internals skills are not the best which is the reason for the question. > > > > Anyhow; justification wise: in userland this leads to a lot of wtf > factor. > > It really comes down to having to provide our own implementation of > > ArrayObject by extending several different areas including ArrayAccess so > > that references can be returned so multi-dimensional arrays can be > properly > > unset aka: > > $ar = new ArrayObject(array('foo' => array('bar' => array('baz' => > > 'foo')))); > > unset($ar['foo']['bar']['baz']); > > > > Regards, > > > > Mike > > > > > > -- > Etienne Kneuss > http://www.colder.ch > --047d7b67824823355204d5111428--