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

Skip to content

Commit b940b5a

Browse files
committed
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 ------- cef16f5 [VarDumper] Improve previous fix on light array coloration
2 parents cc82746 + cef16f5 commit b940b5a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/Symfony/Component/VarDumper/Dumper/CliDumper.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ public function dumpString(Cursor $cursor, $str, $bin, $cut)
255255
*/
256256
public function enterHash(Cursor $cursor, $type, $class, $hasChild)
257257
{
258+
if (null === $this->colors) {
259+
$this->colors = $this->supportsColors();
260+
}
261+
258262
$this->dumpKey($cursor);
259263

260264
if ($this->collapseNextHash) {
@@ -268,8 +272,7 @@ public function enterHash(Cursor $cursor, $type, $class, $hasChild)
268272
} elseif (Cursor::HASH_RESOURCE === $type) {
269273
$prefix = $this->style('note', $class.' resource').($hasChild ? ' {' : ' ');
270274
} else {
271-
$unstyledPrefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? 'array:'.$class : '';
272-
$prefix = $this->style('note', $unstyledPrefix).($unstyledPrefix ? ' [' : '[');
275+
$prefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? $this->style('note', 'array:'.$class).' [' : '[';
273276
}
274277

275278
if ($cursor->softRefCount || 0 < $cursor->softRefHandle) {

src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,28 +578,28 @@ public function provideDumpArrayWithColor()
578578
yield [
579579
['foo' => 'bar'],
580580
0,
581-
<<<EOTXT
581+
<<<EOTXT
582582
\e[0;38;5;208m\e[38;5;38marray:1\e[0;38;5;208m [\e[m
583583
\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
584584
\e[0;38;5;208m]\e[m
585585
586586
EOTXT
587587
];
588588

589-
yield [[], AbstractDumper::DUMP_LIGHT_ARRAY, "\e[0;38;5;208m\e[38;5;38m\e[0;38;5;208m[]\e[m\n"];
589+
yield [[], AbstractDumper::DUMP_LIGHT_ARRAY, "\e[0;38;5;208m[]\e[m\n"];
590590

591591
yield [
592592
['foo' => 'bar'],
593593
AbstractDumper::DUMP_LIGHT_ARRAY,
594594
<<<EOTXT
595-
\e[0;38;5;208m\e[38;5;38m\e[0;38;5;208m[\e[m
595+
\e[0;38;5;208m[\e[m
596596
\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
597597
\e[0;38;5;208m]\e[m
598598
599599
EOTXT
600600
];
601601

602-
yield [[], 0, "\e[0;38;5;208m\e[38;5;38m\e[0;38;5;208m[]\e[m\n"];
602+
yield [[], 0, "\e[0;38;5;208m[]\e[m\n"];
603603
}
604604

605605
/**

0 commit comments

Comments
 (0)