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