Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:30102 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43161 invoked by uid 1010); 6 Jun 2007 06:10:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 43146 invoked from network); 6 Jun 2007 06:10:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2007 06:10:19 -0000 Authentication-Results: pb1.pair.com header.from=antony@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=antony@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: antony@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from [212.25.124.162] ([212.25.124.162:55627] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FB/80-39877-5CF46664 for ; Wed, 06 Jun 2007 02:10:19 -0400 Received: (qmail 29312 invoked from network); 6 Jun 2007 06:10:06 -0000 Received: from internal.zend.office (HELO ?127.0.0.1?) (10.1.1.1) by internal.zend.office with SMTP; 6 Jun 2007 06:10:06 -0000 Message-ID: <46664FBC.5070102@zend.com> Date: Wed, 06 Jun 2007 10:10:04 +0400 User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: "mark@cyanox.nl" CC: internals@lists.php.net References: <4665D15F.2040501@cyanox.nl> <4665D357.5070509@zend.com> <4665E1BF.5090107@cyanox.nl> In-Reply-To: <4665E1BF.5090107@cyanox.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Recursive classes ... possible bug? From: antony@zend.com (Antony Dovgal) On 06.06.2007 02:20, mark@cyanox.nl wrote: >>> Fatal error: Nesting level too deep - recursive dependency? in >>> /home/cyanox/DEV/test_object_recursion.php on line 15 >> >> $t->$tt->$t->$tt->$t->$tt->$t->$tt->$t->$tt->$t and so on. >> So you get endless recursion when comparing the objects. >> >>> Although it is obvious that there is a recursion I think this simple >>> example should work without error. >> >> Sure, if you have any proposals/ideas - feel free to share them. >> > Actually theoretically it should not give an error. Why? The behavior is quite clear - if the objects are instances of the same class, we have no other way to compare them but to compare their properties, this also applies to properties' properties and properties' properties' properties etc. > I just stumbled upon > this odd behavior when doing something very odd which would not work > anyway so I can't really think of a situation where the correct behavior > would be needed. Anyway the following also gives the error. > > class class1{ > public $c2; > function __construct($c2){ > $this->c2 = $c2; > } > } > > class class2{ > public $c1; > function test(){ > $this == $this->c1; // no error. Right. $this and $this->c1 are class2 and class1, no need even to look at the properties to say that they are not equal. > $this == $this; // errors. This is what I described earlier. If you have any ideas on how to improve it - I'd be happy to hear them. -- Wbr, Antony Dovgal