Hello Marcus,

Wednesday, July 2, 2003, 12:54:12 AM, you wrote:

MB> Hello Marcus,

MB> 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 = 
$a->__clone(); var_dump($a);var_dump($b);'
MB>>   object(t)#1 (1) {
MB>>     ["x"]=>
MB>>     NULL
MB>>   }
MB>>   object(t)#2 (0) {
MB>>   }


MB> I looked into the way it works and was able to fix the visibility. However
MB> there is still the problem that properties are not copied. I thing there are
MB> two possible solutions:
MB> a) create all properties in the new object before calling __clone
MB> b) create all missing propertis after calling __clone. This way (i fear) we
MB>    would need a new opcode....


After i've spent soem time on the thing i found out that we don't need
CG(in_clone_method). So if you don't need it in one of your applications or
extensions we can remove it.

-- 
Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to