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

PHP-CS-Fixer / PHP-CS-Fixer / 3721300657

pending completion
3721300657

push

github

GitHub
minor: Follow PSR12 ordered imports in Symfony ruleset (#6712)

9 of 9 new or added lines in 2 files covered. (100.0%)

22674 of 24281 relevant lines covered (93.38%)

39.08 hits per line

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

82.35
/src/Fixer/Phpdoc/PhpdocTagCasingFixer.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\Fixer\Phpdoc;
16

17
use PhpCsFixer\AbstractProxyFixer;
18
use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
19
use PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException;
20
use PhpCsFixer\Fixer\ConfigurableFixerInterface;
21
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
22
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
23
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
24
use PhpCsFixer\FixerDefinition\CodeSample;
25
use PhpCsFixer\FixerDefinition\FixerDefinition;
26
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
27
use PhpCsFixer\Preg;
28

29
final class PhpdocTagCasingFixer extends AbstractProxyFixer implements ConfigurableFixerInterface
30
{
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getDefinition(): FixerDefinitionInterface
35
    {
36
        return new FixerDefinition(
3✔
37
            'Fixes casing of PHPDoc tags.',
3✔
38
            [
3✔
39
                new CodeSample("<?php\n/**\n * @inheritdoc\n */\n"),
3✔
40
                new CodeSample("<?php\n/**\n * @inheritdoc\n * @Foo\n */\n", [
3✔
41
                    'tags' => ['foo'],
3✔
42
                ]),
3✔
43
            ]
3✔
44
        );
3✔
45
    }
46

47
    /**
48
     * {@inheritdoc}
49
     *
50
     * Must run before PhpdocAlignFixer.
51
     * Must run after AlignMultilineCommentFixer, CommentToPhpdocFixer, PhpdocIndentFixer, PhpdocScalarFixer, PhpdocToCommentFixer, PhpdocTypesFixer.
52
     */
53
    public function getPriority(): int
54
    {
55
        return parent::getPriority();
1✔
56
    }
57

58
    public function configure(array $configuration): void
59
    {
60
        parent::configure($configuration);
12✔
61

62
        $replacements = [];
12✔
63
        foreach ($this->configuration['tags'] as $tag) {
12✔
64
            $replacements[$tag] = $tag;
12✔
65
        }
66

67
        /** @var GeneralPhpdocTagRenameFixer $generalPhpdocTagRenameFixer */
68
        $generalPhpdocTagRenameFixer = $this->proxyFixers['general_phpdoc_tag_rename'];
12✔
69

70
        try {
71
            $generalPhpdocTagRenameFixer->configure([
12✔
72
                'fix_annotation' => true,
12✔
73
                'fix_inline' => true,
12✔
74
                'replacements' => $replacements,
12✔
75
                'case_sensitive' => false,
12✔
76
            ]);
12✔
77
        } catch (InvalidConfigurationException $exception) {
×
78
            throw new InvalidFixerConfigurationException(
×
79
                $this->getName(),
×
80
                Preg::replace('/^\[.+?\] /', '', $exception->getMessage()),
×
81
                $exception
×
82
            );
×
83
        }
84
    }
85

86
    /**
87
     * {@inheritdoc}
88
     */
89
    protected function createConfigurationDefinition(): FixerConfigurationResolverInterface
90
    {
91
        return new FixerConfigurationResolver([
12✔
92
            (new FixerOptionBuilder('tags', 'List of tags to fix with their expected casing.'))
12✔
93
                ->setAllowedTypes(['array'])
12✔
94
                ->setDefault(['inheritDoc'])
12✔
95
                ->getOption(),
12✔
96
        ]);
12✔
97
    }
98

99
    /**
100
     * {@inheritdoc}
101
     */
102
    protected function createProxyFixers(): array
103
    {
104
        return [new GeneralPhpdocTagRenameFixer()];
12✔
105
    }
106
}
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