package and depencies
This commit is contained in:
@@ -31,11 +31,11 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
protected $line = '';
|
||||
protected $lineDumper;
|
||||
protected $outputStream;
|
||||
protected $decimalPoint; // This is locale dependent
|
||||
protected $decimalPoint = '.';
|
||||
protected $indentPad = ' ';
|
||||
protected $flags;
|
||||
|
||||
private $charset = '';
|
||||
private string $charset = '';
|
||||
|
||||
/**
|
||||
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput
|
||||
@@ -46,7 +46,6 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
{
|
||||
$this->flags = $flags;
|
||||
$this->setCharset($charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8');
|
||||
$this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point'];
|
||||
$this->setOutput($output ?: static::$defaultOutput);
|
||||
if (!$output && \is_string(static::$defaultOutput)) {
|
||||
static::$defaultOutput = $this->outputStream;
|
||||
@@ -72,7 +71,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
$output = fopen($output, 'w');
|
||||
}
|
||||
$this->outputStream = $output;
|
||||
$this->lineDumper = [$this, 'echoLine'];
|
||||
$this->lineDumper = $this->echoLine(...);
|
||||
}
|
||||
|
||||
return $prev;
|
||||
@@ -83,7 +82,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
*
|
||||
* @return string The previous charset
|
||||
*/
|
||||
public function setCharset(string $charset)
|
||||
public function setCharset(string $charset): string
|
||||
{
|
||||
$prev = $this->charset;
|
||||
|
||||
@@ -102,7 +101,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
*
|
||||
* @return string The previous indent pad
|
||||
*/
|
||||
public function setIndentPad(string $pad)
|
||||
public function setIndentPad(string $pad): string
|
||||
{
|
||||
$prev = $this->indentPad;
|
||||
$this->indentPad = $pad;
|
||||
@@ -117,10 +116,8 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
*
|
||||
* @return string|null The dump as string when $output is true
|
||||
*/
|
||||
public function dump(Data $data, $output = null)
|
||||
public function dump(Data $data, $output = null): ?string
|
||||
{
|
||||
$this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point'];
|
||||
|
||||
if ($locale = $this->flags & (self::DUMP_COMMA_SEPARATOR | self::DUMP_TRAILING_COMMA) ? setlocale(\LC_NUMERIC, 0) : null) {
|
||||
setlocale(\LC_NUMERIC, 'C');
|
||||
}
|
||||
@@ -177,10 +174,8 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
|
||||
/**
|
||||
* Converts a non-UTF-8 string to UTF-8.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function utf8Encode(?string $s)
|
||||
protected function utf8Encode(?string $s): ?string
|
||||
{
|
||||
if (null === $s || preg_match('//u', $s)) {
|
||||
return $s;
|
||||
|
74
vendor/symfony/var-dumper/Dumper/CliDumper.php
vendored
74
vendor/symfony/var-dumper/Dumper/CliDumper.php
vendored
@@ -55,15 +55,12 @@ class CliDumper extends AbstractDumper
|
||||
protected $collapseNextHash = false;
|
||||
protected $expandNextHash = false;
|
||||
|
||||
private $displayOptions = [
|
||||
private array $displayOptions = [
|
||||
'fileLinkFormat' => null,
|
||||
];
|
||||
|
||||
private $handlesHrefGracefully;
|
||||
private bool $handlesHrefGracefully;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($output = null, string $charset = null, int $flags = 0)
|
||||
{
|
||||
parent::__construct($output, $charset, $flags);
|
||||
@@ -122,10 +119,7 @@ class CliDumper extends AbstractDumper
|
||||
$this->displayOptions = $displayOptions + $this->displayOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dumpScalar(Cursor $cursor, string $type, $value)
|
||||
public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|null $value)
|
||||
{
|
||||
$this->dumpKey($cursor);
|
||||
|
||||
@@ -153,17 +147,12 @@ class CliDumper extends AbstractDumper
|
||||
$style = 'float';
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case \INF === $value: $value = 'INF'; break;
|
||||
case -\INF === $value: $value = '-INF'; break;
|
||||
case is_nan($value): $value = 'NAN'; break;
|
||||
default:
|
||||
$value = (string) $value;
|
||||
if (!str_contains($value, $this->decimalPoint)) {
|
||||
$value .= $this->decimalPoint.'0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
$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':
|
||||
@@ -185,9 +174,6 @@ class CliDumper extends AbstractDumper
|
||||
$this->endValue($cursor);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
|
||||
{
|
||||
$this->dumpKey($cursor);
|
||||
@@ -204,7 +190,7 @@ class CliDumper extends AbstractDumper
|
||||
'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
|
||||
'binary' => $bin,
|
||||
];
|
||||
$str = $bin && false !== strpos($str, "\0") ? [$str] : explode("\n", $str);
|
||||
$str = $bin && str_contains($str, "\0") ? [$str] : explode("\n", $str);
|
||||
if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) {
|
||||
unset($str[1]);
|
||||
$str[0] .= "\n";
|
||||
@@ -273,14 +259,9 @@ class CliDumper extends AbstractDumper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild)
|
||||
public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild)
|
||||
{
|
||||
if (null === $this->colors) {
|
||||
$this->colors = $this->supportsColors();
|
||||
}
|
||||
$this->colors ??= $this->supportsColors();
|
||||
|
||||
$this->dumpKey($cursor);
|
||||
$attr = $cursor->attr;
|
||||
@@ -314,10 +295,7 @@ class CliDumper extends AbstractDumper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut)
|
||||
public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut)
|
||||
{
|
||||
if (empty($cursor->attr['cut_hash'])) {
|
||||
$this->dumpEllipsis($cursor, $hasChild, $cut);
|
||||
@@ -434,19 +412,13 @@ class CliDumper extends AbstractDumper
|
||||
* @param string $style The type of style being applied
|
||||
* @param string $value The value being styled
|
||||
* @param array $attr Optional context information
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function style(string $style, string $value, array $attr = [])
|
||||
protected function style(string $style, string $value, array $attr = []): string
|
||||
{
|
||||
if (null === $this->colors) {
|
||||
$this->colors = $this->supportsColors();
|
||||
}
|
||||
$this->colors ??= $this->supportsColors();
|
||||
|
||||
if (null === $this->handlesHrefGracefully) {
|
||||
$this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
|
||||
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
|
||||
}
|
||||
$this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
|
||||
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
|
||||
|
||||
if (isset($attr['ellipsis'], $attr['ellipsis-type'])) {
|
||||
$prefix = substr($value, 0, -$attr['ellipsis']);
|
||||
@@ -510,10 +482,7 @@ class CliDumper extends AbstractDumper
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function supportsColors()
|
||||
protected function supportsColors(): bool
|
||||
{
|
||||
if ($this->outputStream !== static::$defaultOutput) {
|
||||
return $this->hasColorSupport($this->outputStream);
|
||||
@@ -552,9 +521,6 @@ class CliDumper extends AbstractDumper
|
||||
return static::$defaultColors = $this->hasColorSupport($h);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function dumpLine(int $depth, bool $endOfValue = false)
|
||||
{
|
||||
if ($this->colors) {
|
||||
@@ -585,10 +551,8 @@ class CliDumper extends AbstractDumper
|
||||
*
|
||||
* Reference: Composer\XdebugHandler\Process::supportsColor
|
||||
* https://github.com/composer/xdebug-handler
|
||||
*
|
||||
* @param mixed $stream A CLI output stream
|
||||
*/
|
||||
private function hasColorSupport($stream): bool
|
||||
private function hasColorSupport(mixed $stream): bool
|
||||
{
|
||||
if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
|
||||
return false;
|
||||
|
@@ -22,8 +22,8 @@ use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
*/
|
||||
final class RequestContextProvider implements ContextProviderInterface
|
||||
{
|
||||
private $requestStack;
|
||||
private $cloner;
|
||||
private RequestStack $requestStack;
|
||||
private VarCloner $cloner;
|
||||
|
||||
public function __construct(RequestStack $requestStack)
|
||||
{
|
||||
|
@@ -25,10 +25,10 @@ use Twig\Template;
|
||||
*/
|
||||
final class SourceContextProvider implements ContextProviderInterface
|
||||
{
|
||||
private $limit;
|
||||
private $charset;
|
||||
private $projectDir;
|
||||
private $fileLinkFormatter;
|
||||
private int $limit;
|
||||
private ?string $charset;
|
||||
private ?string $projectDir;
|
||||
private ?FileLinkFormatter $fileLinkFormatter;
|
||||
|
||||
public function __construct(string $charset = null, string $projectDir = null, FileLinkFormatter $fileLinkFormatter = null, int $limit = 9)
|
||||
{
|
||||
|
@@ -19,8 +19,8 @@ use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface;
|
||||
*/
|
||||
class ContextualizedDumper implements DataDumperInterface
|
||||
{
|
||||
private $wrappedDumper;
|
||||
private $contextProviders;
|
||||
private DataDumperInterface $wrappedDumper;
|
||||
private array $contextProviders;
|
||||
|
||||
/**
|
||||
* @param ContextProviderInterface[] $contextProviders
|
||||
@@ -35,7 +35,7 @@ class ContextualizedDumper implements DataDumperInterface
|
||||
{
|
||||
$context = [];
|
||||
foreach ($this->contextProviders as $contextProvider) {
|
||||
$context[\get_class($contextProvider)] = $contextProvider->getContext();
|
||||
$context[$contextProvider::class] = $contextProvider->getContext();
|
||||
}
|
||||
|
||||
$this->wrappedDumper->dump($data->withContext($context));
|
||||
|
36
vendor/symfony/var-dumper/Dumper/HtmlDumper.php
vendored
36
vendor/symfony/var-dumper/Dumper/HtmlDumper.php
vendored
@@ -67,16 +67,13 @@ class HtmlDumper extends CliDumper
|
||||
protected $lastDepth = -1;
|
||||
protected $styles;
|
||||
|
||||
private $displayOptions = [
|
||||
private array $displayOptions = [
|
||||
'maxDepth' => 1,
|
||||
'maxStringLength' => 160,
|
||||
'fileLinkFormat' => null,
|
||||
];
|
||||
private $extraDisplayOptions = [];
|
||||
private array $extraDisplayOptions = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($output = null, string $charset = null, int $flags = 0)
|
||||
{
|
||||
AbstractDumper::__construct($output, $charset, $flags);
|
||||
@@ -85,9 +82,6 @@ class HtmlDumper extends CliDumper
|
||||
$this->styles = static::$themes['dark'] ?? self::$themes['dark'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setStyles(array $styles)
|
||||
{
|
||||
$this->headerIsDumped = false;
|
||||
@@ -131,10 +125,7 @@ class HtmlDumper extends CliDumper
|
||||
$this->dumpSuffix = $suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(Data $data, $output = null, array $extraDisplayOptions = [])
|
||||
public function dump(Data $data, $output = null, array $extraDisplayOptions = []): ?string
|
||||
{
|
||||
$this->extraDisplayOptions = $extraDisplayOptions;
|
||||
$result = parent::dump($data, $output);
|
||||
@@ -782,9 +773,6 @@ EOHTML
|
||||
return $this->dumpHeader = preg_replace('/\s+/', ' ', $line).'</style>'.$this->dumpHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
|
||||
{
|
||||
if ('' === $str && isset($cursor->attr['img-data'], $cursor->attr['content-type'])) {
|
||||
@@ -800,10 +788,7 @@ EOHTML
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild)
|
||||
public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild)
|
||||
{
|
||||
if (Cursor::HASH_OBJECT === $type) {
|
||||
$cursor->attr['depth'] = $cursor->depth;
|
||||
@@ -831,10 +816,7 @@ EOHTML
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function leaveHash(Cursor $cursor, int $type, $class, bool $hasChild, int $cut)
|
||||
public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut)
|
||||
{
|
||||
$this->dumpEllipsis($cursor, $hasChild, $cut);
|
||||
if ($hasChild) {
|
||||
@@ -843,10 +825,7 @@ EOHTML
|
||||
parent::leaveHash($cursor, $type, $class, $hasChild, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function style(string $style, string $value, array $attr = [])
|
||||
protected function style(string $style, string $value, array $attr = []): string
|
||||
{
|
||||
if ('' === $value) {
|
||||
return '';
|
||||
@@ -938,9 +917,6 @@ EOHTML
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function dumpLine(int $depth, bool $endOfValue = false)
|
||||
{
|
||||
if (-1 === $this->lastDepth) {
|
||||
|
@@ -22,8 +22,8 @@ use Symfony\Component\VarDumper\Server\Connection;
|
||||
*/
|
||||
class ServerDumper implements DataDumperInterface
|
||||
{
|
||||
private $connection;
|
||||
private $wrappedDumper;
|
||||
private Connection $connection;
|
||||
private ?DataDumperInterface $wrappedDumper;
|
||||
|
||||
/**
|
||||
* @param string $host The server host
|
||||
@@ -41,9 +41,6 @@ class ServerDumper implements DataDumperInterface
|
||||
return $this->connection->getContextProviders();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(Data $data)
|
||||
{
|
||||
if (!$this->connection->write($data) && $this->wrappedDumper) {
|
||||
|
Reference in New Issue
Block a user