xref: /PHP-7.3/Zend/tests/bug27798.phpt (revision 782352c5)
1--TEST--
2Bug #27798 (private / protected variables not exposed by get_object_vars() inside class)
3--FILE--
4<?php
5
6class Base
7{
8	public    $Foo = 1;
9	protected $Bar = 2;
10	private   $Baz = 3;
11
12	function __construct()
13	{
14		echo __METHOD__ . "\n";
15		var_dump(get_object_vars($this));
16	}
17}
18
19class Child extends Base
20{
21	private   $Baz = 4;
22
23	function __construct()
24	{
25		parent::__construct();
26		echo __METHOD__ . "\n";
27		var_dump(get_object_vars($this));
28	}
29}
30
31var_dump(get_object_vars(new Base));
32var_dump(get_object_vars(new Child));
33
34?>
35===DONE===
36--EXPECT--
37Base::__construct
38array(3) {
39  ["Foo"]=>
40  int(1)
41  ["Bar"]=>
42  int(2)
43  ["Baz"]=>
44  int(3)
45}
46array(1) {
47  ["Foo"]=>
48  int(1)
49}
50Base::__construct
51array(3) {
52  ["Foo"]=>
53  int(1)
54  ["Bar"]=>
55  int(2)
56  ["Baz"]=>
57  int(3)
58}
59Child::__construct
60array(3) {
61  ["Baz"]=>
62  int(4)
63  ["Foo"]=>
64  int(1)
65  ["Bar"]=>
66  int(2)
67}
68array(1) {
69  ["Foo"]=>
70  int(1)
71}
72===DONE===
73