-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.php-cs-fixer.dist.php
More file actions
66 lines (56 loc) · 1.86 KB
/
Copy path.php-cs-fixer.dist.php
File metadata and controls
66 lines (56 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
declare(strict_types=1);
/*
* This file is part of the WP Boot package.
*
* (ɔ) Frugan <dev@frugan.it>
*
* This source file is subject to the GNU GPLv3 or later license that is bundled
* with this source code in the file LICENSE.
*/
use PhpCsFixer\Config;
use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
use PhpCsFixer\Finder;
use PhpCsFixer\FixerFactory;
use PhpCsFixer\RuleSet;
$header = <<<'EOF'
This file is part of the WP Boot package.
(ɔ) Frugan <dev@frugan.it>
This source file is subject to the GNU GPLv3 or later license that is bundled
with this source code in the file LICENSE.
EOF;
// exclude will work only for directories, so if you need to exclude file, try notPath
$finder = Finder::create()
->in([__DIR__])
->exclude(['patches', 'vendor'])
->append([__DIR__.'/.php-cs-fixer.dist.php'])
;
$config = new Config()
->setCacheFile(sys_get_temp_dir().'/.php_cs.cache')
->setRiskyAllowed(true)
->setUnsupportedPhpVersionAllowed(true)
->setRules([
// https://mlocati.github.io/php-cs-fixer-configurator
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP80Migration:risky' => true,
'@PHP84Migration' => true,
'header_comment' => ['header' => $header],
])
->setFinder($finder)
;
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
if (false !== getenv('FABBOT_IO')) {
try {
// @phpstan-ignore-next-line
FixerFactory::create()
->registerBuiltInFixers()
->registerCustomFixers($config->getCustomFixers())
// @phpstan-ignore-next-line
->useRuleSet(new RuleSet($config->getRules()))
;
} catch (InvalidArgumentException|InvalidConfigurationException|UnexpectedValueException) {
$config->setRules([]);
}
}
return $config;