[VarDumper] Improve previous fix on light array coloration

This commit is contained in:
Laurent VOULLEMIER 2020-07-29 17:02:56 +02:00
parent cc827466bb
commit cef16f591f
2 changed files with 9 additions and 6 deletions

View File

@ -255,6 +255,10 @@ class CliDumper extends AbstractDumper
*/
public function enterHash(Cursor $cursor, $type, $class, $hasChild)
{
if (null === $this->colors) {
$this->colors = $this->supportsColors();
}
$this->dumpKey($cursor);
if ($this->collapseNextHash) {
@ -268,8 +272,7 @@ class CliDumper extends AbstractDumper
} elseif (Cursor::HASH_RESOURCE === $type) {
$prefix = $this->style('note', $class.' resource').($hasChild ? ' {' : ' ');
} else {
$unstyledPrefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? 'array:'.$class : '';
$prefix = $this->style('note', $unstyledPrefix).($unstyledPrefix ? ' [' : '[');
$prefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? $this->style('note', 'array:'.$class).' [' : '[';
}
if ($cursor->softRefCount || 0 < $cursor->softRefHandle) {

View File

@ -578,7 +578,7 @@ EOTXT
yield [
['foo' => 'bar'],
0,
<<<EOTXT
<<<EOTXT
\e[0;38;5;208m\e[38;5;38marray:1\e[0;38;5;208m [\e[m
\e[0;38;5;208m"\e[38;5;113mfoo\e[0;38;5;208m" => "\e[1;38;5;113mbar\e[0;38;5;208m"\e[m
\e[0;38;5;208m]\e[m
@ -586,20 +586,20 @@ EOTXT
EOTXT
];
yield [[], AbstractDumper::DUMP_LIGHT_ARRAY, "\e[0;38;5;208m\e[38;5;38m\e[0;38;5;208m[]\e[m\n"];
yield [[], AbstractDumper::DUMP_LIGHT_ARRAY, "\e[0;38;5;208m[]\e[m\n"];
yield [
['foo' => 'bar'],
AbstractDumper::DUMP_LIGHT_ARRAY,
<<<EOTXT
\e[0;38;5;208m\e[38;5;38m\e[0;38;5;208m[\e[m
\e[0;38;5;208m[\e[m
\e[0;38;5;208m"\e[38;5;113mfoo\e[0;38;5;208m" => "\e[1;38;5;113mbar\e[0;38;5;208m"\e[m
\e[0;38;5;208m]\e[m
EOTXT
];
yield [[], 0, "\e[0;38;5;208m\e[38;5;38m\e[0;38;5;208m[]\e[m\n"];
yield [[], 0, "\e[0;38;5;208m[]\e[m\n"];
}
/**