Skip to content

Commit

Permalink
Merge remote-tracking branch 'patchwork-php-logger/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Sep 3, 2012
2 parents 0c7064f + 1a75a04 commit 4a56b87
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions core/logger/class/Patchwork/PHP/Dumper.php
Expand Up @@ -23,11 +23,12 @@ abstract class Dumper extends Walker
{
public

$maxLength = 100,
$maxLength = 1000,
$maxDepth = 10;

protected

$dumpLength = 0,
$depthLimited = array(),
$reserved = array('_' => 1, '__cutBy' => 1, '__refs' => 1, '__proto__' => 1),
$callbacks = array(
Expand Down Expand Up @@ -89,7 +90,7 @@ protected function dumpResource($res)

protected function dumpRef($is_soft, $ref_counter = null, &$ref_value = null)
{
if (null !== $ref_value && isset($this->depthLimited[$ref_counter]) && $this->depth !== $this->maxDepth)
if (null !== $ref_value && isset($this->depthLimited[$ref_counter]) && $this->depth < $this->maxDepth)
{
unset($this->depthLimited[$ref_counter]);

Expand All @@ -115,7 +116,7 @@ protected function walkHash($type, &$a)
$len = count($a);
isset($a[self::$token]) && --$len;

if ($len && $this->depth === $this->maxDepth && 0 < $this->maxDepth)
if ($len && $this->depth >= $this->maxDepth && 0 < $this->maxDepth)
{
$this->depthLimited[$this->counter] = 1;

Expand All @@ -129,16 +130,25 @@ protected function walkHash($type, &$a)

if (!$len) return array();

$i = 0;
++$this->depth;
if (false !== strpos($type, ':')) unset($type);

if (0 >= $this->maxLength) $len = -1;
else if ($this->dumpLength >= $this->maxLength) $i = $max = $this->maxLength;
else
{
$i = $this->dumpLength;
$max = $this->maxLength;
$this->dumpLength += $len;
$len = $i - $max;
}

foreach ($a as $k => &$a)
{
if ($k === self::$token) continue;
else if ($i === $this->maxLength && 0 < $this->maxLength)
else if ($len >= 0 && $i++ === $max)
{
if ($len -= $i)
if ($len)
{
$this->dumpString('__cutBy', true);
$this->dumpScalar($len);
Expand All @@ -151,7 +161,6 @@ protected function walkHash($type, &$a)

$this->dumpString($k, true);
$this->walkRef($a);
++$i;
}

if (--$this->depth) return array();
Expand Down

0 comments on commit 4a56b87

Please sign in to comment.