Last active
August 29, 2015 14:04
-
-
Save shelwinnn/470a5c8a4059cd69b82a to your computer and use it in GitHub Desktop.
get all methods from a class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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