From bbf14bf635e91aad4be81ad6eacc8b18fb3b31ed Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Wed, 23 Feb 2022 09:52:32 +0100 Subject: [PATCH] Nicer clickable URL --- src/Command/ErrorFormatter/TableErrorFormatter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Command/ErrorFormatter/TableErrorFormatter.php b/src/Command/ErrorFormatter/TableErrorFormatter.php index 4c8f79c6c1..a9a61effe0 100644 --- a/src/Command/ErrorFormatter/TableErrorFormatter.php +++ b/src/Command/ErrorFormatter/TableErrorFormatter.php @@ -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; @@ -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) { @@ -75,7 +77,7 @@ public function formatErrors( } if (is_string($this->editorUrl)) { $url = str_replace(['%file%', '%line%'], [$error->getTraitFilePath() ?? $error->getFilePath(), (string) $error->getLine()], $this->editorUrl); - $message .= "\n✏️ ' . $url . ''; + $message .= "\n✏️ ' . $relativeFilePath . ''; } $rows[] = [ (string) $error->getLine(), @@ -83,8 +85,6 @@ public function formatErrors( ]; } - $relativeFilePath = $this->relativePathHelper->getRelativePath($file); - $style->table(['Line', $relativeFilePath], $rows); }