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 =
$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:[EMAIL PROTECTED]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php