Skip to content

Commit 7f10d6a

Browse files
committed
PHP-CS-Fixer StyleCI Bridge
1 parent 529903a commit 7f10d6a

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/puli.json
88
/box.json
99
/.puli
10+
/.php_cs.cache

.php_cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/** @var \Composer\Autoload\ClassLoader $loader */
4+
$loader = require __DIR__.'/vendor/autoload.php';
5+
6+
$loader->unregister();
7+
$loader->addPsr4('SLLH\\StyleCIBridge\\', __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge');
8+
$loader->register();
9+
10+
use SLLH\StyleCIBridge\ConfigBridge;
11+
use Symfony\CS\Fixer\Contrib\HeaderCommentFixer;
12+
13+
$header = <<<EOF
14+
This file is part of the puli/cli package.
15+
16+
(c) Bernhard Schussek <bschussek@gmail.com>
17+
18+
For the full copyright and license information, please view the LICENSE
19+
file that was distributed with this source code.
20+
EOF;
21+
22+
// PHP-CS-Fixer 1.x
23+
if (method_exists('Symfony\CS\Fixer\Contrib\HeaderCommentFixer', 'getHeader')) {
24+
HeaderCommentFixer::setHeader($header);
25+
}
26+
27+
$config = ConfigBridge::create();
28+
$config->setUsingCache(true);
29+
30+
// PHP-CS-Fixer 2.x
31+
if (method_exists($config, 'setRules')) {
32+
$config
33+
->setRiskyAllowed(true)
34+
->setRules(array_merge($config->getRules(), array(
35+
'header_comment' => array('header' => $header)
36+
)))
37+
;
38+
}
39+
40+
return $config;

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},
2626
"require-dev": {
2727
"phpunit/phpunit": "^4.6",
28-
"sebastian/version": "^1.0.1"
28+
"sebastian/version": "^1.0.1",
29+
"sllh/php-cs-fixer-styleci-bridge": "^1.3@stable"
2930
},
3031
"minimum-stability": "dev",
3132
"autoload": {

0 commit comments

Comments
 (0)