Return to clone_003.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / classes |
1.1 ! misho 1: --TEST-- ! 2: ZE2 object cloning, 3 ! 3: --SKIPIF-- ! 4: <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> ! 5: --FILE-- ! 6: <?php ! 7: class base { ! 8: protected $p1 = 'base:1'; ! 9: public $p2 = 'base:2'; ! 10: public $p3 = 'base:3'; ! 11: public $p4 = 'base:4'; ! 12: public $p5 = 'base:5'; ! 13: private $p6 = 'base:6'; ! 14: public function __clone() { ! 15: } ! 16: }; ! 17: ! 18: class test extends base { ! 19: public $p1 = 'test:1'; ! 20: public $p3 = 'test:3'; ! 21: public $p4 = 'test:4'; ! 22: public $p5 = 'test:5'; ! 23: public function __clone() { ! 24: $this->p5 = 'clone:5'; ! 25: } ! 26: } ! 27: ! 28: $obj = new test; ! 29: $obj->p4 = 'A'; ! 30: $copy = clone $obj; ! 31: echo "Object\n"; ! 32: print_r($obj); ! 33: echo "Clown\n"; ! 34: print_r($copy); ! 35: echo "Done\n"; ! 36: ?> ! 37: --EXPECT-- ! 38: Object ! 39: test Object ! 40: ( ! 41: [p1] => test:1 ! 42: [p3] => test:3 ! 43: [p4] => A ! 44: [p5] => test:5 ! 45: [p2] => base:2 ! 46: [p6:base:private] => base:6 ! 47: ) ! 48: Clown ! 49: test Object ! 50: ( ! 51: [p1] => test:1 ! 52: [p3] => test:3 ! 53: [p4] => A ! 54: [p5] => clone:5 ! 55: [p2] => base:2 ! 56: [p6:base:private] => base:6 ! 57: ) ! 58: Done