Skip to content

Commit

Permalink
fix backtrace parsing of dumped value
Browse files Browse the repository at this point in the history
  • Loading branch information
leeoniya committed May 18, 2015
1 parent b524591 commit 6cae2c8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/dump_r/Core.php
Expand Up @@ -23,9 +23,16 @@ public static function dump_r(&$raw, $ret = false, $html = true, $depth = 1e3, $
$idx = strpos($src[0]['file'], 'dump_r.php') ? 1 : 0;
$src = (object)$src[$idx];
$file = file($src->file);
$line = $file[$src->line - 1];
preg_match('/dump_r\((.+?)(?:,|\)(;|\?>))/', $line, $m);
$key = $m[1]; // fixme!

$i = 1;
do {
$line = $file[$src->line - $i++];
} while (strpos($line, 'dump_r') === false);

preg_match('/dump_r\((.+?)\)?(?:$|;|\?>)/', $line, $m);
$key = $m[1];

$key = trim(explode(',', $key)[0]);

if (PHP_SAPI == 'cli' || !$html)
$out = $root->text0($src->file, $src->line, $key);
Expand Down

0 comments on commit 6cae2c8

Please sign in to comment.