Skip to content

Commit bbf14bf

Browse files
committed
Nicer clickable URL
1 parent d420d05 commit bbf14bf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Command/ErrorFormatter/TableErrorFormatter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPStan\Command\AnalysisResult;
88
use PHPStan\Command\Output;
99
use PHPStan\File\RelativePathHelper;
10+
use Symfony\Component\Console\Formatter\OutputFormatter;
1011
use function array_map;
1112
use function count;
1213
use function is_string;
@@ -66,6 +67,7 @@ public function formatErrors(
6667

6768
foreach ($fileErrors as $file => $errors) {
6869
$rows = [];
70+
$relativeFilePath = $this->relativePathHelper->getRelativePath($file);
6971
foreach ($errors as $error) {
7072
$message = $error->getMessage();
7173
if ($error->getTip() !== null) {
@@ -75,16 +77,14 @@ public function formatErrors(
7577
}
7678
if (is_string($this->editorUrl)) {
7779
$url = str_replace(['%file%', '%line%'], [$error->getTraitFilePath() ?? $error->getFilePath(), (string) $error->getLine()], $this->editorUrl);
78-
$message .= "\n✏️ <href=" . $url . '>' . $url . '</>';
80+
$message .= "\n✏️ <href=" . OutputFormatter::escape($url) . '>' . $relativeFilePath . '</>';
7981
}
8082
$rows[] = [
8183
(string) $error->getLine(),
8284
$message,
8385
];
8486
}
8587

86-
$relativeFilePath = $this->relativePathHelper->getRelativePath($file);
87-
8888
$style->table(['Line', $relativeFilePath], $rows);
8989
}
9090

0 commit comments

Comments
 (0)