xref: /php-src/Zend/tests/bug27798.phpt (revision 72c3eded)
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--EXPECT--
36Base::__construct
37array(3) {
38  ["Foo"]=>
39  int(1)
40  ["Bar"]=>
41  int(2)
42  ["Baz"]=>
43  int(3)
44}
45array(1) {
46  ["Foo"]=>
47  int(1)
48}
49Base::__construct
50array(3) {
51  ["Foo"]=>
52  int(1)
53  ["Bar"]=>
54  int(2)
55  ["Baz"]=>
56  int(3)
57}
58Child::__construct
59array(3) {
60  ["Foo"]=>
61  int(1)
62  ["Bar"]=>
63  int(2)
64  ["Baz"]=>
65  int(4)
66}
67array(1) {
68  ["Foo"]=>
69  int(1)
70}
71