Recursive classes ... possible bug?

From: Date: Tue, 05 Jun 2007 21:10:55 +0000
Subject: Recursive classes ... possible bug?
Groups: php.internals 
Request: Send a blank email to internals+get-30084@lists.php.net to get a copy of this message
Dear internals, I stumbled upon the following odd error message from PHP which I was not expecting. Here is a small example that triggered the error with 5.2.2, 5.2.3 and a php5.2-200706052030 snapshot. <?php class class1{ public $c2; function __construct($c2){ $this->c2 = $c2; } } class class2{ public $c1; function setC1($c1){ $this->c1 = $c1; } function test(){ echo $this == $this->c1->c2?'equals':'not equals'; // Somehow this if statement triggers the error. } } $tt = new class2(); $t = new class1($tt); $tt->setC1($t); var_dump($t); $tt->test(); ?> I get the error: Fatal error: Nesting level too deep - recursive dependency? in /home/cyanox/DEV/test_object_recursion.php on line 15 Although it is obvious that there is a recursion I think this simple example should work without error. Greetings, Mark Sanders.

« previous php.internals (#30084) next »