11<?php
22
3- use \Symfony \Component \Console \Output \OutputInterface ;
4- use \Symfony \Component \Console \Helper \Table ;
3+ use Symfony \Component \Console \Output \ConsoleOutput ;
4+ use Symfony \Component \Console \Output \OutputInterface ;
5+ use Symfony \Component \Console \Helper \Table ;
56
67class DebugBacktraceConsole extends \DebugBacktrace
78{
89 /** @var ?string */
910 protected static $ callerRemoveFile = __FILE__ ;
10-
11+
1112 /**
1213 * @param OutputInterface $output
1314 * @param int $offset
1415 * @param int|null $limit
1516 */
16- public static function dump (OutputInterface $ output , $ offset = 0 , $ limit = null )
17+ public static function dump (OutputInterface $ output = null , $ offset = 0 , $ limit = null )
1718 {
19+ $ output = static ::getOutput ($ output );
20+
1821 static ::writeCaller ($ output );
1922
2023 $ table = new Table ($ output );
@@ -30,7 +33,7 @@ public static function dump(OutputInterface $output, $offset = 0, $limit = null)
3033 * @param int $offset
3134 * @param int|null $limit
3235 */
33- public static function eDump (OutputInterface $ output , $ offset = 0 , $ limit = null )
36+ public static function eDump (OutputInterface $ output = null , $ offset = 0 , $ limit = null )
3437 {
3538 static ::dump ($ output , $ offset + 1 , $ limit );
3639 exit ();
@@ -66,4 +69,10 @@ protected static function writeCaller(OutputInterface $output)
6669 $ output ->writeln ('<error>Unkonw caller</error> ' );
6770 }
6871 }
72+
73+ /** @eturn OutputInterface */
74+ protected static function getOutput (OutputInterface $ output )
75+ {
76+ return $ output instanceof OutputInterface ? $ output : new ConsoleOutput ();
77+ }
6978}
0 commit comments