summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debug.class10
1 files changed, 10 insertions, 0 deletions
diff --git a/debug.class b/debug.class
index e33a339..1be631b 100644
--- a/debug.class
+++ b/debug.class
@@ -141,6 +141,16 @@ function dump()
continue;
$item = gettype($arg) == 'resource' ? trim(print_r($arg, true)) : trim(var_export($arg, true));
+
+ # Replace PHP 5 var_export object representation by old style
+ while (preg_match("#(.*\b)(\w+)::__set_state\(array\(([^()]+)\)\)(.*)#s", $item, $regs))
+ {
+ list (, $head, $classname, $values, $tail) = $regs;
+ $classname = strtolower($classname);
+ $values = preg_replace("#'(\w+)' =>([^\n]+),#", 'var \$$1 = $2;', $values);
+ $item = $head . "class $classname { $values }$tail";
+ }
+
$item = preg_replace("#(=>?)\s*\n\s*(array|class)#", '$1 $2', $item); # array( and class on same line as key
$item = preg_replace('#array \(\s+([^({,;]+),\s+\)#', 'array( $1 )', $item); # 1-element arrays on 1 line
$item = preg_replace('#class (\S+) \{\s+([^({,;]+;)?\s+\}#', 'class $1 { $2 }', $item); # 1-element objects on 1 line