generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy path.php-cs-fixer.dist.php
69 lines (59 loc) · 2.04 KB
/
.php-cs-fixer.dist.php
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
67
68
69
<?php
declare(strict_types=1);
/*
* This file is part of the Laravel-Strapi helper.
*
* (ɔ) Dave Blakey https://github.com/dbfx
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.md.
*/
use PhpCsFixer\Config;
use PhpCsFixer\ConfigurationException\InvalidConfigurationException;
use PhpCsFixer\Finder;
use PhpCsFixer\FixerFactory;
use PhpCsFixer\RuleSet;
$header = <<<'EOF'
This file is part of the Laravel-Strapi helper.
(ɔ) Dave Blakey https://github.com/dbfx
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.md.
EOF;
// exclude will work only for directories, so if you need to exclude file, try notPath
// directories passed as exclude() argument must be relative to the ones defined with the in() method
$finder = Finder::create()
->in([__DIR__])
->exclude(['vendor'])
->append([__DIR__.'/.php-cs-fixer.dist.php'])
;
$config = (new Config())
->setCacheFile(sys_get_temp_dir().'/.php_cs.cache')
->setRiskyAllowed(true)
->setRules([
// https://mlocati.github.io/php-cs-fixer-configurator
'@PHP74Migration:risky' => true,
'@PHP74Migration' => true,
'@PhpCsFixer' => true,
// '@PhpCsFixer:risky' => true,
'general_phpdoc_annotation_remove' => ['annotations' => ['expectedDeprecation']],
'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 {
FixerFactory::create()
->registerBuiltInFixers()
->registerCustomFixers($config->getCustomFixers())
->useRuleSet(new RuleSet($config->getRules()))
;
} catch (InvalidConfigurationException $e) {
$config->setRules([]);
} catch (UnexpectedValueException $e) {
$config->setRules([]);
} catch (InvalidArgumentException $e) {
$config->setRules([]);
}
}
return $config;