update patch 1
This commit is contained in:
+5
-4
@@ -36,7 +36,6 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
protected $outputStream;
|
||||
protected string $decimalPoint = '.';
|
||||
protected string $indentPad = ' ';
|
||||
protected int $flags;
|
||||
|
||||
private string $charset = '';
|
||||
|
||||
@@ -45,9 +44,11 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
* @param string|null $charset The default character encoding to use for non-UTF8 strings
|
||||
* @param int $flags A bit field of static::DUMP_* constants to fine tune dumps representation
|
||||
*/
|
||||
public function __construct($output = null, ?string $charset = null, int $flags = 0)
|
||||
{
|
||||
$this->flags = $flags;
|
||||
public function __construct(
|
||||
$output = null,
|
||||
?string $charset = null,
|
||||
protected int $flags = 0,
|
||||
) {
|
||||
$this->setCharset($charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8');
|
||||
$this->setOutput($output ?: static::$defaultOutput);
|
||||
if (!$output && \is_string(static::$defaultOutput)) {
|
||||
|
||||
+20
-8
@@ -33,12 +33,13 @@ class CliDumper extends AbstractDumper
|
||||
'default' => '0;38;5;208',
|
||||
'num' => '1;38;5;38',
|
||||
'const' => '1;38;5;208',
|
||||
'virtual' => '3',
|
||||
'str' => '1;38;5;113',
|
||||
'note' => '38;5;38',
|
||||
'ref' => '38;5;247',
|
||||
'public' => '',
|
||||
'protected' => '',
|
||||
'private' => '',
|
||||
'public' => '39',
|
||||
'protected' => '39',
|
||||
'private' => '39',
|
||||
'meta' => '38;5;170',
|
||||
'key' => '38;5;113',
|
||||
'index' => '38;5;38',
|
||||
@@ -347,7 +348,10 @@ class CliDumper extends AbstractDumper
|
||||
if ($cursor->hashKeyIsBinary) {
|
||||
$key = $this->utf8Encode($key);
|
||||
}
|
||||
$attr = ['binary' => $cursor->hashKeyIsBinary];
|
||||
$attr = [
|
||||
'binary' => $cursor->hashKeyIsBinary,
|
||||
'virtual' => $cursor->attr['virtual'] ?? false,
|
||||
];
|
||||
$bin = $cursor->hashKeyIsBinary ? 'b' : '';
|
||||
$style = 'key';
|
||||
switch ($cursor->hashType) {
|
||||
@@ -371,7 +375,7 @@ class CliDumper extends AbstractDumper
|
||||
// no break
|
||||
case Cursor::HASH_OBJECT:
|
||||
if (!isset($key[0]) || "\0" !== $key[0]) {
|
||||
$this->line .= '+'.$bin.$this->style('public', $key).': ';
|
||||
$this->line .= '+'.$bin.$this->style('public', $key, $attr).': ';
|
||||
} elseif (0 < strpos($key, "\0", 1)) {
|
||||
$key = explode("\0", substr($key, 1), 2);
|
||||
|
||||
@@ -459,7 +463,7 @@ class CliDumper extends AbstractDumper
|
||||
$s = $startCchr;
|
||||
$c = $c[$i = 0];
|
||||
do {
|
||||
$s .= $map[$c[$i]] ?? sprintf('\x%02X', \ord($c[$i]));
|
||||
$s .= $map[$c[$i]] ?? \sprintf('\x%02X', \ord($c[$i]));
|
||||
} while (isset($c[++$i]));
|
||||
|
||||
return $s.$endCchr;
|
||||
@@ -506,6 +510,9 @@ class CliDumper extends AbstractDumper
|
||||
if ('label' === $style && '' !== $value) {
|
||||
$value .= ' ';
|
||||
}
|
||||
if ($this->colors && ($attr['virtual'] ?? false)) {
|
||||
$value = "\033[{$this->styles['virtual']}m".$value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
@@ -552,7 +559,7 @@ class CliDumper extends AbstractDumper
|
||||
protected function dumpLine(int $depth, bool $endOfValue = false): void
|
||||
{
|
||||
if ($this->colors ??= $this->supportsColors()) {
|
||||
$this->line = sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line);
|
||||
$this->line = \sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line);
|
||||
}
|
||||
parent::dumpLine($depth);
|
||||
}
|
||||
@@ -591,6 +598,11 @@ class CliDumper extends AbstractDumper
|
||||
return false;
|
||||
}
|
||||
|
||||
// Follow https://force-color.org/
|
||||
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Detect msysgit/mingw and assume this is a tty because detection
|
||||
// does not work correctly, see https://github.com/composer/composer/issues/9690
|
||||
if (!@stream_isatty($stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
|
||||
@@ -632,7 +644,7 @@ class CliDumper extends AbstractDumper
|
||||
|| 'Hyper' === getenv('TERM_PROGRAM');
|
||||
|
||||
if (!$result) {
|
||||
$version = sprintf(
|
||||
$version = \sprintf(
|
||||
'%s.%s.%s',
|
||||
PHP_WINDOWS_VERSION_MAJOR,
|
||||
PHP_WINDOWS_VERSION_MINOR,
|
||||
|
||||
+3
-4
@@ -22,12 +22,11 @@ use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
*/
|
||||
final class RequestContextProvider implements ContextProviderInterface
|
||||
{
|
||||
private RequestStack $requestStack;
|
||||
private VarCloner $cloner;
|
||||
|
||||
public function __construct(RequestStack $requestStack)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
public function __construct(
|
||||
private RequestStack $requestStack,
|
||||
) {
|
||||
$this->cloner = new VarCloner();
|
||||
$this->cloner->setMaxItems(0);
|
||||
$this->cloner->addCasters(ReflectionCaster::UNSET_CLOSURE_FILE_INFO);
|
||||
|
||||
+6
-11
@@ -25,17 +25,12 @@ use Twig\Template;
|
||||
*/
|
||||
final class SourceContextProvider implements ContextProviderInterface
|
||||
{
|
||||
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)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
$this->projectDir = $projectDir;
|
||||
$this->fileLinkFormatter = $fileLinkFormatter;
|
||||
$this->limit = $limit;
|
||||
public function __construct(
|
||||
private ?string $charset = null,
|
||||
private ?string $projectDir = null,
|
||||
private ?FileLinkFormatter $fileLinkFormatter = null,
|
||||
private int $limit = 9,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getContext(): ?array
|
||||
|
||||
@@ -19,16 +19,13 @@ use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface;
|
||||
*/
|
||||
class ContextualizedDumper implements DataDumperInterface
|
||||
{
|
||||
private DataDumperInterface $wrappedDumper;
|
||||
private array $contextProviders;
|
||||
|
||||
/**
|
||||
* @param ContextProviderInterface[] $contextProviders
|
||||
*/
|
||||
public function __construct(DataDumperInterface $wrappedDumper, array $contextProviders)
|
||||
{
|
||||
$this->wrappedDumper = $wrappedDumper;
|
||||
$this->contextProviders = $contextProviders;
|
||||
public function __construct(
|
||||
private DataDumperInterface $wrappedDumper,
|
||||
private array $contextProviders,
|
||||
) {
|
||||
}
|
||||
|
||||
public function dump(Data $data): ?string
|
||||
|
||||
+23
-18
@@ -29,6 +29,7 @@ class HtmlDumper extends CliDumper
|
||||
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all',
|
||||
'num' => 'font-weight:bold; color:#1299DA',
|
||||
'const' => 'font-weight:bold',
|
||||
'virtual' => 'font-style:italic',
|
||||
'str' => 'font-weight:bold; color:#56DB3A',
|
||||
'note' => 'color:#1299DA',
|
||||
'ref' => 'color:#A0A0A0',
|
||||
@@ -45,6 +46,7 @@ class HtmlDumper extends CliDumper
|
||||
'default' => 'background:none; color:#CC7832; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all',
|
||||
'num' => 'font-weight:bold; color:#1299DA',
|
||||
'const' => 'font-weight:bold',
|
||||
'virtual' => 'font-style:italic',
|
||||
'str' => 'font-weight:bold; color:#629755;',
|
||||
'note' => 'color:#6897BB',
|
||||
'ref' => 'color:#6E6E6E',
|
||||
@@ -91,7 +93,7 @@ class HtmlDumper extends CliDumper
|
||||
public function setTheme(string $themeName): void
|
||||
{
|
||||
if (!isset(static::$themes[$themeName])) {
|
||||
throw new \InvalidArgumentException(sprintf('Theme "%s" does not exist in class "%s".', $themeName, static::class));
|
||||
throw new \InvalidArgumentException(\sprintf('Theme "%s" does not exist in class "%s".', $themeName, static::class));
|
||||
}
|
||||
|
||||
$this->setStyles(static::$themes[$themeName]);
|
||||
@@ -777,7 +779,7 @@ EOHTML
|
||||
$this->line .= $cursor->depth >= $this->displayOptions['maxDepth'] ? ' <samp class=sf-dump-compact>' : ' <samp class=sf-dump-expanded>';
|
||||
$this->endValue($cursor);
|
||||
$this->line .= $this->indentPad;
|
||||
$this->line .= sprintf('<img src="data:%s;base64,%s" /></samp>', $cursor->attr['content-type'], base64_encode($cursor->attr['img-data']));
|
||||
$this->line .= \sprintf('<img src="data:%s;base64,%s" /></samp>', $cursor->attr['content-type'], base64_encode($cursor->attr['img-data']));
|
||||
$this->endValue($cursor);
|
||||
} else {
|
||||
parent::dumpString($cursor, $str, $bin, $cut);
|
||||
@@ -805,7 +807,7 @@ EOHTML
|
||||
$r = Cursor::HASH_OBJECT !== $type ? 1 - (Cursor::HASH_RESOURCE !== $type) : 2;
|
||||
$r .= $r && 0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->refIndex;
|
||||
|
||||
$this->line .= sprintf(' id=%s-ref%s', $this->dumpId, $r);
|
||||
$this->line .= \sprintf(' id=%s-ref%s', $this->dumpId, $r);
|
||||
}
|
||||
$this->line .= $eol;
|
||||
$this->dumpLine($cursor->depth);
|
||||
@@ -831,19 +833,19 @@ EOHTML
|
||||
|
||||
if ('ref' === $style) {
|
||||
if (empty($attr['count'])) {
|
||||
return sprintf('<a class=sf-dump-ref>%s</a>', $v);
|
||||
return \sprintf('<a class=sf-dump-ref>%s</a>', $v);
|
||||
}
|
||||
$r = ('#' !== $v[0] ? 1 - ('@' !== $v[0]) : 2).substr($value, 1);
|
||||
|
||||
return sprintf('<a class=sf-dump-ref href=#%s-ref%s title="%d occurrences">%s</a>', $this->dumpId, $r, 1 + $attr['count'], $v);
|
||||
return \sprintf('<a class=sf-dump-ref href=#%s-ref%s title="%d occurrences">%s</a>', $this->dumpId, $r, 1 + $attr['count'], $v);
|
||||
}
|
||||
|
||||
if ('const' === $style && isset($attr['value'])) {
|
||||
$style .= sprintf(' title="%s"', esc(\is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value'])));
|
||||
$style .= \sprintf(' title="%s"', esc(\is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value'])));
|
||||
} elseif ('public' === $style) {
|
||||
$style .= sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property');
|
||||
$style .= \sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property');
|
||||
} elseif ('str' === $style && 1 < $attr['length']) {
|
||||
$style .= sprintf(' title="%d%s characters"', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : '');
|
||||
$style .= \sprintf(' title="%d%s characters"', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : '');
|
||||
} elseif ('note' === $style && 0 < ($attr['depth'] ?? 0) && false !== $c = strrpos($value, '\\')) {
|
||||
$style .= ' title=""';
|
||||
$attr += [
|
||||
@@ -854,23 +856,23 @@ EOHTML
|
||||
} elseif ('protected' === $style) {
|
||||
$style .= ' title="Protected property"';
|
||||
} elseif ('meta' === $style && isset($attr['title'])) {
|
||||
$style .= sprintf(' title="%s"', esc($this->utf8Encode($attr['title'])));
|
||||
$style .= \sprintf(' title="%s"', esc($this->utf8Encode($attr['title'])));
|
||||
} elseif ('private' === $style) {
|
||||
$style .= sprintf(' title="Private property defined in class: `%s`"', esc($this->utf8Encode($attr['class'])));
|
||||
$style .= \sprintf(' title="Private property defined in class: `%s`"', esc($this->utf8Encode($attr['class'])));
|
||||
}
|
||||
|
||||
if (isset($attr['ellipsis'])) {
|
||||
$class = 'sf-dump-ellipsis';
|
||||
if (isset($attr['ellipsis-type'])) {
|
||||
$class = sprintf('"%s sf-dump-ellipsis-%s"', $class, $attr['ellipsis-type']);
|
||||
$class = \sprintf('"%s sf-dump-ellipsis-%s"', $class, $attr['ellipsis-type']);
|
||||
}
|
||||
$label = esc(substr($value, -$attr['ellipsis']));
|
||||
$style = str_replace(' title="', " title=\"$v\n", $style);
|
||||
$v = sprintf('<span class=%s>%s</span>', $class, substr($v, 0, -\strlen($label)));
|
||||
$v = \sprintf('<span class=%s>%s</span>', $class, substr($v, 0, -\strlen($label)));
|
||||
|
||||
if (!empty($attr['ellipsis-tail'])) {
|
||||
$tail = \strlen(esc(substr($value, -$attr['ellipsis'], $attr['ellipsis-tail'])));
|
||||
$v .= sprintf('<span class=%s>%s</span>%s', $class, substr($label, 0, $tail), substr($label, $tail));
|
||||
$v .= \sprintf('<span class=%s>%s</span>%s', $class, substr($label, 0, $tail), substr($label, $tail));
|
||||
} else {
|
||||
$v .= $label;
|
||||
}
|
||||
@@ -893,7 +895,7 @@ EOHTML
|
||||
$s .= '">';
|
||||
}
|
||||
|
||||
$s .= $map[$c[$i]] ?? sprintf('\x%02X', \ord($c[$i]));
|
||||
$s .= $map[$c[$i]] ?? \sprintf('\x%02X', \ord($c[$i]));
|
||||
} while (isset($c[++$i]));
|
||||
|
||||
return $s.'</span>';
|
||||
@@ -913,14 +915,17 @@ EOHTML
|
||||
$v .= '^';
|
||||
}
|
||||
$target = isset($attr['file']) ? '' : ' target="_blank"';
|
||||
$v = sprintf('<a href="%s"%s rel="noopener noreferrer">%s</a>', esc($this->utf8Encode($attr['href'])), $target, $v);
|
||||
$v = \sprintf('<a href="%s"%s rel="noopener noreferrer">%s</a>', esc($this->utf8Encode($attr['href'])), $target, $v);
|
||||
}
|
||||
if (isset($attr['lang'])) {
|
||||
$v = sprintf('<code class="%s">%s</code>', esc($attr['lang']), $v);
|
||||
$v = \sprintf('<code class="%s">%s</code>', esc($attr['lang']), $v);
|
||||
}
|
||||
if ('label' === $style) {
|
||||
$v .= ' ';
|
||||
}
|
||||
if ($attr['virtual'] ?? false) {
|
||||
$v = '<span class=sf-dump-virtual>'.$v.'</span>';
|
||||
}
|
||||
|
||||
return $v;
|
||||
}
|
||||
@@ -928,7 +933,7 @@ EOHTML
|
||||
protected function dumpLine(int $depth, bool $endOfValue = false): void
|
||||
{
|
||||
if (-1 === $this->lastDepth) {
|
||||
$this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line;
|
||||
$this->line = \sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line;
|
||||
}
|
||||
if ($this->headerIsDumped !== ($this->outputStream ?? $this->lineDumper)) {
|
||||
$this->line = $this->getDumpHeader().$this->line;
|
||||
@@ -940,7 +945,7 @@ EOHTML
|
||||
$args[] = json_encode($this->extraDisplayOptions, \JSON_FORCE_OBJECT);
|
||||
}
|
||||
// Replace is for BC
|
||||
$this->line .= sprintf(str_replace('"%s"', '%s', $this->dumpSuffix), implode(', ', $args));
|
||||
$this->line .= \sprintf(str_replace('"%s"', '%s', $this->dumpSuffix), implode(', ', $args));
|
||||
}
|
||||
$this->lastDepth = $depth;
|
||||
|
||||
|
||||
+5
-4
@@ -23,17 +23,18 @@ use Symfony\Component\VarDumper\Server\Connection;
|
||||
class ServerDumper implements DataDumperInterface
|
||||
{
|
||||
private Connection $connection;
|
||||
private ?DataDumperInterface $wrappedDumper;
|
||||
|
||||
/**
|
||||
* @param string $host The server host
|
||||
* @param DataDumperInterface|null $wrappedDumper A wrapped instance used whenever we failed contacting the server
|
||||
* @param ContextProviderInterface[] $contextProviders Context providers indexed by context name
|
||||
*/
|
||||
public function __construct(string $host, ?DataDumperInterface $wrappedDumper = null, array $contextProviders = [])
|
||||
{
|
||||
public function __construct(
|
||||
string $host,
|
||||
private ?DataDumperInterface $wrappedDumper = null,
|
||||
array $contextProviders = [],
|
||||
) {
|
||||
$this->connection = new Connection($host, $contextProviders);
|
||||
$this->wrappedDumper = $wrappedDumper;
|
||||
}
|
||||
|
||||
public function getContextProviders(): array
|
||||
|
||||
Reference in New Issue
Block a user