The code below produces:

Fatal error: Nesting level too deep - recursive dependency?
in test.php on line 24

This is should not happen since the objects being compared are
the same object, so there should be no need to recusively compare the
objects.
Additionally, I think the comparison should bail out (without a fatal
error) when the objects are not the same and when a recursive dependency
is found.

IMHO, this is a critical problem that should be fixed for 4.3, since it
prevents anyone from using OO with references in a reasonable way.


<?php
   class A {
       var $b;

       function A()
       {
           $this->b =& new B($this);
       }
   }

   class B {
       var $a;

       function B(&$a)
       {
           $this->a =& $a;
       }
   }

   $one =& new A;
   $two =& $one;

   if ($one == $two) {  // <-- fatal error here
       echo "Same object\n";
   } else {
       echo "not the same object\n";
   }
?>

-- 
Wez Furlong
The Brain Room Ltd.


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to