2020use Symfony \Component \VarDumper \Dumper \CliDumper ;
2121use Symfony \Component \VarDumper \Dumper \HtmlDumper ;
2222use Symfony \Component \VarDumper \Dumper \DataDumperInterface ;
23+ use Symfony \Component \VarDumper \Dumper \ServerDumper ;
2324use Twig \Template ;
2425
2526/**
@@ -38,15 +39,17 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
3839 private $ requestStack ;
3940 private $ dumper ;
4041 private $ dumperIsInjected ;
42+ private $ serverDumper ;
4143
42- public function __construct (Stopwatch $ stopwatch = null , $ fileLinkFormat = null , $ charset = null , RequestStack $ requestStack = null , DataDumperInterface $ dumper = null )
44+ public function __construct (Stopwatch $ stopwatch = null , $ fileLinkFormat = null , $ charset = null , RequestStack $ requestStack = null , DataDumperInterface $ dumper = null , ServerDumper $ serverDumper = null )
4345 {
4446 $ this ->stopwatch = $ stopwatch ;
4547 $ this ->fileLinkFormat = $ fileLinkFormat ?: ini_get ('xdebug.file_link_format ' ) ?: get_cfg_var ('xdebug.file_link_format ' );
4648 $ this ->charset = $ charset ?: ini_get ('php.output_encoding ' ) ?: ini_get ('default_charset ' ) ?: 'UTF-8 ' ;
4749 $ this ->requestStack = $ requestStack ;
4850 $ this ->dumper = $ dumper ;
4951 $ this ->dumperIsInjected = null !== $ dumper ;
52+ $ this ->serverDumper = $ serverDumper ;
5053
5154 // All clones share these properties by reference:
5255 $ this ->rootRefs = array (
@@ -257,8 +260,17 @@ public function __destruct()
257260
258261 private function doDump ($ data , $ name , $ file , $ line )
259262 {
263+ $ dumper = $ this ->serverDumper ?: $ this ->dumper ;
264+ if ($ dumper instanceof ServerDumper) {
265+ $ dumper ->setWrappedDumper ($ this ->dumper );
266+ }
267+
260268 if ($ this ->dumper instanceof CliDumper) {
261269 $ contextDumper = function ($ name , $ file , $ line , $ fmt ) {
270+ if ($ this instanceof ServerDumper) {
271+ return ;
272+ }
273+
262274 if ($ this instanceof HtmlDumper) {
263275 if ($ file ) {
264276 $ s = $ this ->style ('meta ' , '%s ' );
@@ -278,13 +290,13 @@ private function doDump($data, $name, $file, $line)
278290 }
279291 $ this ->dumpLine (0 );
280292 };
281- $ contextDumper = $ contextDumper ->bindTo ($ this -> dumper , $ this -> dumper );
293+ $ contextDumper = $ contextDumper ->bindTo ($ dumper , $ dumper );
282294 $ contextDumper ($ name , $ file , $ line , $ this ->fileLinkFormat );
283295 } else {
284296 $ cloner = new VarCloner ();
285- $ this -> dumper ->dump ($ cloner ->cloneVar ($ name .' on line ' .$ line .': ' ));
297+ $ dumper ->dump ($ cloner ->cloneVar ($ name .' on line ' .$ line .': ' ));
286298 }
287- $ this -> dumper ->dump ($ data );
299+ $ dumper ->dump ($ data );
288300 }
289301
290302 private function htmlEncode ($ s )
0 commit comments