diff --git a/src/Command/ErrorFormatter/CheckstyleErrorFormatter.php b/src/Command/ErrorFormatter/CheckstyleErrorFormatter.php index 8120dea1ef..4afb8ca3f1 100644 --- a/src/Command/ErrorFormatter/CheckstyleErrorFormatter.php +++ b/src/Command/ErrorFormatter/CheckstyleErrorFormatter.php @@ -43,11 +43,14 @@ public function formatErrors( $output->writeLineFormatted(''); foreach ($errors as $error) { + + $identifier = $error->getIdentifier(); + $output->writeRaw(sprintf( ' ', $this->escape((string) $error->getLine()), - $this->escape($error->getMessage()), - $error->getIdentifier() !== null ? sprintf(' source="%s"', $this->escape($error->getIdentifier())) : '', + $this->escape($error->getMessage() . ($identifier !== null ? sprintf(' // @phpstan-ignore %s', $identifier) : '')), + $identifier !== null ? sprintf(' source="%s"', $this->escape($identifier)) : '', )); $output->writeLineFormatted(''); } diff --git a/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php index 48e906017c..34f7ef2f46 100644 --- a/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php @@ -186,7 +186,7 @@ public function testIdentifier(): void ), $this->getOutput()); $this->assertXmlStringEqualsXmlString(' - + ', $this->getOutputContent()); }