32 if (self::$_filePath ===
null) {
34 self::$_filePath =
BP;
36 self::$_filePath = dirname(
__DIR__);
50 public static function backtrace($return =
false, $html =
true, $withArgs =
true)
52 $trace = debug_backtrace();
53 return self::trace($trace, $return, $html, $withArgs);
67 public static function trace(array $trace, $return =
false, $html =
true, $withArgs =
true)
74 foreach ($trace as
$i =>
$data) {
82 if (isset(
$data[
'args']) && $withArgs) {
83 foreach (
$data[
'args'] as $arg) {
89 if (isset(
$data[
'class']) && isset(
$data[
'function'])) {
90 if (isset(
$data[
'object']) && get_class(
$data[
'object']) !=
$data[
'class']) {
95 if (isset(
$data[
'object'])) {
99 $methodName = sprintf(
107 $methodName = sprintf(
'%s(%s)',
$data[
'function'], join(
', ', $args));
110 if (isset(
$data[
'file'])) {
111 $pos = strpos(
$data[
'file'], self::getRootPath());
112 if (
$pos !==
false) {
113 $data[
'file'] = substr(
$data[
'file'], strlen(self::getRootPath()) + 1);
121 $out .= sprintf(
'#%d %s called at [%s]',
$i, $methodName,
$fileName);
123 $out .= sprintf(
'#%d %s',
$i, $methodName);
151 if (is_object($arg)) {
152 $out .= sprintf(
"&%s#%s#", get_class($arg), spl_object_hash($arg));
155 }
elseif (is_array($arg)) {
156 $isAssociative =
false;
158 foreach ($arg as $k => $v) {
159 if (!is_numeric($k)) {
160 $isAssociative =
true;
164 if ($isAssociative) {
166 foreach ($args as $k => $v) {
169 $out .=
'array(' . join(
', ', $arr) .
')';
171 $out .=
'array(' . join(
', ', $args) .
')';
173 }
elseif ($arg ===
null) {
175 }
elseif (is_numeric($arg) || is_float($arg)) {
177 }
elseif (is_string($arg)) {
178 if (strlen($arg) > self::$argLength) {
179 $arg = substr($arg, 0, self::$argLength) .
"...";
181 $arg = strtr($arg, [
"\t" =>
'\t',
"\r" =>
'\r',
"\n" =>
'\n',
"'" =>
'\\\'']);
182 $out .=
"'" . $arg .
"'";
183 }
elseif (is_bool($arg)) {
184 $out .= $arg ===
true ?
'true' :
'false';
static backtrace($return=false, $html=true, $withArgs=true)
elseif(isset( $params[ 'redirect_parent']))
defined('TESTS_BP')||define('TESTS_BP' __DIR__
static trace(array $trace, $return=false, $html=true, $withArgs=true)
static _formatCalledArgument($arg)