Skip to content

Commit c150b4e

Browse files
Adding editorUrl to add clickable file urls to output (v2)
1 parent 00ff86b commit c150b4e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

conf/config.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ parameters:
150150
- PHP_SHLIB_SUFFIX
151151
- PHP_FD_SETSIZE
152152
- OPENSSL_VERSION_NUMBER
153+
editorUrl: null
153154

154155
extensions:
155156
rules: PHPStan\DependencyInjection\RulesExtension
@@ -299,6 +300,7 @@ parametersSchema:
299300
scanFiles: listOf(string())
300301
scanDirectories: listOf(string())
301302
fixerTmpDir: string()
303+
editorUrl: schema(string(), nullable())
302304

303305
# irrelevant Nette parameters
304306
debugMode: bool()
@@ -1560,6 +1562,7 @@ services:
15601562
class: PHPStan\Command\ErrorFormatter\TableErrorFormatter
15611563
arguments:
15621564
showTipsOfTheDay: %tipsOfTheDay%
1565+
editorUrl: %editorUrl%
15631566

15641567
errorFormatter.checkstyle:
15651568
class: PHPStan\Command\ErrorFormatter\CheckstyleErrorFormatter

phpstan-baseline.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,3 @@ parameters:
289289
message: "#^Method PHPStan\\\\Node\\\\FileNodeTest\\:\\:getRule\\(\\) return type with generic interface PHPStan\\\\Rules\\\\Rule does not specify its types\\: TNodeType$#"
290290
count: 1
291291
path: tests/PHPStan/Node/FileNodeTest.php
292-

src/Command/ErrorFormatter/TableErrorFormatter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ class TableErrorFormatter implements ErrorFormatter
1313
private RelativePathHelper $relativePathHelper;
1414

1515
private bool $showTipsOfTheDay;
16+
private ?string $editorUrl;
1617

1718
public function __construct(
1819
RelativePathHelper $relativePathHelper,
19-
bool $showTipsOfTheDay
20+
bool $showTipsOfTheDay,
21+
?string $editorUrl
2022
)
2123
{
2224
$this->relativePathHelper = $relativePathHelper;
2325
$this->showTipsOfTheDay = $showTipsOfTheDay;
26+
$this->editorUrl = $editorUrl;
2427
}
2528

2629
public function formatErrors(
@@ -71,6 +74,9 @@ public function formatErrors(
7174
$tip = str_replace('%configurationFile%', $projectConfigFile, $tip);
7275
$message .= "\n💡 " . $tip;
7376
}
77+
if (is_string($this->editorUrl)) {
78+
$message .= "\n " . str_replace(['%file%', '%line%'], [$file, (string) $error->getLine()], $this->editorUrl);
79+
}
7480
$rows[] = [
7581
(string) $error->getLine(),
7682
$message,

0 commit comments

Comments
 (0)