bug #37700 [VarDumper] Improve previous fix on light array coloration (l-vo)

This PR was merged into the 3.4 branch.

Discussion
----------

[VarDumper] Improve previous fix on light array coloration

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #37674
| License       | MIT
| Doc PR        |

Improve #36230 to fix #37674 (revert previous fix and use a solution that looks better).

Commits
-------

cef16f591f [VarDumper] Improve previous fix on light array coloration
This commit is contained in:
Fabien Potencier 2020-07-31 08:39:36 +02:00
commit b940b5a4ca
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"];
}
/**