Skip to content

Commit

Permalink
Support for relative paths in editorUrl
Browse files Browse the repository at this point in the history
This allows running PHPStan within Docker environment and output errors with links to files on the host (`editorUrl` must be configured using actual host's path to the project + `%rel_file%`).

Fixes phpstan/phpstan#7043
  • Loading branch information
Wirone committed Jun 11, 2022
1 parent 943d95e commit 723ba37
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Command/ErrorFormatter/TableErrorFormatter.php
Expand Up @@ -78,7 +78,11 @@ public function formatErrors(
}
if (is_string($this->editorUrl)) {
$editorFile = $error->getTraitFilePath() ?? $error->getFilePath();
$url = str_replace(['%file%', '%line%'], [$editorFile, (string) $error->getLine()], $this->editorUrl);
$url = str_replace(
['%file%', '%rel_file%', '%line%'],
[$editorFile, $this->relativePathHelper->getRelativePath($editorFile), (string) $error->getLine()],
$this->editorUrl,
);
$message .= "\n✏️ <href=" . OutputFormatter::escape($url) . '>' . $this->relativePathHelper->getRelativePath($editorFile) . '</>';
}
$rows[] = [
Expand Down

0 comments on commit 723ba37

Please sign in to comment.