xref: /PHP-8.1/Zend/tests/bug28442.phpt (revision a555cc0b)
1--TEST--
2Bug #28442 (Changing a static variables in a class changes it across sub/super classes.)
3--FILE--
4<?php
5
6class ClassA
7{
8   static $prop;
9}
10
11class ClassB extends ClassA
12{
13   static $prop;
14}
15
16class ClassC extends ClassB
17{
18}
19
20echo "===INIT===\n";
21ClassA::$prop = 'A';
22ClassB::$prop = 'B';
23ClassC::$prop = 'C';
24var_dump(ClassA::$prop);
25var_dump(ClassB::$prop);
26var_dump(ClassC::$prop);
27
28echo "===SetA===\n";
29ClassA::$prop = 'A2';
30var_dump(ClassA::$prop);
31var_dump(ClassB::$prop);
32var_dump(ClassC::$prop);
33
34echo "===SetB===\n";
35ClassB::$prop = 'B2';
36var_dump(ClassA::$prop);
37var_dump(ClassB::$prop);
38var_dump(ClassC::$prop);
39
40echo "===SetC===\n";
41ClassC::$prop = 'C2';
42var_dump(ClassA::$prop);
43var_dump(ClassB::$prop);
44var_dump(ClassC::$prop);
45
46?>
47--EXPECT--
48===INIT===
49string(1) "A"
50string(1) "C"
51string(1) "C"
52===SetA===
53string(2) "A2"
54string(1) "C"
55string(1) "C"
56===SetB===
57string(2) "A2"
58string(2) "B2"
59string(2) "B2"
60===SetC===
61string(2) "A2"
62string(2) "C2"
63string(2) "C2"
64