diff --git a/build/target-repository/README.md b/build/target-repository/README.md
index 6880cbb902..5e5f718a41 100644
--- a/build/target-repository/README.md
+++ b/build/target-repository/README.md
@@ -214,12 +214,11 @@ We currently provide formatters for:
- `console`: Human-oriented printing à la PHP CS Fixer.
- `json`: A custom JSON blob for arbitrary tooling.
-- `checkstyle`: Useful for Github Action Reports.
You can use the output format option as below
```bash
-vendor/bin/ecs --output-format=checkstyle
+vendor/bin/ecs --output-format=json
```
diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json
index 70133e5961..09c7726ea0 100644
--- a/build/target-repository/composer.json
+++ b/build/target-repository/composer.json
@@ -18,8 +18,5 @@
"symplify/coding-standard": "<13.0",
"phpcsstandards/php_codesniffer": "<4.0.4",
"friendsofphp/php-cs-fixer": "<3.95.20"
- },
- "suggest": {
- "ext-dom": "Needed to support checkstyle output format in class CheckstyleOutputFormatter"
}
}
diff --git a/src/Console/Output/CheckstyleOutputFormatter.php b/src/Console/Output/CheckstyleOutputFormatter.php
deleted file mode 100644
index a19f4321bb..0000000000
--- a/src/Console/Output/CheckstyleOutputFormatter.php
+++ /dev/null
@@ -1,93 +0,0 @@
-createCheckstyleContent(
- $errorAndDiffResult,
- false
- );
- $this->easyCodingStandardStyle->writeln($checkstyleContent);
-
- return $this->exitCodeResolver->resolve($errorAndDiffResult, $configuration);
- }
-
- public static function getName(): string
- {
- return 'checkstyle';
- }
-
- public static function hasSupportForProgressBars(): bool
- {
- return false;
- }
-
- /**
- * @api
- */
- public function createCheckstyleContent(
- ErrorAndDiffResult $errorAndDiffResult,
- bool $absoluteFilePath = false
- ): string {
- if (! \extension_loaded('dom')) {
- throw new RuntimeException('Cannot generate report! `ext-dom` is not available!');
- }
-
- $domDocument = new DOMDocument('1.0', 'UTF-8');
-
- /** @var DOMElement $domNode */
- $domNode = $domDocument->appendChild($domDocument->createElement('checkstyle'));
-
- foreach ($errorAndDiffResult->getFileDiffs() as $fileDiff) {
- $filePath = $absoluteFilePath ? $fileDiff->getAbsoluteFilePath() : $fileDiff->getRelativeFilePath();
- /** @var DOMElement $file */
- $file = $domNode->appendChild($domDocument->createElement('file'));
- $file->setAttribute('name', $filePath ?? '');
-
- foreach ($fileDiff->getAppliedCheckers() as $appliedChecker) {
- $errorElement = $this->createError($domDocument, $appliedChecker);
- $file->appendChild($errorElement);
- }
- }
-
- $domDocument->formatOutput = true;
-
- return (string) $domDocument->saveXML();
- }
-
- private function createError(DOMDocument $domDocument, string $appliedChecker): DOMElement
- {
- $domElement = $domDocument->createElement('error');
- $domElement->setAttribute('severity', 'warning');
- $domElement->setAttribute('source', 'EasyCodingStandard.' . $appliedChecker);
- $domElement->setAttribute('message', 'Found violation(s) of type: ' . $appliedChecker);
-
- return $domElement;
- }
-}
diff --git a/src/Console/Output/OutputFormatterCollector.php b/src/Console/Output/OutputFormatterCollector.php
index 36d42c3d2d..87a4d35e43 100644
--- a/src/Console/Output/OutputFormatterCollector.php
+++ b/src/Console/Output/OutputFormatterCollector.php
@@ -18,6 +18,7 @@ final class OutputFormatterCollector
private const array REMOVED_FORMATS = [
'junit' => ConsoleOutputFormatter::NAME,
'gitlab' => ConsoleOutputFormatter::NAME,
+ 'checkstyle' => ConsoleOutputFormatter::NAME,
];
/**
diff --git a/tests/Console/Output/CheckstyleOutputFormatterTest.php b/tests/Console/Output/CheckstyleOutputFormatterTest.php
deleted file mode 100644
index 01bf28c661..0000000000
--- a/tests/Console/Output/CheckstyleOutputFormatterTest.php
+++ /dev/null
@@ -1,61 +0,0 @@
-checkstyleOutputFormatter = $this->make(CheckstyleOutputFormatter::class);
- $this->colorConsoleDiffFormatter = $this->make(ColorConsoleDiffFormatter::class);
- }
-
- public function test(): void
- {
- $relativeFilePath = StaticRelativeFilePathHelper::resolveFromCwd(__DIR__ . '/Source/RandomFile.php');
-
- $fileDiffs = [];
-
- $diff = 'some diff';
- $fileDiffs[] = new FileDiff(
- $relativeFilePath,
- $diff,
- $this->colorConsoleDiffFormatter->format($diff),
- [LineLengthFixer::class]
- );
-
- $diff = 'some other diff';
- $fileDiffs[] = new FileDiff(
- $relativeFilePath,
- $diff,
- $this->colorConsoleDiffFormatter->format($diff),
- [LineLengthFixer::class]
- );
-
- $errorAndDiffResult = new ErrorAndDiffResult([], $fileDiffs, []);
-
- $checkstyleContent = $this->checkstyleOutputFormatter->createCheckstyleContent($errorAndDiffResult);
- $this->assertStringMatchesFormatFile(
- __DIR__ . '/Fixture/expected_checkstyle_output.xml',
- $checkstyleContent . PHP_EOL
- );
- }
-}
diff --git a/tests/Console/Output/Fixture/expected_checkstyle_output.xml b/tests/Console/Output/Fixture/expected_checkstyle_output.xml
deleted file mode 100644
index 9c08d4e96d..0000000000
--- a/tests/Console/Output/Fixture/expected_checkstyle_output.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/tests/Console/Output/OutputFormatterCollectorTest.php b/tests/Console/Output/OutputFormatterCollectorTest.php
index 20cde93a48..51b4ef12f9 100644
--- a/tests/Console/Output/OutputFormatterCollectorTest.php
+++ b/tests/Console/Output/OutputFormatterCollectorTest.php
@@ -4,7 +4,6 @@
namespace Symplify\EasyCodingStandard\Tests\Console\Output;
-use Symplify\EasyCodingStandard\Console\Output\CheckstyleOutputFormatter;
use Symplify\EasyCodingStandard\Console\Output\ConsoleOutputFormatter;
use Symplify\EasyCodingStandard\Console\Output\JsonOutputFormatter;
use Symplify\EasyCodingStandard\Console\Output\OutputFormatterCollector;
@@ -31,10 +30,6 @@ public function test(): void
JsonOutputFormatter::class,
$this->outputFormatterCollector->getByName(JsonOutputFormatter::getName())
);
- $this->assertInstanceOf(
- CheckstyleOutputFormatter::class,
- $this->outputFormatterCollector->getByName(CheckstyleOutputFormatter::getName())
- );
}
public function testRemovedJUnitFormatFallsBackToConsole(): void
@@ -52,4 +47,12 @@ public function testRemovedGitlabFormatFallsBackToConsole(): void
$this->outputFormatterCollector->getByName('gitlab')
);
}
+
+ public function testRemovedCheckstyleFormatFallsBackToConsole(): void
+ {
+ $this->assertInstanceOf(
+ ConsoleOutputFormatter::class,
+ $this->outputFormatterCollector->getByName('checkstyle')
+ );
+ }
}