1--TEST--
2Test get_class_methods() function : basic functionality
3--FILE--
4<?php
5/*
6 * Test behaviour with various visibility levels.
7 */
8
9class C {
10    private function privC() {}
11    protected function protC() {}
12    public function pubC() {}
13
14    public static function testFromC() {
15        echo "Accessing C from C:\n";
16        var_dump(get_class_methods("C"));
17        echo "Accessing D from C:\n";
18        var_dump(get_class_methods("D"));
19        echo "Accessing X from C:\n";
20        var_dump(get_class_methods("X"));
21    }
22}
23
24class D extends C {
25    private function privD() {}
26    protected function protD() {}
27    public function pubD() {}
28
29    public static function testFromD() {
30        echo "Accessing C from D:\n";
31        var_dump(get_class_methods("C"));
32        echo "Accessing D from D:\n";
33        var_dump(get_class_methods("D"));
34        echo "Accessing X from D:\n";
35        var_dump(get_class_methods("X"));
36    }
37}
38
39class X {
40    private function privX() {}
41    protected function protX() {}
42    public function pubX() {}
43
44    public static function testFromX() {
45        echo "Accessing C from X:\n";
46        var_dump(get_class_methods("C"));
47        echo "Accessing D from X:\n";
48        var_dump(get_class_methods("D"));
49        echo "Accessing X from X:\n";
50        var_dump(get_class_methods("X"));
51    }
52}
53
54echo "Accessing D from global scope:\n";
55var_dump(get_class_methods("D"));
56
57C::testFromC();
58D::testFromD();
59X::testFromX();
60
61echo "Done";
62?>
63--EXPECT--
64Accessing D from global scope:
65array(4) {
66  [0]=>
67  string(4) "pubD"
68  [1]=>
69  string(9) "testFromD"
70  [2]=>
71  string(4) "pubC"
72  [3]=>
73  string(9) "testFromC"
74}
75Accessing C from C:
76array(4) {
77  [0]=>
78  string(5) "privC"
79  [1]=>
80  string(5) "protC"
81  [2]=>
82  string(4) "pubC"
83  [3]=>
84  string(9) "testFromC"
85}
86Accessing D from C:
87array(7) {
88  [0]=>
89  string(5) "protD"
90  [1]=>
91  string(4) "pubD"
92  [2]=>
93  string(9) "testFromD"
94  [3]=>
95  string(5) "privC"
96  [4]=>
97  string(5) "protC"
98  [5]=>
99  string(4) "pubC"
100  [6]=>
101  string(9) "testFromC"
102}
103Accessing X from C:
104array(2) {
105  [0]=>
106  string(4) "pubX"
107  [1]=>
108  string(9) "testFromX"
109}
110Accessing C from D:
111array(3) {
112  [0]=>
113  string(5) "protC"
114  [1]=>
115  string(4) "pubC"
116  [2]=>
117  string(9) "testFromC"
118}
119Accessing D from D:
120array(7) {
121  [0]=>
122  string(5) "privD"
123  [1]=>
124  string(5) "protD"
125  [2]=>
126  string(4) "pubD"
127  [3]=>
128  string(9) "testFromD"
129  [4]=>
130  string(5) "protC"
131  [5]=>
132  string(4) "pubC"
133  [6]=>
134  string(9) "testFromC"
135}
136Accessing X from D:
137array(2) {
138  [0]=>
139  string(4) "pubX"
140  [1]=>
141  string(9) "testFromX"
142}
143Accessing C from X:
144array(2) {
145  [0]=>
146  string(4) "pubC"
147  [1]=>
148  string(9) "testFromC"
149}
150Accessing D from X:
151array(4) {
152  [0]=>
153  string(4) "pubD"
154  [1]=>
155  string(9) "testFromD"
156  [2]=>
157  string(4) "pubC"
158  [3]=>
159  string(9) "testFromC"
160}
161Accessing X from X:
162array(4) {
163  [0]=>
164  string(5) "privX"
165  [1]=>
166  string(5) "protX"
167  [2]=>
168  string(4) "pubX"
169  [3]=>
170  string(9) "testFromX"
171}
172Done
173