• 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

78.95
/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
    /** @TODO PHP 8.0 - remove the property */
38
    protected static $defaultName = 'help';
39

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

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

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

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

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

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

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

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

85
        return $allowed;
4✔
86
    }
87

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