Re: clone wars

From: Date: Mon, 16 Feb 2004 00:39:44 +0000
Subject: Re: clone wars
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-7855@lists.php.net to get a copy of this message
More specifically, This causes a change in $object: $clone = clone $object; $clone->troublesomeVariable = array(); But this doesn't: $clone = clone $cell; $clone = null; $clone->_subElements = array(); On 15 Feb 2004, at 7:35 PM, Herr Witten wrote:
It appears that only one of the variables, an array, is being shared across these multiple objects, but other array variables are not. Moreover, When I make a clone and then set the clone to null, all clones made thereafter are correct. $clone = clone $object; $clone = null; Also, I can't replicate the problem with another class. It only seems to be this class. On 15 Feb 2004, at 5:47 PM, Marcus Boerger wrote:
Hello, most probably that property is a reference in which case the result is correct. Sunday, February 15, 2004, 11:45:56 PM, you wrote:
It appears that cloning is broken, since a modification to the clone modifies the original. For my __clone method implementation, I allow all of the variables to be set by default except for one. But this problem persists even when I don't modify that one variable.
-- Best regards,
 Marcus                            mailto:helly@php.net
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#7855) next »