Skip to content

Commit 2027be1

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: [VarDumper] Fix managing collapse state in CliDumper
2 parents 77fb4f2 + 684b36f commit 2027be1

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

Diff for: Dumper/CliDumper.php

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public function setDisplayOptions(array $displayOptions)
134134
public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|null $value)
135135
{
136136
$this->dumpKey($cursor);
137+
$this->collapseNextHash = $this->expandNextHash = false;
137138

138139
$style = 'const';
139140
$attr = $cursor->attr;
@@ -197,6 +198,7 @@ public function dumpScalar(Cursor $cursor, string $type, string|int|float|bool|n
197198
public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut)
198199
{
199200
$this->dumpKey($cursor);
201+
$this->collapseNextHash = $this->expandNextHash = false;
200202
$attr = $cursor->attr;
201203

202204
if ($bin) {
@@ -290,6 +292,7 @@ public function enterHash(Cursor $cursor, int $type, string|int|null $class, boo
290292
$this->colors ??= $this->supportsColors();
291293

292294
$this->dumpKey($cursor);
295+
$this->expandNextHash = false;
293296
$attr = $cursor->attr;
294297

295298
if ($this->collapseNextHash) {

Diff for: Tests/Caster/MysqliCasterTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public function testNotConnected()
3030

3131
$xCast = <<<EODUMP
3232
mysqli_driver {%A
33-
+reconnect: false
3433
+report_mode: 3
3534
}
3635
EODUMP;

Diff for: Tests/Dumper/CliDumperTest.php

+40
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\VarDumper\Caster\CutStub;
16+
use Symfony\Component\VarDumper\Cloner\Data;
17+
use Symfony\Component\VarDumper\Cloner\Stub;
1618
use Symfony\Component\VarDumper\Cloner\VarCloner;
1719
use Symfony\Component\VarDumper\Dumper\AbstractDumper;
1820
use Symfony\Component\VarDumper\Dumper\CliDumper;
@@ -455,4 +457,42 @@ public function testDumpArrayWithColor($value, $flags, $expectedOut)
455457

456458
$this->assertSame($expectedOut, $out);
457459
}
460+
461+
public function testCollapse()
462+
{
463+
$stub = new Stub();
464+
$stub->type = Stub::TYPE_OBJECT;
465+
$stub->class = 'stdClass';
466+
$stub->position = 1;
467+
468+
$data = new Data([
469+
[
470+
$stub,
471+
],
472+
[
473+
"\0~collapse=1\0foo" => 123,
474+
"\0+\0bar" => [1 => 2],
475+
],
476+
[
477+
'bar' => 123,
478+
]
479+
]);
480+
481+
$dumper = new CliDumper();
482+
$dump = $dumper->dump($data, true);
483+
484+
$this->assertSame(
485+
<<<'EOTXT'
486+
{
487+
foo: 123
488+
+"bar": array:1 [
489+
"bar" => 123
490+
]
491+
}
492+
493+
EOTXT
494+
,
495+
$dump
496+
);
497+
}
458498
}

0 commit comments

Comments
 (0)