Annotation of embedaddon/php/tests/classes/clone_004.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: ZE2 object cloning, 4
3: --FILE--
4: <?php
5: abstract class base {
6: public $a = 'base';
7:
8: // disallow cloning
9: private function __clone() {}
10: }
11:
12: class test extends base {
13: public $b = 'test';
14:
15: // reenable cloning
16: public function __clone() {}
17:
18: public function show() {
19: var_dump($this);
20: }
21: }
22:
23: echo "Original\n";
24: $o1 = new test;
25: $o1->a = array(1,2);
26: $o1->b = array(3,4);
27: $o1->show();
28:
29: echo "Clone\n";
30: $o2 = clone $o1;
31: $o2->show();
32:
33: echo "Modify\n";
34: $o2->a = 5;
35: $o2->b = 6;
36: $o2->show();
37:
38: echo "Done\n";
39: ?>
40: --EXPECT--
41: Original
42: object(test)#1 (2) {
43: ["b"]=>
44: array(2) {
45: [0]=>
46: int(3)
47: [1]=>
48: int(4)
49: }
50: ["a"]=>
51: array(2) {
52: [0]=>
53: int(1)
54: [1]=>
55: int(2)
56: }
57: }
58: Clone
59: object(test)#2 (2) {
60: ["b"]=>
61: array(2) {
62: [0]=>
63: int(3)
64: [1]=>
65: int(4)
66: }
67: ["a"]=>
68: array(2) {
69: [0]=>
70: int(1)
71: [1]=>
72: int(2)
73: }
74: }
75: Modify
76: object(test)#2 (2) {
77: ["b"]=>
78: int(6)
79: ["a"]=>
80: int(5)
81: }
82: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>