Skip to content

Commit 5d2cc9a

Browse files
staabmCopilot
andcommitted
Improve GitHub error annotations
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1de5e32 commit 5d2cc9a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/Command/ErrorFormatter/GithubErrorFormatter.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ private function buildFileSpecificMessage(Error $error, OutputFormatter $tipForm
9191
{
9292
$message = $error->getMessage();
9393
if ($error->getFixedErrorDiffs() !== []) {
94-
$message .= ' 🔧';
94+
$message .= "\n🔧 Can be fixed automatically. Run PHPStan again with --fix.";
9595
}
9696

9797
$identifier = $error->getIdentifier();
9898
if ($identifier !== null) {
99-
$message .= "\n🪪 " . $identifier;
99+
$message .= sprintf("\n🪪 [%s](https://phpstan.org/error-identifiers/%s)", $identifier, $identifier);
100100
if (!$error->canBeIgnored()) {
101101
$message .= ' (non-ignorable)';
102102
}

‎tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public function testFormatErrorsLikeTable(): void
131131
));
132132

133133
$this->assertSame(
134-
'::error file=foo.php,line=1,col=0::Fixable error 🔧%0A🪪 foo.bar
135-
::error file=foo.php,line=2,col=0::Non-ignorable error%0A🪪 foo.baz (non-ignorable)
134+
'::error file=foo.php,line=1,col=0::Fixable error%0A🔧 Can be fixed automatically. Run PHPStan again with --fix.%0A🪪 [foo.bar](https://phpstan.org/error-identifiers/foo.bar)
135+
::error file=foo.php,line=2,col=0::Non-ignorable error%0A🪪 [foo.baz](https://phpstan.org/error-identifiers/foo.baz) (non-ignorable)
136136
::error file=foo.php,line=3,col=0::Multi-line tip%0A💡 First line%0A💡 Second line in phpstan.neon
137137
::error file=foo.php,line=4,col=0::Tip with type%0A💡 Use array<int, string> instead.
138138
',

0 commit comments

Comments
 (0)