Skip to content

Commit 2f04be3

Browse files
committed
Set $output parameter facultative
1 parent b64a8e3 commit 2f04be3

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

DebugBacktraceConsole.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
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

67
class 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
}

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### [2.1.0](../../compare/2.0.1...2.1.0) (2020-05-15)
2+
3+
- Set `DebugBacktraceConsole::dump()` and `DebugBacktraceConsole::eDump()` `$output` parameter facultative
4+
15
### [2.0.1](../../compare/2.0.0...2.0.1) (2017-03-30)
26

37
- Fix caller for \DebugBacktraceHtml and \DebugBacktraceConsole

composer.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
"files": ["DebugBacktrace.php", "DebugBacktraceHtml.php", "DebugBacktraceConsole.php"]
88
},
99
"require": {
10-
"php": "^5.4|^7.0"
11-
},
12-
"repositories": [
13-
{
14-
"type": "vcs",
15-
"url": "https://github.com/steevanb/php-backtrace.git"
16-
}
17-
]
10+
"php": "^5.4|^7.0|^8.0"
11+
}
1812
}

0 commit comments

Comments
 (0)