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

keradus / PHP-CS-Fixer / 18589345849

16 Oct 2025 09:31PM UTC coverage: 94.158% (+0.01%) from 94.148%
18589345849

push

github

web-flow
docs: update usage documentation for describe `--expand` and `@` (#9119)

28675 of 30454 relevant lines covered (94.16%)

45.16 hits per line

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

91.67
/src/Console/WarningsDetector.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\ComposerJsonReader;
18
use PhpCsFixer\ToolInfo;
19
use PhpCsFixer\ToolInfoInterface;
20

21
/**
22
 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
23
 *
24
 * @internal
25
 *
26
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise.
27
 */
28
final class WarningsDetector
29
{
30
    private ToolInfoInterface $toolInfo;
31

32
    /**
33
     * @var list<string>
34
     */
35
    private array $warnings = [];
36

37
    public function __construct(ToolInfoInterface $toolInfo)
38
    {
39
        $this->toolInfo = $toolInfo;
7✔
40
    }
41

42
    public function detectOldMajor(): void
43
    {
44
        // @TODO 3.99 to be activated with new MAJOR release 4.0
45
        // $currentMajorVersion = \intval(explode('.', Application::VERSION)[0], 10);
46
        // $nextMajorVersion = $currentMajorVersion + 1;
47
        // $this->warnings[] = "You are running PHP CS Fixer v{$currentMajorVersion}, which is not maintained anymore. Please update to v{$nextMajorVersion}.";
48
        // $this->warnings[] = "You may find an UPGRADE guide at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v{$nextMajorVersion}.0.0/UPGRADE-v{$nextMajorVersion}.md .";
49
    }
×
50

51
    public function detectOldVendor(): void
52
    {
53
        if ($this->toolInfo->isInstalledByComposer()) {
3✔
54
            $details = $this->toolInfo->getComposerInstallationDetails();
1✔
55
            if (ToolInfo::COMPOSER_LEGACY_PACKAGE_NAME === $details['name']) {
1✔
56
                $this->warnings[] = \sprintf(
1✔
57
                    'You are running PHP CS Fixer installed with old vendor `%s`. Please update to `%s`.',
1✔
58
                    ToolInfo::COMPOSER_LEGACY_PACKAGE_NAME,
1✔
59
                    ToolInfo::COMPOSER_PACKAGE_NAME
1✔
60
                );
1✔
61
            }
62
        }
63
    }
64

65
    public function detectNonMonolithic(): void
66
    {
67
        if (filter_var(getenv('PHP_CS_FIXER_NON_MONOLITHIC'), \FILTER_VALIDATE_BOOL)) {
×
68
            $this->warnings[] = 'Processing non-monolithic files enabled, because `PHP_CS_FIXER_NON_MONOLITHIC` is set. Execution result may be unpredictable - non-monolithic files are not officially supported.';
×
69
        }
70
    }
71

72
    public function detectHigherPhpVersion(): void
73
    {
74
        try {
75
            $composerJsonReader = ComposerJsonReader::createSingleton();
4✔
76
            $minPhpVersion = $composerJsonReader->getPhp();
4✔
77

78
            if (null === $minPhpVersion) {
3✔
79
                $this->warnings[] = 'No PHP version requirement found in composer.json. It is recommended to specify a minimum PHP version.';
1✔
80

81
                return;
1✔
82
            }
83

84
            $currentPhpVersion = \PHP_VERSION;
2✔
85
            $currentPhpMajorMinor = \sprintf('%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION);
2✔
86

87
            // Compare major.minor versions
88
            if (version_compare($currentPhpMajorMinor, $minPhpVersion, '>')) {
2✔
89
                $this->warnings[] = \sprintf(
2✔
90
                    'You are running PHP CS Fixer on PHP %1$s, but the minimum supported version in composer.json is PHP %2$s. This may introduce syntax or features not yet available in PHP %2$s, which could cause issues under that version. It is recommended to run PHP CS Fixer on PHP %2$s, to fit your project specifics.',
2✔
91
                    $currentPhpVersion,
2✔
92
                    $minPhpVersion
2✔
93
                );
2✔
94
            }
95
        } catch (\Throwable $e) {
1✔
96
            $this->warnings[] = \sprintf(
1✔
97
                'Unable to determine minimum supported PHP version from composer.json: %s',
1✔
98
                $e->getMessage()
1✔
99
            );
1✔
100
        }
101
    }
102

103
    /**
104
     * @return list<string>
105
     */
106
    public function getWarnings(): array
107
    {
108
        if (0 === \count($this->warnings)) {
7✔
109
            return [];
3✔
110
        }
111

112
        return array_values(array_unique(array_merge(
4✔
113
            $this->warnings,
4✔
114
            ['If you need help while solving warnings, ask at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/discussions/, we will help you!']
4✔
115
        )));
4✔
116
    }
117
}
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