1
1
<?php
2
2
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 ;
5
6
6
7
class DebugBacktraceConsole extends \DebugBacktrace
7
8
{
8
9
/** @var ?string */
9
10
protected static $ callerRemoveFile = __FILE__ ;
10
-
11
+
11
12
/**
12
13
* @param OutputInterface $output
13
14
* @param int $offset
14
15
* @param int|null $limit
15
16
*/
16
- public static function dump (OutputInterface $ output , $ offset = 0 , $ limit = null )
17
+ public static function dump (OutputInterface $ output = null , $ offset = 0 , $ limit = null )
17
18
{
19
+ $ output = static ::getOutput ($ output );
20
+
18
21
static ::writeCaller ($ output );
19
22
20
23
$ table = new Table ($ output );
@@ -30,7 +33,7 @@ public static function dump(OutputInterface $output, $offset = 0, $limit = null)
30
33
* @param int $offset
31
34
* @param int|null $limit
32
35
*/
33
- public static function eDump (OutputInterface $ output , $ offset = 0 , $ limit = null )
36
+ public static function eDump (OutputInterface $ output = null , $ offset = 0 , $ limit = null )
34
37
{
35
38
static ::dump ($ output , $ offset + 1 , $ limit );
36
39
exit ();
@@ -66,4 +69,10 @@ protected static function writeCaller(OutputInterface $output)
66
69
$ output ->writeln ('<error>Unkonw caller</error> ' );
67
70
}
68
71
}
72
+
73
+ /** @eturn OutputInterface */
74
+ protected static function getOutput (OutputInterface $ output )
75
+ {
76
+ return $ output instanceof OutputInterface ? $ output : new ConsoleOutput ();
77
+ }
69
78
}
0 commit comments