Skip to content
Permalink
Browse files

Dumper: hidden values are rendered with variable type [Closes #380]

  • Loading branch information...
dg committed Aug 30, 2019
1 parent a6aaefb commit 44349212f8856cf1cacb0ab2b62c2b30e4be6f93
Showing with 18 additions and 6 deletions.
  1. +18 −6 src/Tracy/Dumper/Dumper.php
@@ -297,10 +297,13 @@ private function dumpArray(&$var, array $options, int $level): string
$out = $span . '>' . $out . count($var) . ")</span>\n" . '<div' . ($collapsed ? ' class="tracy-collapsed"' : '') . '>';
$options['parents'][] = $var;
foreach ($var as $k => &$v) {
$hide = is_string($k) && isset($this->keysToHide[strtolower($k)]) ? self::HIDDEN_VALUE : null;
$hide = is_string($k) && isset($this->keysToHide[strtolower($k)]);
$out .= '<span class="tracy-dump-indent"> ' . str_repeat('| ', $level) . '</span>'
. '<span class="tracy-dump-key">' . Helpers::escapeHtml($this->encodeKey($k)) . '</span> => '
. ($hide ? $this->dumpString($hide) : $this->dumpVar($v, $options, $level + 1));
. ($hide
? Helpers::escapeHtml(self::hideValue($v)) . "\n"
: $this->dumpVar($v, $options, $level + 1)
);
}
array_pop($options['parents']);
@@ -361,10 +364,13 @@ private function dumpObject(&$var, array $options, int $level): string
$vis = ' <span class="tracy-dump-visibility">' . ($k[1] === '*' ? 'protected' : 'private') . '</span>';
$k = substr($k, strrpos($k, "\x00") + 1);
}
$hide = is_string($k) && isset($this->keysToHide[strtolower($k)]) ? self::HIDDEN_VALUE : null;
$hide = is_string($k) && isset($this->keysToHide[strtolower($k)]);
$out .= '<span class="tracy-dump-indent"> ' . str_repeat('| ', $level) . '</span>'
. '<span class="tracy-dump-key">' . Helpers::escapeHtml($this->encodeKey($k)) . "</span>$vis => "
. ($hide ? $this->dumpString($hide) : $this->dumpVar($v, $options, $level + 1));
. ($hide
? Helpers::escapeHtml(self::hideValue($v)) . "\n"
: $this->dumpVar($v, $options, $level + 1)
);
}
array_pop($options['parents']);
@@ -419,7 +425,7 @@ private function toJson(&$var, array $options = [], int $level = 0)
$options['parents'][] = $var;
foreach ($var as $k => &$v) {
$hide = is_string($k) && isset($this->keysToHide[strtolower($k)]);
$res[] = [$this->encodeKey($k), $hide ? self::HIDDEN_VALUE : $this->toJson($v, $options, $level + 1)];
$res[] = [$this->encodeKey($k), $hide ? ['type' => self::hideValue($v)] : $this->toJson($v, $options, $level + 1)];
}
array_pop($options['parents']);
return $res;
@@ -456,7 +462,7 @@ private function toJson(&$var, array $options = [], int $level = 0)
$k = substr($k, strrpos($k, "\x00") + 1);
}
$hide = is_string($k) && isset($this->keysToHide[strtolower($k)]);
$obj['items'][] = [$this->encodeKey($k), $hide ? self::HIDDEN_VALUE : $this->toJson($v, $options, $level + 1), $vis];
$obj['items'][] = [$this->encodeKey($k), $hide ? ['type' => self::hideValue($v)] : $this->toJson($v, $options, $level + 1), $vis];
}
}
return ['object' => $obj['id']];
@@ -619,6 +625,12 @@ private static function exportPhpIncompleteClass(\__PHP_Incomplete_Class $obj):
}
private static function hideValue($var): string
{
return self::HIDDEN_VALUE . ' (' . (is_object($var) ? Helpers::getClass($var) : gettype($var)) . ')';
}
/**
* Finds the location where dump was called. Returns [file, line, code]
*/

0 comments on commit 4434921

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