• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

keradus / PHP-CS-Fixer / 17252691116

26 Aug 2025 11:09PM UTC coverage: 94.743% (-0.01%) from 94.755%
17252691116

push

github

keradus
chore: apply phpdoc_tag_no_named_arguments

28313 of 29884 relevant lines covered (94.74%)

45.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/Console/Report/FixReport/CheckstyleReporter.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of PHP CS Fixer.
7
 *
8
 * (c) Fabien Potencier <fabien@symfony.com>
9
 *     Dariusz Rumiński <dariusz.ruminski@gmail.com>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14

15
namespace PhpCsFixer\Console\Report\FixReport;
16

17
use PhpCsFixer\Console\Application;
18
use Symfony\Component\Console\Formatter\OutputFormatter;
19

20
/**
21
 * @author Kévin Gomez <contact@kevingomez.fr>
22
 *
23
 * @readonly
24
 *
25
 * @internal
26
 *
27
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
28
 */
29
final class CheckstyleReporter implements ReporterInterface
30
{
31
    public function getFormat(): string
32
    {
33
        return 'checkstyle';
1✔
34
    }
35

36
    public function generate(ReportSummary $reportSummary): string
37
    {
38
        if (!\extension_loaded('dom')) {
6✔
39
            throw new \RuntimeException('Cannot generate report! `ext-dom` is not available!');
×
40
        }
41

42
        $dom = new \DOMDocument('1.0', 'UTF-8');
6✔
43

44
        /** @var \DOMElement $checkstyles */
45
        $checkstyles = $dom->appendChild($dom->createElement('checkstyle'));
6✔
46
        $checkstyles->setAttribute('version', Application::getAbout());
6✔
47

48
        foreach ($reportSummary->getChanged() as $filePath => $fixResult) {
6✔
49
            /** @var \DOMElement $file */
50
            $file = $checkstyles->appendChild($dom->createElement('file'));
5✔
51
            $file->setAttribute('name', $filePath);
5✔
52

53
            foreach ($fixResult['appliedFixers'] as $appliedFixer) {
5✔
54
                $error = $this->createError($dom, $appliedFixer);
5✔
55
                $file->appendChild($error);
5✔
56
            }
57
        }
58

59
        $dom->formatOutput = true;
6✔
60

61
        $result = $dom->saveXML();
6✔
62
        if (false === $result) {
6✔
63
            throw new \RuntimeException('Failed to generate XML output');
×
64
        }
65

66
        return $reportSummary->isDecoratedOutput() ? OutputFormatter::escape($result) : $result;
6✔
67
    }
68

69
    private function createError(\DOMDocument $dom, string $appliedFixer): \DOMElement
70
    {
71
        $error = $dom->createElement('error');
5✔
72
        $error->setAttribute('severity', 'warning');
5✔
73
        $error->setAttribute('source', 'PHP-CS-Fixer.'.$appliedFixer);
5✔
74
        $error->setAttribute('message', 'Found violation(s) of type: '.$appliedFixer);
5✔
75

76
        return $error;
5✔
77
    }
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc