xref: /PHP-7.1/Zend/tests/bug37212.phpt (revision 610c7fbe)
1--TEST--
2Bug #37212 (Access to protected property of common base class)
3--FILE--
4<?php
5
6class A
7{
8    protected $value;
9
10    public function __construct($val)
11    {
12        $this->value = $val;
13    }
14
15    protected function getValue()
16    {
17        return $this->value;
18    }
19}
20
21class B extends A
22{
23    public function copyValue($obj)
24    {
25        $this->value = $obj->getValue();
26        $this->value = $obj->value; // value defined in common base class
27    }
28}
29class C extends A {}
30
31$B = new B("B");
32var_dump($B);
33$C = new C("C");
34var_dump($C);
35
36$B->copyValue($C);
37
38var_dump($B);
39
40?>
41===DONE===
42--EXPECTF--
43object(B)#%d (1) {
44  ["value":protected]=>
45  string(1) "B"
46}
47object(C)#%d (1) {
48  ["value":protected]=>
49  string(1) "C"
50}
51object(B)#%d (1) {
52  ["value":protected]=>
53  string(1) "C"
54}
55===DONE===
56