1--TEST-- 2ReflectionClass::getMethods() 3--CREDITS-- 4Robin Fernandes <robinf@php.net> 5Steve Seear <stevseea@php.net> 6--FILE-- 7<?php 8class pubf { 9 public function f() {} 10 static public function s() {} 11} 12class subpubf extends pubf { 13} 14 15class protf { 16 protected function f() {} 17 static protected function s() {} 18} 19class subprotf extends protf { 20} 21 22class privf { 23 private function f() {} 24 static private function s() {} 25} 26class subprivf extends privf { 27} 28 29$classes = array("pubf", "subpubf", "protf", "subprotf", 30 "privf", "subprivf"); 31foreach($classes as $class) { 32 echo "Reflecting on class $class: \n"; 33 $rc = new ReflectionClass($class); 34 var_dump($rc->getMethods()); 35} 36 37?> 38--EXPECTF-- 39Reflecting on class pubf: 40array(2) { 41 [0]=> 42 object(ReflectionMethod)#%d (2) { 43 ["name"]=> 44 string(1) "f" 45 ["class"]=> 46 string(4) "pubf" 47 } 48 [1]=> 49 object(ReflectionMethod)#%d (2) { 50 ["name"]=> 51 string(1) "s" 52 ["class"]=> 53 string(4) "pubf" 54 } 55} 56Reflecting on class subpubf: 57array(2) { 58 [0]=> 59 object(ReflectionMethod)#%d (2) { 60 ["name"]=> 61 string(1) "f" 62 ["class"]=> 63 string(4) "pubf" 64 } 65 [1]=> 66 object(ReflectionMethod)#%d (2) { 67 ["name"]=> 68 string(1) "s" 69 ["class"]=> 70 string(4) "pubf" 71 } 72} 73Reflecting on class protf: 74array(2) { 75 [0]=> 76 object(ReflectionMethod)#%d (2) { 77 ["name"]=> 78 string(1) "f" 79 ["class"]=> 80 string(5) "protf" 81 } 82 [1]=> 83 object(ReflectionMethod)#%d (2) { 84 ["name"]=> 85 string(1) "s" 86 ["class"]=> 87 string(5) "protf" 88 } 89} 90Reflecting on class subprotf: 91array(2) { 92 [0]=> 93 object(ReflectionMethod)#%d (2) { 94 ["name"]=> 95 string(1) "f" 96 ["class"]=> 97 string(5) "protf" 98 } 99 [1]=> 100 object(ReflectionMethod)#%d (2) { 101 ["name"]=> 102 string(1) "s" 103 ["class"]=> 104 string(5) "protf" 105 } 106} 107Reflecting on class privf: 108array(2) { 109 [0]=> 110 object(ReflectionMethod)#%d (2) { 111 ["name"]=> 112 string(1) "f" 113 ["class"]=> 114 string(5) "privf" 115 } 116 [1]=> 117 object(ReflectionMethod)#%d (2) { 118 ["name"]=> 119 string(1) "s" 120 ["class"]=> 121 string(5) "privf" 122 } 123} 124Reflecting on class subprivf: 125array(2) { 126 [0]=> 127 object(ReflectionMethod)#%d (2) { 128 ["name"]=> 129 string(1) "f" 130 ["class"]=> 131 string(5) "privf" 132 } 133 [1]=> 134 object(ReflectionMethod)#%d (2) { 135 ["name"]=> 136 string(1) "s" 137 ["class"]=> 138 string(5) "privf" 139 } 140} 141