xref: /PHP-7.1/tests/classes/clone_006.phpt (revision 8d003858)
1--TEST--
2ZE2 object cloning, 6
3--SKIPIF--
4<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
5--INI--
6error_reporting=2047
7--FILE--
8<?php
9
10class MyCloneable {
11	static $id = 0;
12
13	function __construct() {
14		$this->id = self::$id++;
15	}
16
17	function __clone() {
18		$this->address = "New York";
19		$this->id = self::$id++;
20	}
21}
22
23$original = new MyCloneable();
24
25$original->name = "Hello";
26$original->address = "Tel-Aviv";
27
28echo $original->id . "\n";
29
30$clone = clone $original;
31
32echo $clone->id . "\n";
33echo $clone->name . "\n";
34echo $clone->address . "\n";
35
36?>
37--EXPECTF--
38Notice: Accessing static property MyCloneable::$id as non static in %s on line %d
39
40Notice: Accessing static property MyCloneable::$id as non static in %s on line %d
410
42
43Notice: Accessing static property MyCloneable::$id as non static in %s on line %d
44
45Notice: Accessing static property MyCloneable::$id as non static in %s on line %d
461
47Hello
48New York
49