]> git.andy128k.dev Git - ipf.git/commitdiff
Fast & Smart ServerErrorDebug Responce
authoravl <alex.litovchenko@gmail.com>
Sun, 14 Sep 2008 01:18:17 +0000 (04:18 +0300)
committeravl <alex.litovchenko@gmail.com>
Sun, 14 Sep 2008 01:18:17 +0000 (04:18 +0300)
ipf/http/response/servererrordebug.php
ipf/utils.php

index d4374cb9abde5188753312f5f658f50b5ec6f71b..f300c7307be13f6a693b18fefcadc99814313692 100644 (file)
@@ -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)
             <tbody>';
             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 .= '
                 <tr>
                   <td>'.$o($k).'</td>
                   <td>'.$o($name).'</td>
                   <td class="code">
-                    <div>'.highlight_string(print_r($v,true), true).'</div>
+                    <div>'.highlight_string($value, true).'</div>
                   </td>
                 </tr>';
             }
index 12a0642158576946b2445349925a66a9f6b2885a..54da745f7548015d5e35fd14eec164b5ab0f4d73 100644 (file)
@@ -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;
+    }
+    
 }