Exemplo n.º 1
0
 /**
  * 	method: getStackTrace
  *
  * 	todo: write documentation
  */
 public static function getStackTrace($va_args = NULL)
 {
     $a = func_get_args();
     $a = Amslib_Array::toKeyValue($a);
     $e = isset($a["exception"]) ? $a["exception"] : new Exception();
     if (isset($a["type"]) && in_array($a["type"], array("text", "string", "html"))) {
         //	A common mistake is putting "text" instead of "string" so i'll cover this up here
         if ($a["type"] == "text") {
             $a["type"] = "string";
         }
         $t = $e->getTraceAsString();
         $t = explode("\n", $t);
         $i = $a["type"] == "string" ? "\n" : "<br/>";
     } else {
         $t = $e->getTrace();
         //	remove the arguments because they are largely useless
         foreach ($t as $k => $ignore) {
             unset($t[$k]["args"]);
         }
     }
     if (isset($a["limit"])) {
         $l = $a["limit"];
         if (is_numeric($l)) {
             $l = array($l);
         }
         if (is_array($l) && count($l)) {
             $p = array($t, $s = intval(array_shift($l)));
             if (count($l) && ($e = intval(array_shift($l))) > $s) {
                 $p[] = $e;
             }
             $t = call_user_func_array("array_slice", $p);
         }
     }
     return isset($i) ? implode($i, $t) : $t;
 }