Skip to content

Commit 97129bf

Browse files
authored
Create .php-cs-fixer.dist.php
add rules for php-cs-fixer to follow PSR12
1 parent 777bd90 commit 97129bf

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.php-cs-fixer.dist.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
$header = <<<'EOF'
16+
This file is part of PHP CS Fixer.
17+
18+
(c) Fabien Potencier <fabien@symfony.com>
19+
Dariusz Rumiński <dariusz.ruminski@gmail.com>
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+
'@PSR12' => true,
41+
])
42+
->setFinder($finder)
43+
;
44+
45+
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
46+
if (false !== getenv('FABBOT_IO')) {
47+
try {
48+
PhpCsFixer\FixerFactory::create()
49+
->registerBuiltInFixers()
50+
->registerCustomFixers($config->getCustomFixers())
51+
->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()))
52+
;
53+
} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
54+
$config->setRules([]);
55+
} catch (UnexpectedValueException $e) {
56+
$config->setRules([]);
57+
} catch (InvalidArgumentException $e) {
58+
$config->setRules([]);
59+
}
60+
}
61+
62+
return $config;

0 commit comments

Comments
 (0)