8000 [VarDumper][DebugBundle] Fix dump labels compatibility · symfony/symfony@05d5dca · GitHub
[go: up one dir, main page]

Skip to content

Commit 05d5dca

Browse files
committed
[VarDumper][DebugBundle] Fix dump labels compatibility
1 parent 825fd03 commit 05d5dca

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Symfony/Bundle/DebugBundle/DebugBundle.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,19 @@ public function boot()
3535
// The dump data collector is used by default, so dump output is sent to
3636
// the WDT. In a CLI context, if dump is used too soon, the data collector
3737
// will buffer it, and release it at the end of the script.
38-
VarDumper::setHandler(function ($var) use ($container) {
38+
VarDumper::setHandler(function ($var, string $label = null) use ($container) {
3939
$dumper = $container->get('data_collector.dump');
4040
$cloner = $container->get('var_dumper.cloner');
41-
8000 $handler = function ($var) use ($dumper, $cloner) {
42-
$dumper->dump($cloner->cloneVar($var));
41+
$handler = function ($var, string $label = null) use ($dumper, $cloner) {
42+
$var = $cloner->cloneVar($var);
43+
if (null !== $label) {
44+
$var = $var->withContext(['label' => $label]);
45+
}
46+
47+
$dumper->dump($var);
4348
};
4449
VarDumper::setHandler($handler);
45-
$handler($var);
50+
$handler($var, $label);
4651
});
4752
}
4853
}

src/Symfony/Component/VarDumper/Cloner/Data.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ public function dump(DumperInterface $dumper)
278278
$cursor->attr = ['if_links' => true];
279279
$dumper->dumpScalar($cursor, 'default', ' ');
280280
$cursor->hashType = 0;
281+
} elseif ('' !== $label) {
282+
$cursor->hashType = -1;
283+
$dumper->dumpScalar($cursor, 'default', $label.'^ ');
284+
$cursor->hashType = 0;
281285
}
282286

283287
$this->dumpItem($dumper, $cursor, $refs, $this->data[$this->position][$this->key]);

0 commit comments

Comments
 (0)
0