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