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

PHP-CS-Fixer / PHP-CS-Fixer / 3832405332

pending completion
3832405332

push

github

GitHub
minor: improve rule sets order (#6738)

1 of 1 new or added line in 1 file covered. (100.0%)

22556 of 24273 relevant lines covered (92.93%)

39.1 hits per line

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

53.85
/src/RuleSet/RuleSets.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\RuleSet;
16

17
use Symfony\Component\Finder\Finder;
18

19
/**
20
 * Set of rule sets to be used by fixer.
21
 *
22
 * @internal
23
 */
24
final class RuleSets
25
{
26
    /**
27
     * @var array<string,RuleSetDescriptionInterface>
28
     */
29
    private static $setDefinitions;
30

31
    /**
32
     * @return array<string, RuleSetDescriptionInterface>
33
     */
34
    public static function getSetDefinitions(): array
35
    {
36
        if (null === self::$setDefinitions) {
56✔
37
            self::$setDefinitions = [];
×
38

39
            foreach (Finder::create()->files()->in(__DIR__.'/Sets') as $file) {
×
40
                $class = 'PhpCsFixer\RuleSet\Sets\\'.$file->getBasename('.php');
×
41
                $set = new $class();
×
42

43
                self::$setDefinitions[$set->getName()] = $set;
×
44
            }
45

46
            uksort(self::$setDefinitions, static fn (string $x, string $y): int => strnatcmp($x, $y));
×
47
        }
48

49
        return self::$setDefinitions;
56✔
50
    }
51

52
    /**
53
     * @return string[]
54
     */
55
    public static function getSetDefinitionNames(): array
56
    {
57
        return array_keys(self::getSetDefinitions());
1✔
58
    }
59

60
    public static function getSetDefinition(string $name): RuleSetDescriptionInterface
61
    {
62
        $definitions = self::getSetDefinitions();
16✔
63

64
        if (!isset($definitions[$name])) {
16✔
65
            throw new \InvalidArgumentException(sprintf('Set "%s" does not exist.', $name));
1✔
66
        }
67

68
        return $definitions[$name];
15✔
69
    }
70
}
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