summaryrefslogtreecommitdiff
path: root/tests/classes/clone_006.phpt
blob: 16f6bfe50814bcc9e5e5d5a5d4a2e7850a67dc0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--TEST--
ZE2 object cloning, 6
--INI--
error_reporting=2047
--FILE--
<?php

class MyCloneable {
    static $id = 0;

    function __construct() {
        $this->id = self::$id++;
    }

    function __clone() {
        $this->address = "New York";
        $this->id = self::$id++;
    }
}

$original = new MyCloneable();

$original->name = "Hello";
$original->address = "Tel-Aviv";

echo $original->id . "\n";

$clone = clone $original;

echo $clone->id . "\n";
echo $clone->name . "\n";
echo $clone->address . "\n";

?>
--EXPECTF--
Notice: Accessing static property MyCloneable::$id as non static in %s on line %d

Notice: Accessing static property MyCloneable::$id as non static in %s on line %d
0

Notice: Accessing static property MyCloneable::$id as non static in %s on line %d

Notice: Accessing static property MyCloneable::$id as non static in %s on line %d
1
Hello
New York