Hi internals,
in the following code __clone() have problems with member variables of type
object ($this->obj is null). If the comment is removed from the call to
__clone2() in __clone() then __clone2() also has problems with the vision. On
the other hand __clone2() has no problems when called externally.
The code :
<?php
class clone_example {
        private $pub = 2;
        private $obj = NULL;

        function clone_example($obj) {
                $this->obj = $obj;
        }

        function __clone() {
                print_r($this);
//              $this->__clone2();
        }
        function __clone2() {
                print_r($this);
        }
}

class fubar {
        public $v = array(1,2,3);
}
$fu = new fubar();
$a = new clone_example($fu);
$a->__clone2();
$a->__clone();
$a->__clone2();
?>


The output is :
clone_example Object
(
    [pub:private] => 2
    [obj:private] => fubar Object
        (
            [v] => Array
                (
                    [0] => 1
                    [1] => 2
                    [2] => 3
                )

        )

)
clone_example Object
(
    [pub:private] => 2
    [obj:private] =>
)
clone_example Object
(
    [pub:private] => 2
    [obj:private] => fubar Object
        (
            [v] => Array
                (
                    [0] => 1
                    [1] => 2
                    [2] => 3
                )

        )

)

Am I doing something wrong or there is something wrong in the engine?

Andrey

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

Reply via email to