Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39579 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86549 invoked from network); 3 Aug 2008 21:27:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Aug 2008 21:27:58 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:49813] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/95-50899-BD226984 for ; Sun, 03 Aug 2008 17:27:56 -0400 Received: from MBOERGER-ZRH.corp.google.com (194-156.107-92.cust.bluewin.ch [92.107.156.194]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 4C28511FC82; Sun, 3 Aug 2008 23:27:52 +0200 (CEST) Date: Sun, 3 Aug 2008 23:25:01 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1815659426.20080803232501@marcus-boerger.de> To: "Robin Fernandes" CC: "Marcus Boerger" , internals In-Reply-To: <5a8807d10808031324k2f83789ak233d75ec704a6c31@mail.gmail.com> References: <5a8807d10808030407j14f51cb6ga7d917d51c6206ac@mail.gmail.com> <93357385.20080803141751@marcus-boerger.de> <5a8807d10808031324k2f83789ak233d75ec704a6c31@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Intended behavior of ArrayObject::exchangeArray() ? From: helly@php.net (Marcus Boerger) Hello Robin, Sunday, August 3, 2008, 10:24:17 PM, you wrote: > Hi Marcus! >>> 1. What should happen when the argument is an object? >> >> Seems like an error message is missing there. It allows to take an instance >> of another ArrayObject/Iterator and use the array from that. >> >> In case any other Object is passed it is ignored. What do you feel? > Sounds alright to me, but it's inconsistent with __construct(), which > in addition to using the storage array from ArrayObject/Iterator > instances, can use the properties from any other kind of object. Also, > just to be clear, I should point out that it is not the current > behaviour. Passing any object to exchangeArray(), even an instance of > ArrayObject/Iterator, eradicates the container: > $ao1 = new ArrayObject(array('one')); > $ao2 = new ArrayObject(array('two')); > $ao1->exchangeArray($ao2); > var_dump($ao1); ?>> > Output on PHP 5.3.0-dev (cli) (built: Jul 28 2008 00:21:59): > object(ArrayObject)#1 (0) { > } >>> 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. >> >> Seems about right. Can you attach the patch as a text file (I cannot open >> the link). > Attached. I just naively moved some logic from __construct() into a > separate function and called it from both __construct() and > exchangeArray(). Well, naively or not, this seems about perfectly correct. Why don't you simply apply this to HEAD and 5.3? Best regards, Marcus