These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use \Symfony\Component\Console\Output\OutputInterface; |
||
4 | use \Symfony\Component\Console\Helper\Table; |
||
5 | |||
6 | class DebugBacktraceConsole extends \DebugBacktrace |
||
0 ignored issues
–
show
|
|||
7 | { |
||
8 | /** @var ?string */ |
||
9 | protected static $callerRemoveFile = __FILE__; |
||
10 | |||
11 | /** |
||
12 | * @param OutputInterface $output |
||
13 | * @param int $offset |
||
14 | * @param int|null $limit |
||
15 | */ |
||
16 | public static function dump(OutputInterface $output, $offset = 0, $limit = null) |
||
17 | { |
||
18 | static::writeCaller($output); |
||
19 | |||
20 | $table = new Table($output); |
||
21 | $table->setHeaders(['#', 'file', 'line', 'call']); |
||
22 | foreach (static::getBacktraces($offset, $limit) as $index => $backtrace) { |
||
23 | static::writeBacktraceDump($table, $backtrace, $index); |
||
24 | } |
||
25 | $table->render(); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param OutputInterface $output |
||
30 | * @param int $offset |
||
31 | * @param int|null $limit |
||
32 | */ |
||
33 | public static function eDump(OutputInterface $output, $offset = 0, $limit = null) |
||
34 | { |
||
35 | static::dump($output, $offset + 1, $limit); |
||
36 | exit(); |
||
0 ignored issues
–
show
The method
eDump() contains an exit expression.
An exit expression should only be used in rare cases. For example, if you write a short command line script. In most cases however, using an ![]() |
|||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param Table $table |
||
41 | * @param array $backtrace |
||
42 | * @param int $index |
||
43 | */ |
||
44 | protected static function writeBacktraceDump(Table $table, array $backtrace, $index) |
||
45 | { |
||
46 | $table->addRow([ |
||
47 | $index + 1, |
||
48 | static::getFilePath($backtrace['file']), |
||
49 | $backtrace['line'], |
||
50 | $backtrace['call'] |
||
51 | ]); |
||
52 | } |
||
53 | |||
54 | /** @param OutputInterface $output */ |
||
55 | protected static function writeCaller(OutputInterface $output) |
||
56 | { |
||
57 | $caller = static::getCaller(); |
||
58 | |||
59 | if (is_array($caller)) { |
||
60 | $output->writeln( |
||
61 | 'From ' |
||
62 | . '<info>' . $caller['file'] . '</info>' |
||
63 | . '<comment>#' . $caller['line'] . '</comment>' |
||
64 | ); |
||
65 | } else { |
||
66 | $output->writeln('<error>Unkonw caller</error>'); |
||
67 | } |
||
68 | } |
||
69 | } |
||
70 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.