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

PHP-CS-Fixer / PHP-CS-Fixer / 22808552760

07 Mar 2026 10:26PM UTC coverage: 92.913% (-0.01%) from 92.925%
22808552760

push

github

web-flow
chore: commands cleanup (#9478)

14 of 23 new or added lines in 12 files covered. (60.87%)

1 existing line in 1 file now uncovered.

29395 of 31637 relevant lines covered (92.91%)

43.93 hits per line

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

75.0
/src/Console/Command/HelpCommand.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\FixerConfiguration\AllowedValueSubset;
18
use PhpCsFixer\FixerConfiguration\FixerOptionInterface;
19
use PhpCsFixer\Utils;
20
use Symfony\Component\Console\Attribute\AsCommand;
21
use Symfony\Component\Console\Command\HelpCommand as BaseHelpCommand;
22
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
23
use Symfony\Component\Console\Input\InputInterface;
24
use Symfony\Component\Console\Output\OutputInterface;
25

26
/**
27
 * @author Fabien Potencier <fabien@symfony.com>
28
 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
29
 *
30
 * @internal
31
 *
32
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
33
 */
34
#[AsCommand(name: 'help')]
35
final class HelpCommand extends BaseHelpCommand
36
{
37
    public function __construct()
38
    {
NEW
39
        parent::__construct('help');
×
40
    }
41

42
    /**
43
     * Formats the description of an option to include its allowed values.
44
     *
45
     * @param string                 $description   description with a single `%s` placeholder for the allowed values
46
     * @param non-empty-list<string> $allowedValues
47
     */
48
    public static function getDescriptionWithAllowedValues(string $description, array $allowedValues): string
49
    {
50
        $allowedValues = Utils::naturalLanguageJoinWithBackticks($allowedValues, 'or');
2✔
51

52
        return \sprintf($description, 'can be '.$allowedValues);
2✔
53
    }
54

55
    /**
56
     * Returns the allowed values of the given option that can be converted to a string.
57
     *
58
     * @return null|non-empty-list<AllowedValueSubset|mixed>
59
     */
60
    public static function getDisplayableAllowedValues(FixerOptionInterface $option): ?array
61
    {
62
        $allowed = $option->getAllowedValues();
4✔
63

64
        if (null !== $allowed) {
4✔
65
            $allowed = array_filter($allowed, static fn ($value): bool => !$value instanceof \Closure);
2✔
66

67
            usort($allowed, static function ($valueA, $valueB): int {
2✔
68
                if ($valueA instanceof AllowedValueSubset) {
2✔
69
                    return -1;
×
70
                }
71

72
                if ($valueB instanceof AllowedValueSubset) {
2✔
73
                    return 1;
×
74
                }
75

76
                return strcasecmp(
2✔
77
                    Utils::toString($valueA),
2✔
78
                    Utils::toString($valueB),
2✔
79
                );
2✔
80
            });
2✔
81

82
            if (0 === \count($allowed)) {
2✔
83
                $allowed = null;
×
84
            }
85
        }
86

87
        return $allowed;
4✔
88
    }
89

90
    protected function initialize(InputInterface $input, OutputInterface $output): void
91
    {
92
        $output->getFormatter()->setStyle('url', new OutputFormatterStyle('blue'));
×
93
    }
94
}
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