Skip to content

Commit

Permalink
Nicer clickable URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Feb 23, 2022
1 parent d420d05 commit bbf14bf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Command/ErrorFormatter/TableErrorFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPStan\Command\AnalysisResult;
use PHPStan\Command\Output;
use PHPStan\File\RelativePathHelper;
use Symfony\Component\Console\Formatter\OutputFormatter;
use function array_map;
use function count;
use function is_string;
Expand Down Expand Up @@ -66,6 +67,7 @@ public function formatErrors(

foreach ($fileErrors as $file => $errors) {
$rows = [];
$relativeFilePath = $this->relativePathHelper->getRelativePath($file);
foreach ($errors as $error) {
$message = $error->getMessage();
if ($error->getTip() !== null) {
Expand All @@ -75,16 +77,14 @@ public function formatErrors(
}
if (is_string($this->editorUrl)) {
$url = str_replace(['%file%', '%line%'], [$error->getTraitFilePath() ?? $error->getFilePath(), (string) $error->getLine()], $this->editorUrl);
$message .= "\n✏️ <href=" . $url . '>' . $url . '</>';
$message .= "\n✏️ <href=" . OutputFormatter::escape($url) . '>' . $relativeFilePath . '</>';
}
$rows[] = [
(string) $error->getLine(),
$message,
];
}

$relativeFilePath = $this->relativePathHelper->getRelativePath($file);

$style->table(['Line', $relativeFilePath], $rows);
}

Expand Down

0 comments on commit bbf14bf

Please sign in to comment.