ID: 27707
User updated by: jesse at mactechs dot com
Reported By: jesse at mactechs dot com
Status: Open
Bug Type: Class/Object related
Operating System: Irrelevant
PHP Version: 4.3.4
New Comment:
Correction: last words of last sentance of second
paragraph of description should read: "(WITHOUT
recursing to all the values)".
Previous Comments:
------------------------------------------------------------------------
[2004-03-25 19:34:05] jesse at mactechs dot com
Description:
------------
Recursive object reference comparisons fail in PHP4.x.
Alternative to my "exptected result" below, I would
settle for one of a couple of things. One would be a
boolean comparison function that returns true if two
references point to the same data, or another could be
simply a boolean function that returns true if two
objects are the same (with recursing to all the values).
I'm aware the Zend Engine 2/PHP5 identity operator works
in the fashion I'd like now, but I'd still consider this
a bug for Zend Engine/PHP4.
Reproduce code:
---------------
// key failing element here is B::is_ref
class A {
var $a_ref;
function set_ref (&$obj) {
$this->a_ref =& $obj; } }
class B {
var $b_ref;
function set_ref (&$obj) {
$this->b_ref =& $obj; }
function is_ref (&$obj) {
if ($obj === $this->b_ref)
return true; } }
$a = new A; $b = new B;
$a->set_ref ($b); $b->set_ref ($a);
var_dump ($b->is_ref ($a));
Expected result:
----------------
I would expect that "if ($obj === $this->b_ref)" would
return true if they (the two object references being
compared) referenced the same object, and
false if they didnt. Please see my description, as
well.
Actual result:
--------------
"
Fatal error: Nesting level too deep - recursive
dependency? in /path-to/test.php on line 12
"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27707&edit=1