Skip to content
Permalink
Browse files

Dumper: fixed dumping empty array in snapshot [Closes #367]

  • Loading branch information...
dg committed May 29, 2019
1 parent 5fd894f commit 7641fee1f44f2c9ad58bca2aca5728c9fe2f2e8a
Showing with 10 additions and 1 deletion.
  1. +1 −1 src/Tracy/Dumper/Dumper.php
  2. +9 −0 tests/Tracy/Dumper.toHtml().snapshot.phpt
@@ -412,7 +412,7 @@ private function toJson(&$var, array $options = [], int $level = 0)
return $this->encodeString($var, $this->maxLength);
} elseif (is_array($var)) {
if (($rec = in_array($var, $options['parents'] ?? [], true)) || $level >= $this->maxDepth) {
if (count($var) && (($rec = in_array($var, $options['parents'] ?? [], true)) || $level >= $this->maxDepth)) {
return ['stop' => [count($var), $rec]];
}
$res = [];
@@ -158,6 +158,15 @@ Assert::match(
);
Assert::same([], $snapshot);
$arr = [1, [2, [3, [4, []]]], 3];
Assert::match(
'<pre class="tracy-dump" data-tracy-dump=\'[[0,1],[1,[[0,2],[1,[[0,3],[1,[[0,4],[1,[]]]]]]]],[2,3]]\'></pre>',
Dumper::toHtml($arr, $options)
);
Assert::same([], $snapshot);
$obj = new stdClass;
$obj->a = new stdClass;
$obj->a->b = new stdClass;

0 comments on commit 7641fee

Please sign in to comment.
You can’t perform that action at this time.