Skip to content

Instantly share code, notes, and snippets.

@shelwinnn
Last active August 29, 2015 14:04
Show Gist options
  • Save shelwinnn/470a5c8a4059cd69b82a to your computer and use it in GitHub Desktop.
Save shelwinnn/470a5c8a4059cd69b82a to your computer and use it in GitHub Desktop.
get all methods from a class
<?php
function getAllMethods($className){
$class = new ReflectionClass($className);
$methods = $class->getMethods();
foreach($methods as $k=>$method){
//method type
if($method->isAbstract()){
$methods[$k]->type = 'abstract';
}else if($method->isFinal()){
$methods[$k]->type = 'final';
}else if($method->isPrivate()){
$methods[$k]->type = 'private';
}else if($method->isProtected()){
$methods[$k]->type = 'protected';
}else if($method->isStatic()){
$methods[$k]->type = 'static';
}else{
$methods[$k]->type = 'public';
}
//method parameter
$params = $method->getParameters();
foreach($params as $param){
$methods[$k]->params[] = $param->name;
}
}
return $methods;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment