From 2099d5ec525e4806f91ec0b62be78692251b5d09 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 4 Apr 2007 16:48:01 +0000 Subject: Replace PHP 5 var_export object representation by old style (incomplete) --- debug.class | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- cgit v1.2.3