Skip to content

Instantly share code, notes, and snippets.

@iegik
Created December 4, 2012 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iegik/4203712 to your computer and use it in GitHub Desktop.
Save iegik/4203712 to your computer and use it in GitHub Desktop.
Get classes, methods and it`s arguments
<?php
function get_func_argNames($funcName,$className=null) {
if($className){
$f = new ReflectionMethod($className,$funcName);
}else{
$f = new ReflectionFunction($funcName);
}
$result = array();
foreach ($f->getParameters() as $param) {
$result[$param->name] = $param->isOptional()?:'required';
}
if(count($result))
return $result;
}
function get_class_info($c) {
$n=get_class($c);
if($f = get_class_methods($n)){
$mm = array_flip($f);
foreach($mm as $m=>$a){
$mm[$m] = get_func_argNames($m,$n);
}
return $mm;
}
}
function get_defined_functions_info($arr=false) {
foreach($arr as $d=>$f){
$arr[$d] = array_flip($f);
foreach($arr[$d] as $k=>$v){
$arr[$d][$k] = get_func_argNames($k);//func_get_args($v));
}
}
return $arr;
}
<?php
require_once "ChromePhp.php";
require_once "debug.php";
console::log(get_defined_functions_info(get_defined_functions()));
foreach( $_selections as $_selection){
console::log(get_class_info($_selection));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment