xref: /PHP-7.1/tests/classes/clone_003.phpt (revision 610c7fbe)
1--TEST--
2ZE2 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
7class 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
18class 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;
31echo "Object\n";
32print_r($obj);
33echo "Clown\n";
34print_r($copy);
35echo "Done\n";
36?>
37--EXPECT--
38Object
39test 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)
48Clown
49test 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)
58Done
59