Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26884 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45277 invoked by uid 1010); 10 Dec 2006 14:56:28 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 45249 invoked from network); 10 Dec 2006 14:56:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2006 14:56:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=colder@php.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=colder@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 213.239.212.54 cause and error) X-PHP-List-Original-Sender: colder@php.net X-Host-Fingerprint: 213.239.212.54 dns1.omne-serveurs.net Linux 2.4/2.6 Received: from [213.239.212.54] ([213.239.212.54:60134] helo=dns1.omne-serveurs.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/42-00543-5DF1C754 for ; Sun, 10 Dec 2006 09:55:52 -0500 Received: (qmail 1936 invoked from network); 10 Dec 2006 14:55:14 -0000 Received: from 85.0.56.126 by dns1 (envelope-from , uid 1004) with qmail-scanner-1.23 (clamdscan: 0.82. spamassassin: 3.0.1. perlscan: 1.32. Clear:RC:1(85.0.56.126):. Processed in 0.029477 secs); 10 Dec 2006 14:55:14 -0000 Received: from 126-56.0-85.cust.bluewin.ch (HELO ?10.0.0.2?) (85.0.56.126) by dns1.omne-serveurs.net with (DHE-RSA-AES256-SHA encrypted) SMTP; 10 Dec 2006 14:55:14 -0000 Message-ID: <457C1FD2.5050709@php.net> Date: Sun, 10 Dec 2006 15:55:14 +0100 User-Agent: Thunderbird 1.5.0.7 (X11/20060909) MIME-Version: 1.0 CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Magic Method that handles unset($object) From: colder@php.net (Etienne Kneuss) Hi, Sebastian Bergmann wrote: > > Is there another solution to this problem (apart from explicitly > unsetting the $children array on the $parent object)?And even if there > is I think that this method would be usefull. > You could use references, you would have to move some code around, though. I'm not sure that's exactly what you want, but give it a shot: class ParentC { public $children = array(); public function __construct() { print "ParentC::__construct()\n"; } public function __destruct() { print "ParentC::__destruct()\n"; } } class Child { public $parentO = null; public function __construct() { print "Child::__construct()\n"; } public function __destruct() { print "Child::__destruct()\n"; } } function &setup() { $parent = new ParentC; $child = new Child; $parent->children[] = &$child; $child->parentO = &$parent; return $parent; } $parent = &setup(); $parent = null; echo "--end--\n"; Result: ParentC::__construct() Child::__construct() ParentC::__destruct() Child::__destruct() --end-- -- Etienne Kneuss http://www.colder.ch colder@php.net Men never do evil so completely and cheerfully as when they do it from a religious conviction. -- Pascal