PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » PHP » PHP_Compat » Bug #3649

clone() fails

Details

Submitted2005-02-28 20:05 UTC
Fromojai at nerim dot net
Assignedaidan
StatusClosed
PackagePHP_Compat
PHP Version4.3.10
OSLinux Debian
Roadmaps(Not assigned)

Comments

[2005-02-28 20:05 UTC] ojai at nerim dot net

Description:
------------
Hi,

When an object property is assigned an object reference with "=& new", clone() fails to do its job properly.

Enjoy ;)

Reproduce code:
---------------
require_once 'PHP/Compat/Function/clone.php';

class B { var $c; }

class A
{
var $b;
function __clone()
{
$this->b = clone($this->b);
}
}

$obj = new A();
$obj->b =& new B(); // It would work with =
$obj->b->c = 1;
$clone = clone ($obj);
$clone->b->c = 2;
echo '$obj->b->c == ' . $obj->b->c . "\n";

Expected result:
----------------
$obj->b->c == 1

Actual result:
--------------
With PHP 5.0.2 : $obj->b->c == 1
With PHP 4.3.10 : $obj->b->c == 2