function CliDumper::dumpScalar
Overrides DumperInterface::dumpScalar
File
-
vendor/
symfony/ var-dumper/ Dumper/ CliDumper.php, line 126
Class
- CliDumper
- CliDumper dumps variables for command line output.
Namespace
Symfony\Component\VarDumper\DumperCode
public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|null $value) : void {
$this->dumpKey($cursor);
$this->collapseNextHash = $this->expandNextHash = false;
$style = 'const';
$attr = $cursor->attr;
switch ($type) {
case 'default':
$style = 'default';
break;
case 'label':
$this->styles += [
'label' => $this->styles['default'],
];
$style = 'label';
break;
case 'integer':
$style = 'num';
if (isset($this->styles['integer'])) {
$style = 'integer';
}
break;
case 'double':
$style = 'num';
if (isset($this->styles['float'])) {
$style = 'float';
}
$value = match (true) { \INF === $value => 'INF',
-\INF === $value => '-INF',
is_nan($value) => 'NAN',
default => !str_contains($value = (string) $value, $this->decimalPoint) ? $value .= $this->decimalPoint . '0' : $value,
};
break;
case 'NULL':
$value = 'null';
break;
case 'boolean':
$value = $value ? 'true' : 'false';
break;
default:
$attr += [
'value' => $this->utf8Encode($value),
];
$value = $this->utf8Encode($type);
break;
}
$this->line .= $this->style($style, $value, $attr);
$this->endValue($cursor);
}