1--TEST-- 2ReflectionClass::getMethods() 3--CREDITS-- 4Robin Fernandes <robinf@php.net> 5Steve Seear <stevseea@php.net> 6--FILE-- 7<?php 8class C { 9 public function pubf1() {} 10 public function pubf2() {} 11 private function privf1() {} 12 private function privf2() {} 13 static public function pubsf1() {} 14 static public function pubsf2() {} 15 static private function privsf1() {} 16 static private function privsf2() {} 17} 18 19$rc = new ReflectionClass("C"); 20$StaticFlag = 0x01; 21$pubFlag = 0x100; 22$privFlag = 0x400; 23 24echo "No methods:"; 25var_dump($rc->getMethods(0)); 26 27echo "Public methods:"; 28var_dump($rc->getMethods($pubFlag)); 29 30echo "Private methods:"; 31var_dump($rc->getMethods($privFlag)); 32 33echo "Public or static methods:"; 34var_dump($rc->getMethods($StaticFlag | $pubFlag)); 35 36echo "Private or static methods:"; 37var_dump($rc->getMethods($StaticFlag | $privFlag)); 38 39 40?> 41--EXPECTF-- 42No methods:array(0) { 43} 44Public methods:array(4) { 45 [0]=> 46 object(ReflectionMethod)#%d (2) { 47 ["name"]=> 48 string(5) "pubf1" 49 ["class"]=> 50 string(1) "C" 51 } 52 [1]=> 53 object(ReflectionMethod)#%d (2) { 54 ["name"]=> 55 string(5) "pubf2" 56 ["class"]=> 57 string(1) "C" 58 } 59 [2]=> 60 object(ReflectionMethod)#%d (2) { 61 ["name"]=> 62 string(6) "pubsf1" 63 ["class"]=> 64 string(1) "C" 65 } 66 [3]=> 67 object(ReflectionMethod)#%d (2) { 68 ["name"]=> 69 string(6) "pubsf2" 70 ["class"]=> 71 string(1) "C" 72 } 73} 74Private methods:array(4) { 75 [0]=> 76 object(ReflectionMethod)#%d (2) { 77 ["name"]=> 78 string(6) "privf1" 79 ["class"]=> 80 string(1) "C" 81 } 82 [1]=> 83 object(ReflectionMethod)#%d (2) { 84 ["name"]=> 85 string(6) "privf2" 86 ["class"]=> 87 string(1) "C" 88 } 89 [2]=> 90 object(ReflectionMethod)#%d (2) { 91 ["name"]=> 92 string(7) "privsf1" 93 ["class"]=> 94 string(1) "C" 95 } 96 [3]=> 97 object(ReflectionMethod)#%d (2) { 98 ["name"]=> 99 string(7) "privsf2" 100 ["class"]=> 101 string(1) "C" 102 } 103} 104Public or static methods:array(6) { 105 [0]=> 106 object(ReflectionMethod)#%d (2) { 107 ["name"]=> 108 string(5) "pubf1" 109 ["class"]=> 110 string(1) "C" 111 } 112 [1]=> 113 object(ReflectionMethod)#%d (2) { 114 ["name"]=> 115 string(5) "pubf2" 116 ["class"]=> 117 string(1) "C" 118 } 119 [2]=> 120 object(ReflectionMethod)#%d (2) { 121 ["name"]=> 122 string(6) "pubsf1" 123 ["class"]=> 124 string(1) "C" 125 } 126 [3]=> 127 object(ReflectionMethod)#%d (2) { 128 ["name"]=> 129 string(6) "pubsf2" 130 ["class"]=> 131 string(1) "C" 132 } 133 [4]=> 134 object(ReflectionMethod)#%d (2) { 135 ["name"]=> 136 string(7) "privsf1" 137 ["class"]=> 138 string(1) "C" 139 } 140 [5]=> 141 object(ReflectionMethod)#%d (2) { 142 ["name"]=> 143 string(7) "privsf2" 144 ["class"]=> 145 string(1) "C" 146 } 147} 148Private or static methods:array(6) { 149 [0]=> 150 object(ReflectionMethod)#%d (2) { 151 ["name"]=> 152 string(6) "privf1" 153 ["class"]=> 154 string(1) "C" 155 } 156 [1]=> 157 object(ReflectionMethod)#%d (2) { 158 ["name"]=> 159 string(6) "privf2" 160 ["class"]=> 161 string(1) "C" 162 } 163 [2]=> 164 object(ReflectionMethod)#%d (2) { 165 ["name"]=> 166 string(6) "pubsf1" 167 ["class"]=> 168 string(1) "C" 169 } 170 [3]=> 171 object(ReflectionMethod)#%d (2) { 172 ["name"]=> 173 string(6) "pubsf2" 174 ["class"]=> 175 string(1) "C" 176 } 177 [4]=> 178 object(ReflectionMethod)#%d (2) { 179 ["name"]=> 180 string(7) "privsf1" 181 ["class"]=> 182 string(1) "C" 183 } 184 [5]=> 185 object(ReflectionMethod)#%d (2) { 186 ["name"]=> 187 string(7) "privsf2" 188 ["class"]=> 189 string(1) "C" 190 } 191} 192