From:             marc dot daumas at urssaf dot fr
Operating system: WinXP
PHP version:      Irrelevant
PHP Bug Type:     Class/Object related
Bug description:  cross referenced objects

Description:
------------
It becomes impossible to compare objects as soon as they have cross
references.
if an object A reference an object B that reference A it becomes
impossible to compare objects with == or === operators.
I understood your "reference" system and actualy I know that's not really
a bug but an issue, but at least the === operator must deal with "already
seen" objects.
I just wonder if PHP5 will become a near to real object language or if
that behavior will persist.
Follow a basic example of Parent/Child object structure that can't be
implemented in PHP4.
I think that if it's impossible to work properly with instances, PHP5 will
not ritch the rank of an OOP language despite all that is said about it.
Best regards

-Marc

Reproduce code:
---------------
<?PHP
Class ParentObject {
        
        var $name;
        var $chidren;
        
        Function &ParentObject($name){
                $this->name=$name;
                $this->children=array();
        }
        
        Function addChild(&$child){
                if(!isset($this->children[$child->name])){
                        $this->children[$child->name]=&$child;
                        $child->setParent($this);
                }
        }
}
Class ChildObject {
        
        var $name;
        var $parent;
        
        Function &ChildObject($name){
                $this->name=$name;
                $this->parent=null;
        }
        
        Function setParent(&$parent){
                if($this->parent!==$parent){
                        if($this->parent!=null){
                                $this->parent->removeChild($this);
                        }
                        $this->parent=&$parent;
                        if($parent!=null){
                                $parent->addChild($this);
                        }
                }
        }
}
$p=&new ParentObject("parent");
$c=&new ChildObject("child");
$c->setParent($p);
?>

Expected result:
----------------
something other than 
<b>Fatal error</b>:  Nesting level too deep - recursive dependency? in
<b>C:\Program Files\Apache Group\Apache2\htdocs\ngn2\test.php</b> on line
<b>29</b><br />


Actual result:
--------------
<b>Fatal error</b>:  Nesting level too deep - recursive dependency? in
<b>C:\Program Files\Apache Group\Apache2\htdocs\ngn2\test.php</b> on line
<b>29</b><br />


-- 
Edit bug report at http://bugs.php.net/?id=26586&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26586&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26586&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26586&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26586&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26586&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26586&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26586&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26586&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26586&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26586&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26586&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26586&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26586&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26586&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26586&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26586&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26586&r=float

Reply via email to