Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[VarDumper] Improve previous fix on light array coloration #37700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[VarDumper] Improve previous fix on light array coloration
  • Loading branch information
l-vo committed Jul 29, 2020
commit cef16f591fed8cfa05c2d8c59a845a1e86283d9c
7 changes: 5 additions & 2 deletions src/Symfony/Component/VarDumper/Dumper/CliDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut)
*/
public function enterHash(Cursor $cursor, $type, $class, $hasChild)
{
if (null === $this->colors) {
$this->colors = $this->supportsColors();
}

$this->dumpKey($cursor);

if ($this->collapseNextHash) {
Expand All @@ -268,8 +272,7 @@ public function enterHash(Cursor $cursor, $type, $class, $hasChild)
} 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,28 +578,28 @@ public function provideDumpArrayWithColor()
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

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"];
}

/**
Expand Down