Get public and private methods of a class

From , 5 Years ago, written in PHP, viewed 208 times.
URL https://pastebin.vip/view/77edbe5f
  1. function getClassMethods($class,$type = 'all') {
  2.  
  3.     $typeArr = array('public','protected','private','static','final','abstract');
  4.     $type = !in_array(strtolower($type),$typeArr) ? 'all' : 'is'.$type;
  5.     $methods = array();
  6.     $reflection  = new ReflectionClass($class);
  7.     foreach($reflection ->getMethods() as $obj){
  8.         if('all' == $type) {
  9.             $methods[] = $obj->name;
  10.         }else {
  11.             if(call_user_func(array(new ReflectionMethod($obj->class, $obj->name),$type))){
  12.                 $methods[] = $obj->name;
  13.             }
  14.         }
  15.     }
  16.     return $methods;
  17. }

Reply to "Get public and private methods of a class"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website