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