#47587 [Bgs]: When exactly is __clone() executed?
| From: | scout at hyperspace-travel dot de | Date: | Fri, 06 Mar 2009 13:44:57 +0000 |
| Subject: | #47587 [Bgs]: When exactly is __clone() executed? | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-1944@lists.php.net to get a copy of this message | ||
ID: 47587
User updated by: scout at hyperspace-travel dot de
Reported By: scout at hyperspace-travel dot de
Status: Bogus
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
"If a __clone() method is
defined, then the newly created object's __clone() method will be
called, to allow any necessary properties that need to be changed."
Yes, I read that. But that doesn't say WHEN __clone() is executed.
Previous Comments:
------------------------------------------------------------------------
[2009-03-06 13:34:39] rquadling@php.net
http://docs.php.net/manual/en/language.oop5.cloning.php
gives a clear
explanation of what happens when cloning is applied to an object.
"When an object is cloned, PHP 5 will perform a shallow copy of all
of the object's properties. Any properties that are references to
other variables, will remain references. If a __clone() method is
defined, then the newly created object's __clone() method will be
called, to allow any necessary properties that need to be changed."
------------------------------------------------------------------------
[2009-03-06 13:25:36] scout at hyperspace-travel dot de
Description:
------------
The documentation does not mention when exactly the __clone() method is
performed. Neither does any of the comments. No I figure it is done
AFTER shallow-copying the attributes of the old object to the new on, as
everything else would be braindead. But still, it would be nice to have
this information written down because that is a pretty crucial detail
and it helps to understand the process of cloning in the first place.
Greets, Lene
Reproduce code:
---------------
---
From manual page: language.oop5.cloning
---
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47587&edit=1