コード例 #1
0
ファイル: tree.class.php プロジェクト: antixrist/Common
 public static function callStack()
 {
     $GC = CARRY('get_class');
     $callstack = Tree::getActiveCallstack();
     $count = count($callstack);
     Tree::$currentIndex = count(Tree::getActiveNodes()) - 1;
     if (!$count) {
         return false;
     }
     for ($i = 0; $i < $count; $i++) {
         foreach (array_keys($callstack[$i]) as $key) {
             if (strpos($key, '_') === 0) {
                 $callstack[$i][substr($key, 1)] = $callstack[$i][$key];
                 unset($callstack[$i][$key]);
             } elseif ($i < $count - 1) {
                 unset($callstack[$i][$key]);
             }
         }
     }
     $final = array();
     for ($i = $count - 1; $i >= 0; $i--) {
         $final += $callstack[$i];
     }
     ksort($final);
     foreach ($final as $key => $value) {
         if (is_string($value)) {
             $name = "{$value}";
         } elseif (is_array($value) and is_string($value[0])) {
             $name = "{$value[0]}";
         } elseif (is_array($value) and is_array($value[0]) and is_string($value[0][0])) {
             $name = "{$value[0][0]}, {$value[0][1]}";
         } elseif (is_array($value) and is_array($value[0]) and is_object($value[0][0])) {
             $name = "{$GC($value[0][0])}, {$value[0][1]}";
         } elseif (is_closure($value)) {
             $name = "CLOSURE ({$key})";
         } else {
             continue;
         }
         Profiling::start($name);
         if (is_closure($value)) {
             $value();
         } else {
             if (is_string($value)) {
                 $value = array($value);
             }
             $function = array_shift($value);
             call_user_func_array($function, $value);
         }
         Profiling::stop();
     }
     return true;
 }