diff options
author | Urban Müller | 2023-01-17 20:09:06 +0100 |
---|---|---|
committer | Urban Müller | 2023-01-17 20:09:06 +0100 |
commit | fadbe60cb25afb17777d5180e41ad7593fa25b97 (patch) | |
tree | 467403a4c374efae501b85720249b2901a70aa61 | |
parent | 3e6c8e296d3337e54bf96ef15477453937bc0d09 (diff) | |
download | itools-fadbe60cb25afb17777d5180e41ad7593fa25b97.tar.gz itools-fadbe60cb25afb17777d5180e41ad7593fa25b97.tar.bz2 itools-fadbe60cb25afb17777d5180e41ad7593fa25b97.zip |
better location for backslash removal; omit faulty blanks around class body
-rw-r--r-- | it_debug.class | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/it_debug.class b/it_debug.class index c1ee8e1..766a82f 100644 --- a/it_debug.class +++ b/it_debug.class @@ -170,17 +170,17 @@ static function dump($args, $p = []) $var = array_shift($argnames); $item = gettype($arg) == 'resource' || is_array($arg) && isset($arg['GLOBALS']) || is_object($arg) && is_a($arg, "SimpleXMLElement") ? trim(print_r($arg, true)) : trim(var_export($arg, true)); - # Replace PHP 5 var_export object representation by old style + # Replace PHP 5+ var_export object representation by old readable style while (preg_match("#(.*\b)(\w+)::__set_state\(array\(([^()]+)\)\)(.*)#s", $item, $regs) && ++$iterations < 100) { list (, $head, $classname, $values, $tail) = $regs; $classname = strtolower($classname); $values = preg_replace("#'(\w+)' =>\s*([^\n]+),#", 'var \$$1 = $2;', $values); - $item = $head . "class $classname { $values }$tail"; + $item = rtrim($head, '\\') . "class $classname {" . $values . "}" . $tail; } $item = preg_replace_callback('/\b(1[2-9]\d\d\d\d\d\d\d\d)\b(.*)/', function($m) { return $m[1] . $m[2] . " # " . date('Y-m-d H:i:s', $m[1]); }, $item); - $item = preg_replace("#(=>?)\s*\n\s*\\\?(array|class|\w+::)#", '$1 $2', $item); # array( and class on same line as key + $item = preg_replace("#(=>?)\s*\n\s*(array|class)#", '$1 $2', $item); # array( and class on same line as key $item = preg_replace_callback('#array \(\s+([^(){};]{1,100}),\s+\)#', function($m) { return "array (" . preg_replace("#\n\s+#", " ", $m[1]) . ")"; }, $item); # short arrays on 1 line $item = preg_replace('#class (\S+) \{\s+([^({,;]+;)?\s+\}#', 'class $1 { $2 }', $item); # 1-element objects on 1 line #$item = preg_replace('#\{\s*var \$attr#', '{ var $attr', $item); # move $attr on same line |