• 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

82.14
/src/Console/Command/ListSetsCommand.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\Command;
16

17
use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
18
use PhpCsFixer\Console\Report\ListSetsReport\ReporterFactory;
19
use PhpCsFixer\Console\Report\ListSetsReport\ReporterInterface;
20
use PhpCsFixer\Console\Report\ListSetsReport\ReportSummary;
21
use PhpCsFixer\Console\Report\ListSetsReport\TextReporter;
22
use PhpCsFixer\RuleSet\RuleSets;
23
use PhpCsFixer\Utils;
24
use Symfony\Component\Console\Attribute\AsCommand;
25
use Symfony\Component\Console\Command\Command;
26
use Symfony\Component\Console\Formatter\OutputFormatter;
27
use Symfony\Component\Console\Input\InputInterface;
28
use Symfony\Component\Console\Input\InputOption;
29
use Symfony\Component\Console\Output\OutputInterface;
30

31
/**
32
 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
33
 *
34
 * @internal
35
 *
36
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
37
 */
38
#[AsCommand(name: 'list-sets', description: 'List all available RuleSets.')]
39
final class ListSetsCommand extends Command
40
{
41
    /** @TODO PHP 8.0 - remove the property */
42
    protected static $defaultName = 'list-sets';
43

44
    /** @TODO PHP 8.0 - remove the property */
45
    protected static $defaultDescription = 'List all available RuleSets.';
46

47
    protected function configure(): void
48
    {
49
        $reporterFactory = new ReporterFactory();
2✔
50
        $reporterFactory->registerBuiltInReporters();
2✔
51
        $formats = $reporterFactory->getFormats();
2✔
52
        \assert([] !== $formats);
2✔
53

54
        $this->setDefinition(
2✔
55
            [
2✔
56
                new InputOption('format', '', InputOption::VALUE_REQUIRED, HelpCommand::getDescriptionWithAllowedValues('To output results in other formats (%s).', $formats), (new TextReporter())->getFormat(), $formats),
2✔
57
            ]
2✔
58
        );
2✔
59
    }
60

61
    protected function execute(InputInterface $input, OutputInterface $output): int
62
    {
63
        $reporter = $this->resolveReporterWithFactory(
2✔
64
            $input->getOption('format'),
2✔
65
            new ReporterFactory()
2✔
66
        );
2✔
67

68
        $reportSummary = new ReportSummary(
2✔
69
            array_values(RuleSets::getSetDefinitions())
2✔
70
        );
2✔
71

72
        $report = $reporter->generate($reportSummary);
2✔
73

74
        $output->isDecorated()
2✔
75
            ? $output->write(OutputFormatter::escape($report))
×
76
            : $output->write($report, false, OutputInterface::OUTPUT_RAW);
2✔
77

78
        return 0;
2✔
79
    }
80

81
    private function resolveReporterWithFactory(string $format, ReporterFactory $factory): ReporterInterface
82
    {
83
        try {
84
            $factory->registerBuiltInReporters();
2✔
85
            $reporter = $factory->getReporter($format);
2✔
86
        } catch (\UnexpectedValueException $e) {
×
87
            $formats = $factory->getFormats();
×
88
            sort($formats);
×
89

90
            throw new InvalidConfigurationException(\sprintf('The format "%s" is not defined, supported are %s.', $format, Utils::naturalLanguageJoin($formats)));
×
91
        }
92

93
        return $reporter;
2✔
94
    }
95
}
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