• 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

65.22
/src/AbstractFixer.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;
16

17
use PhpCsFixer\ConfigurationException\RequiredFixerConfigurationException;
18
use PhpCsFixer\Fixer\ConfigurableFixerInterface;
19
use PhpCsFixer\Fixer\FixerInterface;
20
use PhpCsFixer\Fixer\WhitespacesAwareFixerInterface;
21
use PhpCsFixer\Tokenizer\Tokens;
22

23
/**
24
 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
25
 *
26
 * @internal
27
 *
28
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
29
 */
30
abstract class AbstractFixer implements FixerInterface
31
{
32
    protected WhitespacesFixerConfig $whitespacesConfig;
33

34
    /**
35
     * @readonly
36
     */
37
    private string $name;
38

39
    public function __construct()
40
    {
41
        $nameParts = explode('\\', static::class);
3✔
42
        $name = substr(end($nameParts), 0, -\strlen('Fixer'));
3✔
43
        $this->name = Utils::camelCaseToUnderscore($name);
3✔
44

45
        if ($this instanceof ConfigurableFixerInterface) {
3✔
46
            try {
47
                $this->configure([]);
×
48
            } catch (RequiredFixerConfigurationException $e) {
×
49
                // ignore
50
            }
51
        }
52

53
        if ($this instanceof WhitespacesAwareFixerInterface) {
3✔
54
            $this->whitespacesConfig = $this->getDefaultWhitespacesFixerConfig();
1✔
55
        }
56
    }
57

58
    final public function fix(\SplFileInfo $file, Tokens $tokens): void
59
    {
60
        if ($this instanceof ConfigurableFixerInterface && property_exists($this, 'configuration') && null === $this->configuration) {
×
61
            throw new RequiredFixerConfigurationException($this->getName(), 'Configuration is required.');
×
62
        }
63

64
        if (0 < $tokens->count() && $this->isCandidate($tokens) && $this->supports($file)) {
×
65
            $this->applyFix($file, $tokens);
×
66
        }
67
    }
68

69
    public function isRisky(): bool
70
    {
71
        return false;
1✔
72
    }
73

74
    public function getName(): string
75
    {
76
        return $this->name;
×
77
    }
78

79
    public function getPriority(): int
80
    {
81
        return 0;
×
82
    }
83

84
    public function supports(\SplFileInfo $file): bool
85
    {
86
        return true;
1✔
87
    }
88

89
    public function setWhitespacesConfig(WhitespacesFixerConfig $config): void
90
    {
91
        if (!$this instanceof WhitespacesAwareFixerInterface) {
2✔
92
            throw new \LogicException('Cannot run method for class not implementing "PhpCsFixer\Fixer\WhitespacesAwareFixerInterface".');
1✔
93
        }
94

95
        $this->whitespacesConfig = $config;
1✔
96
    }
97

98
    abstract protected function applyFix(\SplFileInfo $file, Tokens $tokens): void;
99

100
    private function getDefaultWhitespacesFixerConfig(): WhitespacesFixerConfig
101
    {
102
        static $defaultWhitespacesFixerConfig = null;
1✔
103

104
        if (null === $defaultWhitespacesFixerConfig) {
1✔
105
            $defaultWhitespacesFixerConfig = new WhitespacesFixerConfig('    ', "\n");
1✔
106
        }
107

108
        return $defaultWhitespacesFixerConfig;
1✔
109
    }
110
}
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