Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65695 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43418 invoked from network); 6 Feb 2013 15:27:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Feb 2013 15:27:17 -0000 Authentication-Results: pb1.pair.com header.from=pencap@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pencap@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.182 as permitted sender) X-PHP-List-Original-Sender: pencap@gmail.com X-Host-Fingerprint: 209.85.223.182 mail-ie0-f182.google.com Received: from [209.85.223.182] ([209.85.223.182:44844] helo=mail-ie0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/42-28994-45672115 for ; Wed, 06 Feb 2013 10:27:17 -0500 Received: by mail-ie0-f182.google.com with SMTP id k14so2063590iea.41 for ; Wed, 06 Feb 2013 07:27:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=LUD512JOwF7VSM19QLWZHQaBCak09rXz0uKQUUOGKa0=; b=hB/esn3qCw2lTJTQk61YPxLfWU+ypuieaPLYuNdtkGT8qyWl61KPh2owPfkyMQAI7H eonbp6KaoeLx9+AiPyD+g0jzDxIqbkc3/Znw/aCYvZS5TcvNsI2zkQl2Jl1k2VPmoIHD EZ8ftl1Sgw+4SINfj7H5f+LFMcIqHZ/UWn4z1VNKeD8GIF4LK2aTq85rXIfRtHcWgb1d hwtzCBUanryw6d2gpWfk2ncldjwFcgbFMN6Z+PhQMYGQNM+T4VBjS8ppV26gJu8TGte4 qxtU88zsqEXA2ialqL4l+RBs8qPhUwwOrbp9l19XuXqOnBl6lE0bB09kh+/S+FaeF/Cb W+yA== MIME-Version: 1.0 X-Received: by 10.50.222.195 with SMTP id qo3mr7049591igc.14.1360164434766; Wed, 06 Feb 2013 07:27:14 -0800 (PST) Received: by 10.50.40.38 with HTTP; Wed, 6 Feb 2013 07:27:14 -0800 (PST) Date: Wed, 6 Feb 2013 07:27:14 -0800 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary=14dae934088df86aa104d50ff51f Subject: ArrayAccess/ArrayObject return by reference From: pencap@gmail.com (Mike Willbanks) --14dae934088df86aa104d50ff51f Content-Type: text/plain; charset=UTF-8 Looking at: http://lxr.php.net/xref/PHP_5_5/Zend/zend_interfaces.c#538 it 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 --14dae934088df86aa104d50ff51f--