• 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

48.94
/src/Console/Application.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;
16

17
use PhpCsFixer\Console\Command\DescribeCommand;
18
use PhpCsFixer\Console\Command\FixCommand;
19
use PhpCsFixer\Console\Command\HelpCommand;
20
use PhpCsFixer\Console\Command\ListFilesCommand;
21
use PhpCsFixer\Console\Command\ListSetsCommand;
22
use PhpCsFixer\Console\Command\SelfUpdateCommand;
23
use PhpCsFixer\Console\SelfUpdate\GithubClient;
24
use PhpCsFixer\Console\SelfUpdate\NewVersionChecker;
25
use PhpCsFixer\PharChecker;
26
use PhpCsFixer\ToolInfo;
27
use PhpCsFixer\Utils;
28
use Symfony\Component\Console\Application as BaseApplication;
29
use Symfony\Component\Console\Command\ListCommand;
30
use Symfony\Component\Console\Input\InputInterface;
31
use Symfony\Component\Console\Output\ConsoleOutputInterface;
32
use Symfony\Component\Console\Output\OutputInterface;
33

34
/**
35
 * @author Fabien Potencier <fabien@symfony.com>
36
 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
37
 *
38
 * @internal
39
 */
40
final class Application extends BaseApplication
41
{
42
    public const VERSION = '3.13.1-DEV';
43
    public const VERSION_CODENAME = 'Oliva';
44

45
    private ToolInfo $toolInfo;
46

47
    public function __construct()
48
    {
49
        parent::__construct('PHP CS Fixer', self::VERSION);
1✔
50

51
        $this->toolInfo = new ToolInfo();
1✔
52

53
        // in alphabetical order
54
        $this->add(new DescribeCommand());
1✔
55
        $this->add(new FixCommand($this->toolInfo));
1✔
56
        $this->add(new ListFilesCommand($this->toolInfo));
1✔
57
        $this->add(new ListSetsCommand());
1✔
58
        $this->add(new SelfUpdateCommand(
1✔
59
            new NewVersionChecker(new GithubClient()),
1✔
60
            $this->toolInfo,
1✔
61
            new PharChecker()
1✔
62
        ));
1✔
63
    }
64

65
    public static function getMajorVersion(): int
66
    {
67
        return (int) explode('.', self::VERSION)[0];
1✔
68
    }
69

70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function doRun(InputInterface $input, OutputInterface $output): int
74
    {
75
        $stdErr = $output instanceof ConsoleOutputInterface
×
76
            ? $output->getErrorOutput()
×
77
            : ($input->hasParameterOption('--format', true) && 'txt' !== $input->getParameterOption('--format', null, true) ? null : $output)
×
78
        ;
×
79

80
        if (null !== $stdErr) {
×
81
            $warningsDetector = new WarningsDetector($this->toolInfo);
×
82
            $warningsDetector->detectOldVendor();
×
83
            $warningsDetector->detectOldMajor();
×
84
            $warnings = $warningsDetector->getWarnings();
×
85

86
            if (\count($warnings) > 0) {
×
87
                foreach ($warnings as $warning) {
×
88
                    $stdErr->writeln(sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', $warning));
×
89
                }
90
                $stdErr->writeln('');
×
91
            }
92
        }
93

94
        $result = parent::doRun($input, $output);
×
95

96
        if (
97
            null !== $stdErr
×
98
            && $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE
×
99
        ) {
100
            $triggeredDeprecations = Utils::getTriggeredDeprecations();
×
101

102
            if (\count($triggeredDeprecations) > 0) {
×
103
                $stdErr->writeln('');
×
104
                $stdErr->writeln($stdErr->isDecorated() ? '<bg=yellow;fg=black;>Detected deprecations in use:</>' : 'Detected deprecations in use:');
×
105
                foreach ($triggeredDeprecations as $deprecation) {
×
106
                    $stdErr->writeln(sprintf('- %s', $deprecation));
×
107
                }
108
            }
109
        }
110

111
        return $result;
×
112
    }
113

114
    /**
115
     * {@inheritdoc}
116
     */
117
    public function getLongVersion(): string
118
    {
119
        $commit = '@git-commit@';
1✔
120
        $versionCommit = '';
1✔
121

122
        if ('@'.'git-commit@' !== $commit) { /** @phpstan-ignore-line as `$commit` is replaced during phar building */
1✔
123
            $versionCommit = substr($commit, 0, 7);
×
124
        }
125

126
        return implode('', [
1✔
127
            parent::getLongVersion(),
1✔
128
            $versionCommit ? sprintf(' <info>(%s)</info>', $versionCommit) : '', // @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.`
1✔
129
            self::VERSION_CODENAME ? sprintf(' <info>%s</info>', self::VERSION_CODENAME) : '', // @phpstan-ignore-line to avoid `Ternary operator condition is always true|false.`
1✔
130
            ' by <comment>Fabien Potencier</comment> and <comment>Dariusz Ruminski</comment>.',
1✔
131
            "\nPHP runtime: <info>".PHP_VERSION.'</info>',
1✔
132
        ]);
1✔
133
    }
134

135
    /**
136
     * {@inheritdoc}
137
     */
138
    protected function getDefaultCommands(): array
139
    {
140
        return [new HelpCommand(), new ListCommand()];
1✔
141
    }
142
}
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

© 2025 Coveralls, Inc