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

PHP-CS-Fixer / PHP-CS-Fixer / 14011776370

22 Mar 2025 07:40PM UTC coverage: 94.873% (-0.003%) from 94.876%
14011776370

push

github

web-flow
chore: update return type of `FixerOptionInterface::getAllowedValues` (#8530)

28145 of 29666 relevant lines covered (94.87%)

43.2 hits per line

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

76.47
/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
    protected static $defaultName = 'help';
36

37
    /**
38
     * Returns the allowed values of the given option that can be converted to a string.
39
     *
40
     * @return null|list<AllowedValueSubset|mixed>
41
     */
42
    public static function getDisplayableAllowedValues(FixerOptionInterface $option): ?array
43
    {
44
        $allowed = $option->getAllowedValues();
4✔
45

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

49
            usort($allowed, static function ($valueA, $valueB): int {
2✔
50
                if ($valueA instanceof AllowedValueSubset) {
2✔
51
                    return -1;
×
52
                }
53

54
                if ($valueB instanceof AllowedValueSubset) {
2✔
55
                    return 1;
×
56
                }
57

58
                return strcasecmp(
2✔
59
                    Utils::toString($valueA),
2✔
60
                    Utils::toString($valueB)
2✔
61
                );
2✔
62
            });
2✔
63

64
            if (0 === \count($allowed)) {
2✔
65
                $allowed = null;
×
66
            }
67
        }
68

69
        return $allowed;
4✔
70
    }
71

72
    protected function initialize(InputInterface $input, OutputInterface $output): void
73
    {
74
        $output->getFormatter()->setStyle('url', new OutputFormatterStyle('blue'));
×
75
    }
76
}
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