Upgrade framework
This commit is contained in:
309
vendor/symfony/var-dumper/Dumper/CliDumper.php
vendored
309
vendor/symfony/var-dumper/Dumper/CliDumper.php
vendored
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\VarDumper\Dumper;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Cursor;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* CliDumper dumps variables for command line output.
|
||||
@@ -25,9 +26,9 @@ class CliDumper extends AbstractDumper
|
||||
|
||||
protected $colors;
|
||||
protected $maxStringWidth = 0;
|
||||
protected $styles = array(
|
||||
protected $styles = [
|
||||
// See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
||||
'default' => '38;5;208',
|
||||
'default' => '0;38;5;208',
|
||||
'num' => '1;38;5;38',
|
||||
'const' => '1;38;5;208',
|
||||
'str' => '1;38;5;113',
|
||||
@@ -39,28 +40,37 @@ class CliDumper extends AbstractDumper
|
||||
'meta' => '38;5;170',
|
||||
'key' => '38;5;113',
|
||||
'index' => '38;5;38',
|
||||
);
|
||||
];
|
||||
|
||||
protected static $controlCharsRx = '/[\x00-\x1F\x7F]+/';
|
||||
protected static $controlCharsMap = array(
|
||||
protected static $controlCharsMap = [
|
||||
"\t" => '\t',
|
||||
"\n" => '\n',
|
||||
"\v" => '\v',
|
||||
"\f" => '\f',
|
||||
"\r" => '\r',
|
||||
"\033" => '\e',
|
||||
);
|
||||
];
|
||||
|
||||
protected $collapseNextHash = false;
|
||||
protected $expandNextHash = false;
|
||||
|
||||
private array $displayOptions = [
|
||||
'fileLinkFormat' => null,
|
||||
];
|
||||
|
||||
private bool $handlesHrefGracefully;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($output = null, $charset = null, $flags = 0)
|
||||
public function __construct($output = null, string $charset = null, int $flags = 0)
|
||||
{
|
||||
parent::__construct($output, $charset, $flags);
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR && 'ON' !== @getenv('ConEmuANSI') && 'xterm' !== @getenv('TERM')) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && !$this->isWindowsTrueColor()) {
|
||||
// Use only the base 16 xterm colors when using ANSICON or standard Windows 10 CLI
|
||||
$this->setStyles(array(
|
||||
$this->setStyles([
|
||||
'default' => '31',
|
||||
'num' => '1;34',
|
||||
'const' => '1;31',
|
||||
@@ -70,28 +80,26 @@ class CliDumper extends AbstractDumper
|
||||
'meta' => '35',
|
||||
'key' => '32',
|
||||
'index' => '34',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
$this->displayOptions['fileLinkFormat'] = \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l';
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables colored output.
|
||||
*
|
||||
* @param bool $colors
|
||||
*/
|
||||
public function setColors($colors)
|
||||
public function setColors(bool $colors)
|
||||
{
|
||||
$this->colors = (bool) $colors;
|
||||
$this->colors = $colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of characters per line for dumped strings.
|
||||
*
|
||||
* @param int $maxStringWidth
|
||||
*/
|
||||
public function setMaxStringWidth($maxStringWidth)
|
||||
public function setMaxStringWidth(int $maxStringWidth)
|
||||
{
|
||||
$this->maxStringWidth = (int) $maxStringWidth;
|
||||
$this->maxStringWidth = $maxStringWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,10 +112,20 @@ class CliDumper extends AbstractDumper
|
||||
$this->styles = $styles + $this->styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures display options.
|
||||
*
|
||||
* @param array $displayOptions A map of display options to customize the behavior
|
||||
*/
|
||||
public function setDisplayOptions(array $displayOptions)
|
||||
{
|
||||
$this->displayOptions = $displayOptions + $this->displayOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dumpScalar(Cursor $cursor, $type, $value)
|
||||
public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|null $value)
|
||||
{
|
||||
$this->dumpKey($cursor);
|
||||
|
||||
@@ -121,18 +139,27 @@ class CliDumper extends AbstractDumper
|
||||
|
||||
case 'integer':
|
||||
$style = 'num';
|
||||
|
||||
if (isset($this->styles['integer'])) {
|
||||
$style = 'integer';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'double':
|
||||
$style = 'num';
|
||||
|
||||
if (isset($this->styles['float'])) {
|
||||
$style = 'float';
|
||||
}
|
||||
|
||||
switch (true) {
|
||||
case INF === $value: $value = 'INF'; break;
|
||||
case -INF === $value: $value = '-INF'; break;
|
||||
case \INF === $value: $value = 'INF'; break;
|
||||
case -\INF === $value: $value = '-INF'; break;
|
||||
case is_nan($value): $value = 'NAN'; break;
|
||||
default:
|
||||
$value = (string) $value;
|
||||
if (false === strpos($value, $this->decimalPoint)) {
|
||||
if (!str_contains($value, $this->decimalPoint)) {
|
||||
$value .= $this->decimalPoint.'0';
|
||||
}
|
||||
break;
|
||||
@@ -148,7 +175,7 @@ class CliDumper extends AbstractDumper
|
||||
break;
|
||||
|
||||
default:
|
||||
$attr += array('value' => $this->utf8Encode($value));
|
||||
$attr += ['value' => $this->utf8Encode($value)];
|
||||
$value = $this->utf8Encode($type);
|
||||
break;
|
||||
}
|
||||
@@ -161,7 +188,7 @@ class CliDumper extends AbstractDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dumpString(Cursor $cursor, $str, $bin, $cut)
|
||||
public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
|
||||
{
|
||||
$this->dumpKey($cursor);
|
||||
$attr = $cursor->attr;
|
||||
@@ -173,16 +200,16 @@ class CliDumper extends AbstractDumper
|
||||
$this->line .= '""';
|
||||
$this->endValue($cursor);
|
||||
} else {
|
||||
$attr += array(
|
||||
$attr += [
|
||||
'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
|
||||
'binary' => $bin,
|
||||
);
|
||||
$str = explode("\n", $str);
|
||||
];
|
||||
$str = $bin && false !== strpos($str, "\0") ? [$str] : explode("\n", $str);
|
||||
if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) {
|
||||
unset($str[1]);
|
||||
$str[0] .= "\n";
|
||||
}
|
||||
$m = count($str) - 1;
|
||||
$m = \count($str) - 1;
|
||||
$i = $lineCut = 0;
|
||||
|
||||
if (self::DUMP_STRING_LENGTH & $this->flags) {
|
||||
@@ -249,23 +276,33 @@ class CliDumper extends AbstractDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enterHash(Cursor $cursor, $type, $class, $hasChild)
|
||||
public function enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild)
|
||||
{
|
||||
if (null === $this->colors) {
|
||||
$this->colors = $this->supportsColors();
|
||||
}
|
||||
|
||||
$this->dumpKey($cursor);
|
||||
$attr = $cursor->attr;
|
||||
|
||||
if ($this->collapseNextHash) {
|
||||
$cursor->skipChildren = true;
|
||||
$this->collapseNextHash = $hasChild = false;
|
||||
}
|
||||
|
||||
$class = $this->utf8Encode($class);
|
||||
if (Cursor::HASH_OBJECT === $type) {
|
||||
$prefix = $class && 'stdClass' !== $class ? $this->style('note', $class).' {' : '{';
|
||||
$prefix = $class && 'stdClass' !== $class ? $this->style('note', $class, $attr).(empty($attr['cut_hash']) ? ' {' : '') : '{';
|
||||
} elseif (Cursor::HASH_RESOURCE === $type) {
|
||||
$prefix = $this->style('note', $class.' resource').($hasChild ? ' {' : ' ');
|
||||
$prefix = $this->style('note', $class.' resource', $attr).($hasChild ? ' {' : ' ');
|
||||
} else {
|
||||
$prefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? $this->style('note', 'array:'.$class).' [' : '[';
|
||||
}
|
||||
|
||||
if ($cursor->softRefCount || 0 < $cursor->softRefHandle) {
|
||||
$prefix .= $this->style('ref', (Cursor::HASH_RESOURCE === $type ? '@' : '#').(0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->softRefTo), array('count' => $cursor->softRefCount));
|
||||
if (($cursor->softRefCount || 0 < $cursor->softRefHandle) && empty($attr['cut_hash'])) {
|
||||
$prefix .= $this->style('ref', (Cursor::HASH_RESOURCE === $type ? '@' : '#').(0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->softRefTo), ['count' => $cursor->softRefCount]);
|
||||
} elseif ($cursor->hardRefTo && !$cursor->refIndex && $class) {
|
||||
$prefix .= $this->style('ref', '&'.$cursor->hardRefTo, array('count' => $cursor->hardRefCount));
|
||||
$prefix .= $this->style('ref', '&'.$cursor->hardRefTo, ['count' => $cursor->hardRefCount]);
|
||||
} elseif (!$hasChild && Cursor::HASH_RESOURCE === $type) {
|
||||
$prefix = substr($prefix, 0, -1);
|
||||
}
|
||||
@@ -280,21 +317,23 @@ class CliDumper extends AbstractDumper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut)
|
||||
public function leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut)
|
||||
{
|
||||
$this->dumpEllipsis($cursor, $hasChild, $cut);
|
||||
$this->line .= Cursor::HASH_OBJECT === $type ? '}' : (Cursor::HASH_RESOURCE !== $type ? ']' : ($hasChild ? '}' : ''));
|
||||
if (empty($cursor->attr['cut_hash'])) {
|
||||
$this->dumpEllipsis($cursor, $hasChild, $cut);
|
||||
$this->line .= Cursor::HASH_OBJECT === $type ? '}' : (Cursor::HASH_RESOURCE !== $type ? ']' : ($hasChild ? '}' : ''));
|
||||
}
|
||||
|
||||
$this->endValue($cursor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps an ellipsis for cut children.
|
||||
*
|
||||
* @param Cursor $cursor The Cursor position in the dump
|
||||
* @param bool $hasChild When the dump of the hash has child item
|
||||
* @param int $cut The number of items the hash has been cut by
|
||||
* @param bool $hasChild When the dump of the hash has child item
|
||||
* @param int $cut The number of items the hash has been cut by
|
||||
*/
|
||||
protected function dumpEllipsis(Cursor $cursor, $hasChild, $cut)
|
||||
protected function dumpEllipsis(Cursor $cursor, bool $hasChild, int $cut)
|
||||
{
|
||||
if ($cut) {
|
||||
$this->line .= ' …';
|
||||
@@ -309,8 +348,6 @@ class CliDumper extends AbstractDumper
|
||||
|
||||
/**
|
||||
* Dumps a key in a hash structure.
|
||||
*
|
||||
* @param Cursor $cursor The Cursor position in the dump
|
||||
*/
|
||||
protected function dumpKey(Cursor $cursor)
|
||||
{
|
||||
@@ -318,7 +355,7 @@ class CliDumper extends AbstractDumper
|
||||
if ($cursor->hashKeyIsBinary) {
|
||||
$key = $this->utf8Encode($key);
|
||||
}
|
||||
$attr = array('binary' => $cursor->hashKeyIsBinary);
|
||||
$attr = ['binary' => $cursor->hashKeyIsBinary];
|
||||
$bin = $cursor->hashKeyIsBinary ? 'b' : '';
|
||||
$style = 'key';
|
||||
switch ($cursor->hashType) {
|
||||
@@ -328,8 +365,9 @@ class CliDumper extends AbstractDumper
|
||||
break;
|
||||
}
|
||||
$style = 'index';
|
||||
// no break
|
||||
case Cursor::HASH_ASSOC:
|
||||
if (is_int($key)) {
|
||||
if (\is_int($key)) {
|
||||
$this->line .= $this->style($style, $key).' => ';
|
||||
} else {
|
||||
$this->line .= $bin.'"'.$this->style($style, $key).'" => ';
|
||||
@@ -338,7 +376,7 @@ class CliDumper extends AbstractDumper
|
||||
|
||||
case Cursor::HASH_RESOURCE:
|
||||
$key = "\0~\0".$key;
|
||||
// No break;
|
||||
// no break
|
||||
case Cursor::HASH_OBJECT:
|
||||
if (!isset($key[0]) || "\0" !== $key[0]) {
|
||||
$this->line .= '+'.$bin.$this->style('public', $key).': ';
|
||||
@@ -354,7 +392,7 @@ class CliDumper extends AbstractDumper
|
||||
$style = 'meta';
|
||||
if (isset($key[0][1])) {
|
||||
parse_str(substr($key[0], 1), $attr);
|
||||
$attr += array('binary' => $cursor->hashKeyIsBinary);
|
||||
$attr += ['binary' => $cursor->hashKeyIsBinary];
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
@@ -368,16 +406,24 @@ class CliDumper extends AbstractDumper
|
||||
break;
|
||||
}
|
||||
|
||||
$this->line .= $bin.$this->style($style, $key[1], $attr).': ';
|
||||
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, array('class' => '')).'": ';
|
||||
$this->line .= '-'.$bin.'"'.$this->style('private', $key, ['class' => '']).'": ';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($cursor->hardRefTo) {
|
||||
$this->line .= $this->style('ref', '&'.($cursor->hardRefCount ? $cursor->hardRefTo : ''), array('count' => $cursor->hardRefCount)).' ';
|
||||
$this->line .= $this->style('ref', '&'.($cursor->hardRefCount ? $cursor->hardRefTo : ''), ['count' => $cursor->hardRefCount]).' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,25 +434,41 @@ 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 The value with style decoration
|
||||
*/
|
||||
protected function style($style, $value, $attr = array())
|
||||
protected function style(string $style, string $value, array $attr = []): string
|
||||
{
|
||||
if (null === $this->colors) {
|
||||
$this->colors = $this->supportsColors();
|
||||
}
|
||||
|
||||
$style = $this->styles[$style];
|
||||
$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']);
|
||||
if ('cli' === \PHP_SAPI && 'path' === $attr['ellipsis-type'] && isset($_SERVER[$pwd = '\\' === \DIRECTORY_SEPARATOR ? 'CD' : 'PWD']) && str_starts_with($prefix, $_SERVER[$pwd])) {
|
||||
$prefix = '.'.substr($prefix, \strlen($_SERVER[$pwd]));
|
||||
}
|
||||
if (!empty($attr['ellipsis-tail'])) {
|
||||
$prefix .= substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']);
|
||||
$value = substr($value, -$attr['ellipsis'] + $attr['ellipsis-tail']);
|
||||
} else {
|
||||
$value = substr($value, -$attr['ellipsis']);
|
||||
}
|
||||
|
||||
$value = $this->style('default', $prefix).$this->style($style, $value);
|
||||
|
||||
goto href;
|
||||
}
|
||||
|
||||
$map = static::$controlCharsMap;
|
||||
$startCchr = $this->colors ? "\033[m\033[{$this->styles['default']}m" : '';
|
||||
$endCchr = $this->colors ? "\033[m\033[{$style}m" : '';
|
||||
$endCchr = $this->colors ? "\033[m\033[{$this->styles[$style]}m" : '';
|
||||
$value = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $startCchr, $endCchr) {
|
||||
$s = $startCchr;
|
||||
$c = $c[$i = 0];
|
||||
do {
|
||||
$s .= isset($map[$c[$i]]) ? $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;
|
||||
@@ -414,34 +476,47 @@ class CliDumper extends AbstractDumper
|
||||
|
||||
if ($this->colors) {
|
||||
if ($cchrCount && "\033" === $value[0]) {
|
||||
$value = substr($value, strlen($startCchr));
|
||||
$value = substr($value, \strlen($startCchr));
|
||||
} else {
|
||||
$value = "\033[{$style}m".$value;
|
||||
$value = "\033[{$this->styles[$style]}m".$value;
|
||||
}
|
||||
if ($cchrCount && $endCchr === substr($value, -strlen($endCchr))) {
|
||||
$value = substr($value, 0, -strlen($endCchr));
|
||||
if ($cchrCount && str_ends_with($value, $endCchr)) {
|
||||
$value = substr($value, 0, -\strlen($endCchr));
|
||||
} else {
|
||||
$value .= "\033[{$this->styles['default']}m";
|
||||
}
|
||||
}
|
||||
|
||||
href:
|
||||
if ($this->colors && $this->handlesHrefGracefully) {
|
||||
if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], $attr['line'] ?? 0)) {
|
||||
if ('note' === $style) {
|
||||
$value .= "\033]8;;{$href}\033\\^\033]8;;\033\\";
|
||||
} else {
|
||||
$attr['href'] = $href;
|
||||
}
|
||||
}
|
||||
if (isset($attr['href'])) {
|
||||
$value = "\033]8;;{$attr['href']}\033\\{$value}\033]8;;\033\\";
|
||||
}
|
||||
} elseif ($attr['if_links'] ?? false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Tells if the current output stream supports ANSI colors or not
|
||||
*/
|
||||
protected function supportsColors()
|
||||
protected function supportsColors(): bool
|
||||
{
|
||||
if ($this->outputStream !== static::$defaultOutput) {
|
||||
return @(is_resource($this->outputStream) && function_exists('posix_isatty') && posix_isatty($this->outputStream));
|
||||
return $this->hasColorSupport($this->outputStream);
|
||||
}
|
||||
if (null !== static::$defaultColors) {
|
||||
return static::$defaultColors;
|
||||
}
|
||||
if (isset($_SERVER['argv'][1])) {
|
||||
$colors = $_SERVER['argv'];
|
||||
$i = count($colors);
|
||||
$i = \count($colors);
|
||||
while (--$i > 0) {
|
||||
if (isset($colors[$i][5])) {
|
||||
switch ($colors[$i]) {
|
||||
@@ -450,40 +525,30 @@ class CliDumper extends AbstractDumper
|
||||
case '--color=yes':
|
||||
case '--color=force':
|
||||
case '--color=always':
|
||||
case '--colors=always':
|
||||
return static::$defaultColors = true;
|
||||
|
||||
case '--no-ansi':
|
||||
case '--color=no':
|
||||
case '--color=none':
|
||||
case '--color=never':
|
||||
case '--colors=never':
|
||||
return static::$defaultColors = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
static::$defaultColors = @(
|
||||
'10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
|
||||
|| false !== getenv('ANSICON')
|
||||
|| 'ON' === getenv('ConEmuANSI')
|
||||
|| 'xterm' === getenv('TERM')
|
||||
);
|
||||
} elseif (function_exists('posix_isatty')) {
|
||||
$h = stream_get_meta_data($this->outputStream) + array('wrapper_type' => null);
|
||||
$h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'wb') : $this->outputStream;
|
||||
static::$defaultColors = @posix_isatty($h);
|
||||
} else {
|
||||
static::$defaultColors = false;
|
||||
}
|
||||
$h = stream_get_meta_data($this->outputStream) + ['wrapper_type' => null];
|
||||
$h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'w') : $this->outputStream;
|
||||
|
||||
return static::$defaultColors;
|
||||
return static::$defaultColors = $this->hasColorSupport($h);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function dumpLine($depth, $endOfValue = false)
|
||||
protected function dumpLine(int $depth, bool $endOfValue = false)
|
||||
{
|
||||
if ($this->colors) {
|
||||
$this->line = sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line);
|
||||
@@ -493,12 +558,86 @@ class CliDumper extends AbstractDumper
|
||||
|
||||
protected function endValue(Cursor $cursor)
|
||||
{
|
||||
if (self::DUMP_TRAILING_COMMA & $this->flags && 0 < $cursor->depth) {
|
||||
$this->line .= ',';
|
||||
} elseif (self::DUMP_COMMA_SEPARATOR & $this->flags && 1 < $cursor->hashLength - $cursor->hashIndex) {
|
||||
$this->line .= ',';
|
||||
if (-1 === $cursor->hashType) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Stub::ARRAY_INDEXED === $cursor->hashType || Stub::ARRAY_ASSOC === $cursor->hashType) {
|
||||
if (self::DUMP_TRAILING_COMMA & $this->flags && 0 < $cursor->depth) {
|
||||
$this->line .= ',';
|
||||
} elseif (self::DUMP_COMMA_SEPARATOR & $this->flags && 1 < $cursor->hashLength - $cursor->hashIndex) {
|
||||
$this->line .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
$this->dumpLine($cursor->depth, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the stream supports colorization.
|
||||
*
|
||||
* Reference: Composer\XdebugHandler\Process::supportsColor
|
||||
* https://github.com/composer/xdebug-handler
|
||||
*/
|
||||
private function hasColorSupport(mixed $stream): bool
|
||||
{
|
||||
if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Follow https://no-color.org/
|
||||
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('Hyper' === getenv('TERM_PROGRAM')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (\DIRECTORY_SEPARATOR === '\\') {
|
||||
return (\function_exists('sapi_windows_vt100_support')
|
||||
&& @sapi_windows_vt100_support($stream))
|
||||
|| false !== getenv('ANSICON')
|
||||
|| 'ON' === getenv('ConEmuANSI')
|
||||
|| 'xterm' === getenv('TERM');
|
||||
}
|
||||
|
||||
return stream_isatty($stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the Windows terminal supports true color.
|
||||
*
|
||||
* Note that this does not check an output stream, but relies on environment
|
||||
* variables from known implementations, or a PHP and Windows version that
|
||||
* supports true color.
|
||||
*/
|
||||
private function isWindowsTrueColor(): bool
|
||||
{
|
||||
$result = 183 <= getenv('ANSICON_VER')
|
||||
|| 'ON' === getenv('ConEmuANSI')
|
||||
|| 'xterm' === getenv('TERM')
|
||||
|| 'Hyper' === getenv('TERM_PROGRAM');
|
||||
|
||||
if (!$result) {
|
||||
$version = sprintf(
|
||||
'%s.%s.%s',
|
||||
PHP_WINDOWS_VERSION_MAJOR,
|
||||
PHP_WINDOWS_VERSION_MINOR,
|
||||
PHP_WINDOWS_VERSION_BUILD
|
||||
);
|
||||
$result = $version >= '10.0.15063';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getSourceLink(string $file, int $line)
|
||||
{
|
||||
if ($fmt = $this->displayOptions['fileLinkFormat']) {
|
||||
return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : ($fmt->format($file, $line) ?: 'file://'.$file.'#L'.$line);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user