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

keradus / PHP-CS-Fixer / 19958239208

05 Dec 2025 09:13AM UTC coverage: 93.181% (-1.0%) from 94.158%
19958239208

push

github

keradus
chore: .php-cs-fixer.dist.php - remove no longer needed rule, 'expectedDeprecation' annotation does not exist for long time

28928 of 31045 relevant lines covered (93.18%)

44.49 hits per line

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

56.25
/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 PhpCsFixer\RuleSetNameValidator;
18
use Symfony\Component\Finder\Finder;
19

20
/**
21
 * Set of rule sets to be used by fixer.
22
 *
23
 * @internal
24
 *
25
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
26
 */
27
final class RuleSets
28
{
29
    /**
30
     * @var null|array<string, RuleSetDefinitionInterface>
31
     */
32
    private static ?array $builtInSetDefinitions = null;
33

34
    /**
35
     * @var array<string, RuleSetDefinitionInterface>
36
     */
37
    private static array $customRuleSetDefinitions = [];
38

39
    /**
40
     * @return array<string, RuleSetDefinitionInterface>
41
     */
42
    public static function getSetDefinitions(): array
43
    {
44
        $allRuleSets = array_merge(
156✔
45
            self::getBuiltInSetDefinitions(),
156✔
46
            self::$customRuleSetDefinitions
156✔
47
        );
156✔
48

49
        uksort($allRuleSets, static fn (string $x, string $y): int => strnatcmp($x, $y));
156✔
50

51
        return $allRuleSets;
156✔
52
    }
53

54
    /**
55
     * @return array<string, RuleSetDefinitionInterface>
56
     */
57
    public static function getBuiltInSetDefinitions(): array
58
    {
59
        if (null === self::$builtInSetDefinitions) {
156✔
60
            self::$builtInSetDefinitions = [];
×
61

62
            $finder = Finder::create()
×
63
                ->files()
×
64
                ->in(__DIR__.'/Sets')
×
65
                ->exclude('Internal/')
×
66
            ;
×
67

68
            foreach ($finder as $file) {
×
69
                /** @var class-string<RuleSetDefinitionInterface> $class */
70
                $class = 'PhpCsFixer\RuleSet\Sets\\'.$file->getBasename('.php');
×
71

72
                /** @var RuleSetDefinitionInterface */
73
                $set = new $class();
×
74

75
                if (!RuleSetNameValidator::isValid($set->getName(), false)) {
×
76
                    throw new \InvalidArgumentException(\sprintf('Rule set name invalid: %s', $set->getName()));
×
77
                }
78

79
                self::$builtInSetDefinitions[$set->getName()] = $set;
×
80
            }
81

82
            uksort(self::$builtInSetDefinitions, static fn (string $x, string $y): int => strnatcmp($x, $y));
×
83
        }
84

85
        return self::$builtInSetDefinitions;
156✔
86
    }
87

88
    /**
89
     * @return list<string>
90
     */
91
    public static function getSetDefinitionNames(): array
92
    {
93
        return array_keys(self::getSetDefinitions());
1✔
94
    }
95

96
    public static function getSetDefinition(string $name): RuleSetDefinitionInterface
97
    {
98
        $definitions = self::getSetDefinitions();
19✔
99

100
        if (!isset($definitions[$name])) {
19✔
101
            throw new \InvalidArgumentException(\sprintf('Set "%s" does not exist.', $name));
1✔
102
        }
103

104
        return $definitions[$name];
18✔
105
    }
106

107
    public static function registerCustomRuleSet(RuleSetDefinitionInterface $ruleset): void
108
    {
109
        $name = $ruleset->getName();
2✔
110

111
        if (!RuleSetNameValidator::isValid($name, true)) {
2✔
112
            throw new \InvalidArgumentException('RuleSet name must begin with "@" and a letter (a-z, A-Z), and can contain only letters (a-z, A-Z), numbers, underscores, slashes, colons, dots and hyphens.');
×
113
        }
114

115
        if (\array_key_exists($name, self::getSetDefinitions())) {
2✔
116
            throw new \InvalidArgumentException(\sprintf('Set "%s" is already defined.', $name));
1✔
117
        }
118

119
        self::$customRuleSetDefinitions[$name] = $ruleset;
2✔
120
    }
121
}
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