Skip to content

Commit

Permalink
get stacktrace from stringified exception
Browse files Browse the repository at this point in the history
  • Loading branch information
wickedOne committed Oct 2, 2021
1 parent 77e2ee1 commit 9e1b41f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/PhpStormPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,16 @@ protected function printDefect(TestFailure $defect, int $count): void
*/
protected function printDefectFooter(TestFailure $defect): void
{
foreach ($defect->thrownException()->getTrace() as $frame) {
if (false === strpos($frame['file'], 'vendor/phpunit/phpunit')) {
$offender = $frame;
$trace = explode(PHP_EOL, trim((string) $defect->thrownException()));
$offender = end($trace);

break;
}
}
[$file, $line] = explode(':', $offender);

if (isset($offender)) {
if (isset($file, $line)) {
$this->write(sprintf(
"✏️ phpstorm://open?file=%s&line=%d\n",
$offender['file'],
$offender['line']
$file,
$line
));
}
}
Expand Down

0 comments on commit 9e1b41f

Please sign in to comment.