1--TEST--
2Test get_class_vars() function : testing visibility
3--FILE--
4<?php
5class Ancestor {
6  function test() {
7    var_dump(get_class_vars("Tester"));
8  }
9
10  static function testStatic() {
11    var_dump(get_class_vars("Tester"));
12  }
13}
14
15class Tester extends Ancestor {
16  public $pub = "public var";
17  protected $prot = "protected var";
18  private $priv = "private var";
19
20  static public $pubs = "public static var";
21  static protected $prots = "protected static var";
22  static private $privs = "private static var";
23
24  function test() {
25    var_dump(get_class_vars("Tester"));
26  }
27
28  static function testStatic() {
29    var_dump(get_class_vars("Tester"));
30  }
31}
32
33class Child extends Tester {
34  function test() {
35    var_dump(get_class_vars("Tester"));
36  }
37
38  static function testStatic() {
39    var_dump(get_class_vars("Tester"));
40  }
41}
42
43echo "*** Testing get_class_vars() : testing visibility\n";
44
45echo "\n-- From global context --\n";
46var_dump(get_class_vars("Tester"));
47
48echo "\n-- From inside an object instance --\n";
49$instance = new Tester();
50$instance->test();
51
52echo "\n-- From  a static context --\n";
53Tester::testStatic();
54
55
56echo "\n-- From inside an  parent object instance --\n";
57$parent = new Ancestor();
58$parent->test();
59
60echo "\n-- From a parents static context --\n";
61Ancestor::testStatic();
62
63
64echo "\n-- From inside a child object instance --\n";
65$child = new Child();
66$child->test();
67
68echo "\n-- From a child's static context --\n";
69Child::testStatic();
70?>
71--EXPECT--
72*** Testing get_class_vars() : testing visibility
73
74-- From global context --
75array(2) {
76  ["pub"]=>
77  string(10) "public var"
78  ["pubs"]=>
79  string(17) "public static var"
80}
81
82-- From inside an object instance --
83array(6) {
84  ["pub"]=>
85  string(10) "public var"
86  ["prot"]=>
87  string(13) "protected var"
88  ["priv"]=>
89  string(11) "private var"
90  ["pubs"]=>
91  string(17) "public static var"
92  ["prots"]=>
93  string(20) "protected static var"
94  ["privs"]=>
95  string(18) "private static var"
96}
97
98-- From  a static context --
99array(6) {
100  ["pub"]=>
101  string(10) "public var"
102  ["prot"]=>
103  string(13) "protected var"
104  ["priv"]=>
105  string(11) "private var"
106  ["pubs"]=>
107  string(17) "public static var"
108  ["prots"]=>
109  string(20) "protected static var"
110  ["privs"]=>
111  string(18) "private static var"
112}
113
114-- From inside an  parent object instance --
115array(4) {
116  ["pub"]=>
117  string(10) "public var"
118  ["prot"]=>
119  string(13) "protected var"
120  ["pubs"]=>
121  string(17) "public static var"
122  ["prots"]=>
123  string(20) "protected static var"
124}
125
126-- From a parents static context --
127array(4) {
128  ["pub"]=>
129  string(10) "public var"
130  ["prot"]=>
131  string(13) "protected var"
132  ["pubs"]=>
133  string(17) "public static var"
134  ["prots"]=>
135  string(20) "protected static var"
136}
137
138-- From inside a child object instance --
139array(4) {
140  ["pub"]=>
141  string(10) "public var"
142  ["prot"]=>
143  string(13) "protected var"
144  ["pubs"]=>
145  string(17) "public static var"
146  ["prots"]=>
147  string(20) "protected static var"
148}
149
150-- From a child's static context --
151array(4) {
152  ["pub"]=>
153  string(10) "public var"
154  ["prot"]=>
155  string(13) "protected var"
156  ["pubs"]=>
157  string(17) "public static var"
158  ["prots"]=>
159  string(20) "protected static var"
160}
161