Skip to content

Commit d9402bd

Browse files
committed
refactor(formatters): added error identifier to actual checkstyle the message
1 parent 6bdce5d commit d9402bd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Command/ErrorFormatter/CheckstyleErrorFormatter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ public function formatErrors(
4343
$output->writeLineFormatted('');
4444

4545
foreach ($errors as $error) {
46+
47+
$identifier = null !== $error->getIdentifier()
48+
? " // @phpstan-ignore {$error->getIdentifier()}" :
49+
'';
50+
4651
$output->writeRaw(sprintf(
4752
' <error line="%d" column="1" severity="error" message="%s"%s />',
4853
$this->escape((string) $error->getLine()),
49-
$this->escape($error->getMessage()),
54+
$this->escape($error->getMessage() . $identifier),
5055
$error->getIdentifier() !== null ? sprintf(' source="%s"', $this->escape($error->getIdentifier())) : '',
5156
));
5257
$output->writeLineFormatted('');

tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function testIdentifier(): void
186186
), $this->getOutput());
187187
$this->assertXmlStringEqualsXmlString('<checkstyle>
188188
<file name="Foo.php">
189-
<error column="1" line="5" message="Foo" severity="error" source="argument.type" />
189+
<error column="1" line="5" message="Foo // @phpstan-ignore argument.type" severity="error" source="argument.type" />
190190
</file>
191191
</checkstyle>', $this->getOutputContent());
192192
}

0 commit comments

Comments
 (0)