Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39565 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93718 invoked from network); 3 Aug 2008 11:08:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2008 11:08:01 -0000 Authentication-Results: pb1.pair.com header.from=rewbs.soal@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rewbs.soal@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 72.14.220.155 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rewbs.soal@gmail.com X-Host-Fingerprint: 72.14.220.155 fg-out-1718.google.com Received: from [72.14.220.155] ([72.14.220.155:23702] helo=fg-out-1718.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/F5-50899-F8195984 for ; Sun, 03 Aug 2008 07:08:00 -0400 Received: by fg-out-1718.google.com with SMTP id 16so1158774fgg.23 for ; Sun, 03 Aug 2008 04:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:mime-version:content-type:content-transfer-encoding :content-disposition:x-google-sender-auth; bh=wQvVelI1ctQugszJxHqoLWVkvt99+2vvGnz1TNTYLWs=; b=xbWhSYJscwG7hOJhbqCN5md2kw6F3jjb+jSfvRP/AFbr9r/PeIKpKqBbuwI1ddfpnF PH1Ee4Err9aTnZeGfBmE1GA9txP+MuYVD+JJQAY/9gDSvet2gniSC7uxyxfkajonaW4x KCMbalhiSNVLlf7Cw6+AlEhBCpfxL7i2dOmbU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition:x-google-sender-auth; b=XnOlV4ymUGlugBy4CVkvcYvWzHKVo+sNeHT3Yiw3B/wKXUPq8emIhXljrgySf/wqbt fa2vM86V7K81kG0KyFtIg4AQydnDO+sZUcCJwx/xxsmMVe7y3eDrge5Mmc70n+2sAtcq 9FipUS0myU+pSQWv0rGGfzvsB3pwr0NJXrluQ= Received: by 10.86.1.1 with SMTP id 1mr9314737fga.61.1217761676840; Sun, 03 Aug 2008 04:07:56 -0700 (PDT) Received: by 10.86.23.9 with HTTP; Sun, 3 Aug 2008 04:07:56 -0700 (PDT) Message-ID: <5a8807d10808030407j14f51cb6ga7d917d51c6206ac@mail.gmail.com> Date: Sun, 3 Aug 2008 12:07:56 +0100 Sender: rewbs.soal@gmail.com To: internals MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 910866740214e28b Subject: [PHP-DEV] Intended behavior of ArrayObject::exchangeArray() ? From: robinf@php.net ("Robin Fernandes") Hi all, I have two questions about the intended behaviour of ArrayObject::exchangeArray() : 1. What should happen when the argument is an object? The docs suggest that the arg should be an array, but the prototype in the code indicates objects are OK too. However, when an object is passed, the effect is simply to remove the ArrayObject's storage container, which doesn't seem right: http://pastebin.ca/1091256 2. Should the ArrayObject store a copy or a real reference to the array passed to exchangeArray()? Currently, the ArrayObject container effectively becomes a copy-on-write reference to the array passed to exchangeArray()... but there is no logic to split the container when it is modified. Consequently, the behaviour is very ambiguous: http://pastebin.ca/1091266 . Depending on the intended behaviour, it seems either exchangeArray() needs to take its arg as prefer-by-reference, or the arg needs to be split before being stashed in the ArrayObject. One way to address both of these issues is to make exchangeArray() share the logic that sets the array in __construct(). This way, echangeArray() works with object arguments (with some special cases if the argument is itself an ArrayObject), and array arguments are split before being stored in the ArrayObject. Here's a suggested patch against 5_3 that implements this (and includes some tests): http://pastebin.ca/1091668 Note that I'm not an internals or SPL expert, so let me know if I missed something. Regards, Robin