summaryrefslogtreecommitdiff
path: root/ext/standard/tests/class_object/get_class_vars_variation2.phpt
blob: 9098aa7311240f340f305f97db611ad68ee6a6b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
--TEST--
Test get_class_vars() function : testing visibility
--FILE--
<?php
class Ancestor {
  function test() {
    var_dump(get_class_vars("Tester"));
  }

  static function testStatic() {
    var_dump(get_class_vars("Tester"));
  }
}

class Tester extends Ancestor {
  public $pub = "public var";
  protected $prot = "protected var";
  private $priv = "private var";

  static public $pubs = "public static var";
  static protected $prots = "protected static var";
  static private $privs = "private static var";

  function test() {
    var_dump(get_class_vars("Tester"));
  }

  static function testStatic() {
    var_dump(get_class_vars("Tester"));
  }
}

class Child extends Tester {
  function test() {
    var_dump(get_class_vars("Tester"));
  }

  static function testStatic() {
    var_dump(get_class_vars("Tester"));
  }
}

echo "*** Testing get_class_vars() : testing visibility\n";

echo "\n-- From global context --\n";
var_dump(get_class_vars("Tester"));

echo "\n-- From inside an object instance --\n";
$instance = new Tester();
$instance->test();

echo "\n-- From  a static context --\n";
Tester::testStatic();


echo "\n-- From inside an  parent object instance --\n";
$parent = new Ancestor();
$parent->test();

echo "\n-- From a parents static context --\n";
Ancestor::testStatic();


echo "\n-- From inside a child object instance --\n";
$child = new Child();
$child->test();

echo "\n-- From a child's static context --\n";
Child::testStatic();
?>
--EXPECT--
*** Testing get_class_vars() : testing visibility

-- From global context --
array(2) {
  ["pub"]=>
  string(10) "public var"
  ["pubs"]=>
  string(17) "public static var"
}

-- From inside an object instance --
array(6) {
  ["pub"]=>
  string(10) "public var"
  ["prot"]=>
  string(13) "protected var"
  ["priv"]=>
  string(11) "private var"
  ["pubs"]=>
  string(17) "public static var"
  ["prots"]=>
  string(20) "protected static var"
  ["privs"]=>
  string(18) "private static var"
}

-- From  a static context --
array(6) {
  ["pub"]=>
  string(10) "public var"
  ["prot"]=>
  string(13) "protected var"
  ["priv"]=>
  string(11) "private var"
  ["pubs"]=>
  string(17) "public static var"
  ["prots"]=>
  string(20) "protected static var"
  ["privs"]=>
  string(18) "private static var"
}

-- From inside an  parent object instance --
array(4) {
  ["pub"]=>
  string(10) "public var"
  ["prot"]=>
  string(13) "protected var"
  ["pubs"]=>
  string(17) "public static var"
  ["prots"]=>
  string(20) "protected static var"
}

-- From a parents static context --
array(4) {
  ["pub"]=>
  string(10) "public var"
  ["prot"]=>
  string(13) "protected var"
  ["pubs"]=>
  string(17) "public static var"
  ["prots"]=>
  string(20) "protected static var"
}

-- From inside a child object instance --
array(4) {
  ["pub"]=>
  string(10) "public var"
  ["prot"]=>
  string(13) "protected var"
  ["pubs"]=>
  string(17) "public static var"
  ["prots"]=>
  string(20) "protected static var"
}

-- From a child's static context --
array(4) {
  ["pub"]=>
  string(10) "public var"
  ["prot"]=>
  string(13) "protected var"
  ["pubs"]=>
  string(17) "public static var"
  ["prots"]=>
  string(20) "protected static var"
}