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

PHP-CS-Fixer / PHP-CS-Fixer / 15906293412

26 Jun 2025 03:39PM UTC coverage: 94.829% (-0.04%) from 94.87%
15906293412

Pull #8733

github

web-flow
Merge f9db1d7b2 into a32defda7
Pull Request #8733: feat: allowUnsupportedPhpVersion

22 of 33 new or added lines in 3 files covered. (66.67%)

3 existing lines in 1 file now uncovered.

28129 of 29663 relevant lines covered (94.83%)

45.34 hits per line

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

94.55
/src/Config.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\Fixer\FixerInterface;
18
use PhpCsFixer\Runner\Parallel\ParallelConfig;
19
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
20

21
/**
22
 * @author Fabien Potencier <fabien@symfony.com>
23
 * @author Katsuhiro Ogawa <ko.fivestar@gmail.com>
24
 * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
25
 */
26
class Config implements ConfigInterface, ParallelAwareConfigInterface, UnsupportedPhpVersionAllowedConfigInterface
27
{
28
    /**
29
     * @var non-empty-string
30
     */
31
    private string $cacheFile = '.php-cs-fixer.cache';
32

33
    /**
34
     * @var list<FixerInterface>
35
     */
36
    private array $customFixers = [];
37

38
    /**
39
     * @var null|iterable<\SplFileInfo>
40
     */
41
    private ?iterable $finder = null;
42

43
    private string $format;
44

45
    private bool $hideProgress = false;
46

47
    /**
48
     * @var non-empty-string
49
     */
50
    private string $indent = '    ';
51

52
    private bool $isRiskyAllowed = false;
53

54
    /**
55
     * @var non-empty-string
56
     */
57
    private string $lineEnding = "\n";
58

59
    private string $name;
60

61
    private ParallelConfig $parallelConfig;
62

63
    private ?string $phpExecutable = null;
64

65
    /**
66
     * @TODO: 4.0 - update to @PER
67
     *
68
     * @var array<string, array<string, mixed>|bool>
69
     */
70
    private array $rules;
71

72
    private bool $usingCache = true;
73

74
    private bool $isUnsupportedPhpVersionAllowed = false;
75

76
    public function __construct(string $name = 'default')
77
    {
78
        // @TODO 4.0 cleanup
79
        if (Utils::isFutureModeEnabled()) {
17✔
80
            $this->name = $name.' (future mode)';
1✔
81
            $this->rules = ['@PER-CS' => true];
1✔
82
            $this->format = '@auto';
1✔
83
        } else {
84
            $this->name = $name;
16✔
85
            $this->rules = ['@PSR12' => true];
16✔
86
            $this->format = 'txt';
16✔
87
        }
88

89
        // @TODO 4.0 cleanup
90
        if (Utils::isFutureModeEnabled() || filter_var(getenv('PHP_CS_FIXER_PARALLEL'), FILTER_VALIDATE_BOOL)) {
17✔
91
            $this->parallelConfig = ParallelConfigFactory::detect();
1✔
92
        } else {
93
            $this->parallelConfig = ParallelConfigFactory::sequential();
16✔
94
        }
95

96
        // @TODO 4.0 cleanup
97
        if (false !== getenv('PHP_CS_FIXER_IGNORE_ENV')) {
17✔
98
            $this->isUnsupportedPhpVersionAllowed = filter_var(getenv('PHP_CS_FIXER_IGNORE_ENV'), FILTER_VALIDATE_BOOL);
17✔
99
        }
100
    }
101

102
    /**
103
     * @return non-empty-string
104
     */
105
    public function getCacheFile(): string
106
    {
107
        return $this->cacheFile;
3✔
108
    }
109

110
    public function getCustomFixers(): array
111
    {
112
        return $this->customFixers;
5✔
113
    }
114

115
    /**
116
     * @return Finder
117
     */
118
    public function getFinder(): iterable
119
    {
120
        $this->finder ??= new Finder();
4✔
121

122
        return $this->finder;
4✔
123
    }
124

125
    public function getFormat(): string
126
    {
127
        return $this->format;
1✔
128
    }
129

130
    public function getHideProgress(): bool
131
    {
132
        return $this->hideProgress;
1✔
133
    }
134

135
    public function getIndent(): string
136
    {
137
        return $this->indent;
1✔
138
    }
139

140
    public function getLineEnding(): string
141
    {
142
        return $this->lineEnding;
1✔
143
    }
144

145
    public function getName(): string
146
    {
147
        return $this->name;
3✔
148
    }
149

150
    public function getParallelConfig(): ParallelConfig
151
    {
152
        return $this->parallelConfig;
2✔
153
    }
154

155
    public function getPhpExecutable(): ?string
156
    {
157
        return $this->phpExecutable;
1✔
158
    }
159

160
    public function getRiskyAllowed(): bool
161
    {
162
        return $this->isRiskyAllowed;
1✔
163
    }
164

165
    public function getRules(): array
166
    {
167
        return $this->rules;
2✔
168
    }
169

170
    public function getUsingCache(): bool
171
    {
172
        return $this->usingCache;
1✔
173
    }
174

175
    public function getUnsupportedPhpVersionAllowed(): bool
176
    {
NEW
177
        return $this->isUnsupportedPhpVersionAllowed;
×
178
    }
179

180
    public function registerCustomFixers(iterable $fixers): ConfigInterface
181
    {
182
        foreach ($fixers as $fixer) {
4✔
183
            $this->addCustomFixer($fixer);
4✔
184
        }
185

186
        return $this;
4✔
187
    }
188

189
    /**
190
     * @param non-empty-string $cacheFile
191
     */
192
    public function setCacheFile(string $cacheFile): ConfigInterface
193
    {
194
        $this->cacheFile = $cacheFile;
2✔
195

196
        return $this;
2✔
197
    }
198

199
    public function setFinder(iterable $finder): ConfigInterface
200
    {
201
        $this->finder = $finder;
5✔
202

203
        return $this;
5✔
204
    }
205

206
    public function setFormat(string $format): ConfigInterface
207
    {
208
        $this->format = $format;
1✔
209

210
        return $this;
1✔
211
    }
212

213
    public function setHideProgress(bool $hideProgress): ConfigInterface
214
    {
215
        $this->hideProgress = $hideProgress;
1✔
216

217
        return $this;
1✔
218
    }
219

220
    /**
221
     * @param non-empty-string $indent
222
     */
223
    public function setIndent(string $indent): ConfigInterface
224
    {
225
        $this->indent = $indent;
1✔
226

227
        return $this;
1✔
228
    }
229

230
    /**
231
     * @param non-empty-string $lineEnding
232
     */
233
    public function setLineEnding(string $lineEnding): ConfigInterface
234
    {
235
        $this->lineEnding = $lineEnding;
1✔
236

237
        return $this;
1✔
238
    }
239

240
    public function setParallelConfig(ParallelConfig $config): ConfigInterface
241
    {
242
        $this->parallelConfig = $config;
3✔
243

244
        return $this;
3✔
245
    }
246

247
    public function setPhpExecutable(?string $phpExecutable): ConfigInterface
248
    {
249
        $this->phpExecutable = $phpExecutable;
1✔
250

251
        return $this;
1✔
252
    }
253

254
    public function setRiskyAllowed(bool $isRiskyAllowed): ConfigInterface
255
    {
256
        $this->isRiskyAllowed = $isRiskyAllowed;
2✔
257

258
        return $this;
2✔
259
    }
260

261
    public function setRules(array $rules): ConfigInterface
262
    {
263
        $this->rules = $rules;
2✔
264

265
        return $this;
2✔
266
    }
267

268
    public function setUsingCache(bool $usingCache): ConfigInterface
269
    {
270
        $this->usingCache = $usingCache;
1✔
271

272
        return $this;
1✔
273
    }
274

275
    public function setUnsupportedPhpVersionAllowed(bool $isUnsupportedPhpVersionAllowed): ConfigInterface
276
    {
NEW
277
        $this->isUnsupportedPhpVersionAllowed = $isUnsupportedPhpVersionAllowed;
×
278

NEW
279
        return $this;
×
280
    }
281

282
    private function addCustomFixer(FixerInterface $fixer): void
283
    {
284
        $this->customFixers[] = $fixer;
4✔
285
    }
286
}
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