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

keradus / PHP-CS-Fixer / 16999983712

15 Aug 2025 09:42PM UTC coverage: 94.75% (-0.09%) from 94.839%
16999983712

push

github

keradus
ci: more self-fixing checks on lowest/highest PHP

28263 of 29829 relevant lines covered (94.75%)

45.88 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
#[AsCommand(name: 'help')]
33
final class HelpCommand extends BaseHelpCommand
34
{
35
    /** @TODO PHP 8.0 - remove the property */
36
    protected static $defaultName = 'help';
37

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

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

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

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

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

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

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

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

83
        return $allowed;
4✔
84
    }
85

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