function CliDumper::dumpKey
Dumps a key in a hash structure.
4 calls to CliDumper::dumpKey()
- CliDumper::dumpScalar in vendor/
symfony/ var-dumper/ Dumper/ CliDumper.php - Dumps a scalar value.
- CliDumper::dumpString in vendor/
symfony/ var-dumper/ Dumper/ CliDumper.php - Dumps a string.
- CliDumper::enterHash in vendor/
symfony/ var-dumper/ Dumper/ CliDumper.php - Dumps while entering an hash.
- HtmlDumper::dumpString in vendor/
symfony/ var-dumper/ Dumper/ HtmlDumper.php - Dumps a string.
File
-
vendor/
symfony/ var-dumper/ Dumper/ CliDumper.php, line 345
Class
- CliDumper
- CliDumper dumps variables for command line output.
Namespace
Symfony\Component\VarDumper\DumperCode
protected function dumpKey(Cursor $cursor) : void {
if (null !== ($key = $cursor->hashKey)) {
if ($cursor->hashKeyIsBinary) {
$key = $this->utf8Encode($key);
}
$attr = [
'binary' => $cursor->hashKeyIsBinary,
'virtual' => $cursor->attr['virtual'] ?? false,
];
$bin = $cursor->hashKeyIsBinary ? 'b' : '';
$style = 'key';
switch ($cursor->hashType) {
default:
case Cursor::HASH_INDEXED:
if (self::DUMP_LIGHT_ARRAY & $this->flags) {
break;
}
$style = 'index';
// no break
case Cursor::HASH_ASSOC:
if (\is_int($key)) {
$this->line .= $this->style($style, $key) . ' => ';
}
else {
$this->line .= $bin . '"' . $this->style($style, $key) . '" => ';
}
break;
case Cursor::HASH_RESOURCE:
$key = "\x00~\x00" . $key;
// no break
case Cursor::HASH_OBJECT:
if (!isset($key[0]) || "\x00" !== $key[0]) {
$this->line .= '+' . $bin . $this->style('public', $key, $attr) . ': ';
}
elseif (0 < strpos($key, "\x00", 1)) {
$key = explode("\x00", substr($key, 1), 2);
switch ($key[0][0]) {
case '+':
// User inserted keys
$attr['dynamic'] = true;
$this->line .= '+' . $bin . '"' . $this->style('public', $key[1], $attr) . '": ';
break 2;
case '~':
$style = 'meta';
if (isset($key[0][1])) {
parse_str(substr($key[0], 1), $attr);
$attr += [
'binary' => $cursor->hashKeyIsBinary,
];
}
break;
case '*':
$style = 'protected';
$bin = '#' . $bin;
break;
default:
$attr['class'] = $key[0];
$style = 'private';
$bin = '-' . $bin;
break;
}
if (isset($attr['collapse'])) {
if ($attr['collapse']) {
$this->collapseNextHash = true;
}
else {
$this->expandNextHash = true;
}
}
$this->line .= $bin . $this->style($style, $key[1], $attr) . ($attr['separator'] ?? ': ');
}
else {
// This case should not happen
$this->line .= '-' . $bin . '"' . $this->style('private', $key, [
'class' => '',
]) . '": ';
}
break;
}
if ($cursor->hardRefTo) {
$this->line .= $this->style('ref', '&' . ($cursor->hardRefCount ? $cursor->hardRefTo : ''), [
'count' => $cursor->hardRefCount,
]) . ' ';
}
}
}