From 5681e94086706842dc89e8377141479a8bf1fea4 Mon Sep 17 00:00:00 2001 From: avl Date: Sun, 14 Sep 2008 04:18:17 +0300 Subject: [PATCH] Fast & Smart ServerErrorDebug Responce --- ipf/http/response/servererrordebug.php | 11 ++++++- ipf/utils.php | 40 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ipf/http/response/servererrordebug.php b/ipf/http/response/servererrordebug.php index d4374cb..f300c73 100644 --- a/ipf/http/response/servererrordebug.php +++ b/ipf/http/response/servererrordebug.php @@ -9,6 +9,8 @@ class IPF_HTTP_Response_ServerErrorDebug extends IPF_HTTP_Response } } + + function IPF_HTTP_Response_ServerErrorDebug_Pretty($e) { $o = create_function('$in','return htmlspecialchars($in);'); @@ -196,12 +198,19 @@ function IPF_HTTP_Response_ServerErrorDebug_Pretty($e) '; foreach ($frame['args'] as $k => $v) { $name = isset($params[$k]) ? '$'.$params[$k]->name : '?'; + switch (gettype($v)){ + case "object": + $value = 'Instance of '.get_class($v); + break; + default: + $value = (string)$v; + } $out .= ' '.$o($k).' '.$o($name).' -
'.highlight_string(print_r($v,true), true).'
+
'.highlight_string($value, true).'
'; } diff --git a/ipf/utils.php b/ipf/utils.php index 12a0642..54da745 100644 --- a/ipf/utils.php +++ b/ipf/utils.php @@ -171,5 +171,45 @@ class IPF_Utils { $dir->close(); return true; } + + public static function print_r($subject, $ignore = array(), $depth = 5, $refChain = array()) + { + $s = ''; + if ($depth > 20) return; + if (is_object($subject)) { + foreach ($refChain as $refVal) + if ($refVal === $subject) { + $s .= "*RECURSION*\n"; + return; + } + array_push($refChain, $subject); + $s .= get_class($subject) . " Object ( \n"; + $subject = (array) $subject; + foreach ($subject as $key => $val) + if (is_array($ignore) && !in_array($key, $ignore, 1)) { + $s .= str_repeat(" ", $depth * 4) . '['; + if ($key{0} == "\0") { + $keyParts = explode("\0", $key); + $s .= $keyParts[2] . (($keyParts[1] == '*') ? ':protected' : ':private'); + } else + $s .= $key; + $s .= '] => '; + IPF_Utils::print_r($val, $ignore, $depth + 1, $refChain); + } + $s .= str_repeat(" ", ($depth - 1) * 4) . ")\n"; + array_pop($refChain); + } elseif (is_array($subject)) { + $s .= "Array ( \n"; + foreach ($subject as $key => $val) + if (is_array($ignore) && !in_array($key, $ignore, 1)) { + $s .= str_repeat(" ", $depth * 4) . '[' . $key . '] => '; + IPF_Utils::print_r($val, $ignore, $depth + 1, $refChain); + } + $s .= str_repeat(" ", ($depth - 1) * 4) . ")\n"; + } else + $s .= $subject . "\n"; + return $s; + } + } -- 2.49.0