Re: before beta 2
| From: | (Marcus B�rger) | Date: | Tue, 01 Jul 2003 22:54:12 +0000 |
| Subject: | Re: before beta 2 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-3126@lists.php.net to get a copy of this message | ||
Hello Marcus,
Monday, June 30, 2003, 2:28:35 AM, you wrote:
MB> - Fix __clone() visibility. When implementing singletons we must forbid calling
MB> __clone() by making it private (private function __clone() is the same to
MB> singletons as private function __construct() to factories). Also the clone
MB> mechanism must ensure the new object has all properties defined in the class.
MB> The current implementation doesn't do so what contradicts the inheritance
MB> model. The following example show both errors:
MB> php -r 'class t {var $x; private function __clone() {} }; $a = new t; $b =
MB> $a->__clone(); var_dump($a);var_dump($b);'
MB> object(t)#1 (1) {
MB> ["x"]=>
MB> NULL
MB> }
MB> object(t)#2 (0) {
MB> }
I looked into the way it works and was able to fix the visibility. However
there is still the problem that properties are not copied. I thing there are
two possible solutions:
a) create all properties in the new object before calling __clone
b) create all missing propertis after calling __clone. This way (i fear) we
would need a new opcode....
--
Best regards,
Marcus mailto:helly@php.net