Code

< 40 %
40-60 %
> 60 %
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of PHP CS Fixer.
7
 *
8
 * (c) Fabien Potencier <[email protected]>
9
 *     Dariusz Rumiński <[email protected]>
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
$header = <<<'EOF'
16
    This file is part of PHP CS Fixer.
17
18
    (c) Fabien Potencier <[email protected]>
19
        Dariusz Rumiński <[email protected]>
20
21
    This source file is subject to the MIT license that is bundled
22
    with this source code in the file LICENSE.
23
    EOF;
24
25
$finder = PhpCsFixer\Finder::create()
26
    ->ignoreDotFiles(false)
27
    ->ignoreVCSIgnored(true)
28
    ->exclude('tests/Fixtures')
29
    ->in(__DIR__)
30
    ->append([
31
        __DIR__.'/dev-tools/doc.php',
32
        // __DIR__.'/php-cs-fixer', disabled, as we want to be able to run bootstrap file even on lower PHP version, to show nice message
33
    ])
34
;
35
36
$config = new PhpCsFixer\Config();
37
$config
38
    ->setRiskyAllowed(true)
39
    ->setRules([
40
        '@PHP74Migration' => true,
41
        '@PSR12' => true,
42
    ])
43
    ->setFinder($finder)
44
;
45
46
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
47
if (false !== getenv('FABBOT_IO')) {
48
    try {
49
        PhpCsFixer\FixerFactory::create()
50
            ->registerBuiltInFixers()
51
            ->registerCustomFixers($config->getCustomFixers())
52
            ->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
53
        ;
54
    } catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
55
        $config->setRules([]);
56
    } catch (UnexpectedValueException $e) {
57
        $config->setRules([]);
58
    } catch (InvalidArgumentException $e) {
59
        $config->setRules([]);
60
    }
61
}
62
63
return $config;
64