Skip to content

Commit

Permalink
Dumper: disabled HASH disables "see above/see below"
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Apr 28, 2022
1 parent d6261b5 commit d9c2e36
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Tracy/Dumper/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,10 @@ private function renderArray($array, int $depth): string
$ref = new Value(Value::TYPE_REF, $array->id);
$this->copySnapshot($ref);
return '<span class="tracy-toggle tracy-collapsed" data-tracy-dump=\'' . json_encode($ref) . "'>" . $out . '</span>';
}

return $out . (isset($this->above[$array->id]) ? ' <i>see above</i>' : ' <i>see below</i>');
} elseif ($this->hash) {
return $out . (isset($this->above[$array->id]) ? ' <i>see above</i>' : ' <i>see below</i>');
}
}
}

Expand Down Expand Up @@ -364,9 +365,10 @@ private function renderObject(Value $object, int $depth): string
$ref = new Value(Value::TYPE_REF, $object->id);
$this->copySnapshot($ref);
return '<span class="tracy-toggle tracy-collapsed" data-tracy-dump=\'' . json_encode($ref) . "'>" . $out . '</span>';
}

return $out . (isset($this->above[$object->id]) ? ' <i>see above</i>' : ' <i>see below</i>');
} elseif ($this->hash) {
return $out . (isset($this->above[$object->id]) ? ' <i>see above</i>' : ' <i>see below</i>');
}
}

$collapsed = $object->collapsed ?? ($depth
Expand Down
13 changes: 13 additions & 0 deletions tests/Tracy/Dumper.toText().nohash.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,16 @@ stdClass
z: stdClass RECURSION
XX
, Dumper::toText($arr, [Dumper::HASH => false]));


$obj = (object) ['a' => 1];
Assert::match(<<<'XX'
array (3)
0 => stdClass
| a: 1
1 => stdClass
| a: 1
2 => stdClass
| a: 1
XX
, Dumper::toText([$obj, $obj, $obj], [Dumper::HASH => false]));

0 comments on commit d9c2e36

Please sign in to comment.