diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index 0c2108eda2e70..a45624247a81f 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -424,13 +424,19 @@ function xpathHasClass(className) { a.innerHTML += ' '; } a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children'; - a.innerHTML += elt.className == 'sf-dump-compact' ? '' : ''; + a.innerHTML += ''; a.className += ' sf-dump-toggle'; x = 1; if ('sf-dump' != elt.parentNode.className) { x += elt.parentNode.getAttribute('data-depth')/1; } + elt.setAttribute('data-depth', x); + var className = elt.className; + elt.className = 'sf-dump-expanded'; + if (className ? 'sf-dump-expanded' !== className : (x > options.maxDepth)) { + toggle(a); + } } else if (/\bsf-dump-ref\b/.test(elt.className) && (a = elt.getAttribute('href'))) { a = a.substr(1); elt.className += ' '+a; @@ -800,8 +806,7 @@ public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut) { if ('' === $str && isset($cursor->attr['img-data'], $cursor->attr['content-type'])) { $this->dumpKey($cursor); - $this->line .= $this->style('default', $cursor->attr['img-size'] ?? '', []); - $this->line .= $cursor->depth >= $this->displayOptions['maxDepth'] ? ' ' : ' '; + $this->line .= $this->style('default', $cursor->attr['img-size'] ?? '', []).' '; $this->endValue($cursor); $this->line .= $this->indentPad; $this->line .= sprintf('', $cursor->attr['content-type'], base64_encode($cursor->attr['img-data'])); @@ -821,16 +826,18 @@ public function enterHash(Cursor $cursor, int $type, $class, bool $hasChild) } parent::enterHash($cursor, $type, $class, false); - if ($cursor->skipChildren || $cursor->depth >= $this->displayOptions['maxDepth']) { + if ($cursor->skipChildren) { $cursor->skipChildren = false; $eol = ' class=sf-dump-compact>'; - } else { + } elseif ($this->expandNextHash) { $this->expandNextHash = false; $eol = ' class=sf-dump-expanded>'; + } else { + $eol = '>'; } if ($hasChild) { - $this->line .= 'refIndex) { $r = Cursor::HASH_OBJECT !== $type ? 1 - (Cursor::HASH_RESOURCE !== $type) : 2; $r .= $r && 0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->refIndex; diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php index 0a03e230a9675..50c7a8d24dca0 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php @@ -141,13 +141,13 @@ public function testHtmlDump() $dump = $dumper->dump($cloner->cloneVar($e)->withRefHandles(false), true); $expectedDump = <<<'EODUMP' -Exception { +Exception { #message: "1" #code: 0 #file: "%s%eVarDumper%eTests%eCaster%eExceptionCasterTest.php" #line: 28 - trace: { + trace: { %s%eVarDumper%eTests%eCaster%eExceptionCasterTest.php:28 …%d diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php index cd6876cdff22f..ebbf91cda9c8c 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/StubCasterTest.php @@ -99,7 +99,7 @@ public function testLinkStub() $dump = $dumper->dump($cloner->cloneVar($var), true); $expectedDump = <<<'EODUMP' -array:1 [ +array:1 [ 0 => "Symfony\Component\VarDumper\Tests\Caster\StubCasterTest" ] @@ -120,7 +120,7 @@ public function testLinkStubWithNoFileLink() $dump = $dumper->dump($cloner->cloneVar($var), true); $expectedDump = <<<'EODUMP' -array:1 [ +array:1 [ 0 => "example.com" ] @@ -140,7 +140,7 @@ public function testClassStub() $dump = $dumper->dump($cloner->cloneVar($var), true, ['fileLinkFormat' => '%f:%l']); $expectedDump = <<<'EODUMP' -array:1 [ +array:1 [ 0 => "hello(?stdClass $a, stdClass $b = null)" ] @@ -160,7 +160,7 @@ public function testClassStubWithNotExistingClass() $dump = $dumper->dump($cloner->cloneVar($var), true); $expectedDump = <<<'EODUMP' -array:1 [ +array:1 [ 0 => "Symfony\Component\VarDumper\Tests\Caster\NotExisting" ] @@ -181,7 +181,7 @@ public function testClassStubWithNotExistingMethod() $dump = $dumper->dump($cloner->cloneVar($var), true, ['fileLinkFormat' => '%f:%l']); $expectedDump = <<<'EODUMP' -array:1 [ +array:1 [ 0 => "hello" ] @@ -202,7 +202,7 @@ public function testClassStubWithAnonymousClass() $dump = $dumper->dump($cloner->cloneVar($var), true, ['fileLinkFormat' => '%f:%l']); $expectedDump = <<<'EODUMP' -array:1 [ +array:1 [ 0 => "Exception@anonymous" ] diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php index 960cf4b291a4d..add86778b2b75 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php @@ -54,7 +54,7 @@ public function testGet() $this->assertStringMatchesFormat( <<array:24 [ +array:24 [ "number" => 1 0 => &1 null "const" => 1.1 @@ -70,7 +70,7 @@ public function testGet() ing """ "[]" => [] - "res" => stream resource @{$res} + "res" => stream resource @{$res} %A wrapper_type: "plainfile" stream_type: "STDIO" mode: "r" @@ -79,11 +79,11 @@ public function testGet() %A options: [] } "obj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d +">Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d +foo: "foo" +"bar": "bar" } - "closure" => Closure(\$a, PDO &\$b = null) {#%d + "closure" => Closure(\$a, PDO &\$b = null) {#%d class: "Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest" this: {$var['line']} to {$var['line']}" } "line" => {$var['line']} - "nobj" => array:1 [ + "nobj" => array:1 [ 0 => &3 {#%d} ] - "recurs" => &4 array:1 [ + "recurs" => &4 array:1 [ 0 => &4 array:1 [&4] ] 8 => &1 null