php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26586 cross referenced objects
Submitted: 2003-12-10 11:45 UTC Modified: 2013-08-06 08:04 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: marc dot daumas at urssaf dot fr Assigned: yohgaki (profile)
Status: Closed Package: *General Issues
PHP Version: Irrelevant OS: WinXP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marc dot daumas at urssaf dot fr
New email:
PHP Version: OS:

 

 [2003-12-10 11:45 UTC] marc dot daumas at urssaf dot fr
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 />


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-27 23:52 UTC] will dot skates at ntlworld dot com
Please Close
 [2013-08-06 08:04 UTC] yohgaki@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: yohgaki
 [2013-08-06 08:04 UTC] yohgaki@php.net
It seems working now.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 03 23:01:32 2025 UTC