Created
December 4, 2012 13:06
-
-
Save iegik/4203712 to your computer and use it in GitHub Desktop.
Get classes, methods and it`s arguments
This file contains 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 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; | |
} |
This file contains 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 | |
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