[color=#333333]public static function get_class_and_methods()
[/color]
{
// $classes = get_declared_classes();
$appdir = APPPATH."modules";
$appdirScan = array_diff(scandir($appdir), array('.', '..'));
echo "<pre>";
$arrAllModules = [];
foreach ($appdirScan as $keyParent => $module) {
$scanperModule = array_diff(preg_grep('~\.(php|phtml)$~', scandir($appdir."/".$module."/controllers")), array('.', '..'));
$arrAllModules[] = $scanperModule;
foreach ($scanperModule as $keyFChild => $value) {
// $a = file_get_contents($appdir."/".$module."/controllers/".$value);
$classes = self::getClassNameFromFile($appdir."/".$module."/controllers/".$value);
$methods = get_class_methods($classes);
var_dump ($methods);
// $aUserMethods = array();
// if(is_array($methods)){
// foreach($methods as $method) {
// var_dump ($method);
// if($method != '__construct' && $method != 'get_instance' && $method != $classes && $method != "setOutput" && $method != "checkAjaxSession" && $method != "setDeniedPage" && $method != "debug" && $method != "__get") {
// $aUserMethods[] = $method;
// }
// }
// }
}
}
// $flatten = array_flatten(array_merge($arrAllModules));
die();
}
private static function getClassNameFromFile($filePathName)
{
$php_code = file_get_contents($filePathName);
$classes = array();
$tokens = token_get_all($php_code);
$count = count($tokens);
for ($i = 2; $i < $count; $i++) {
if ($tokens[$i - 2][0] == T_CLASS
&& $tokens[$i - 1][0] == T_WHITESPACE
&& $tokens[$i][0] == T_STRING
) {
$class_name = $tokens[$i][1];
$classes[] = $class_name;
}
}
return $classes[0];
}
function array_flatten($array) {
if (!is_array($array)) {
return FALSE;
}
$result = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
$result = array_merge($result, array_flatten($value));
}
else {
$result[$key] = $value;
}
}
return $result;
[color=#333333] }
[/color]