Skip to content

Commit 8209194

Browse files
localheinzgdiggs
authored andcommitted
Enhancement: Enforce coding style with friendsofphp/php-cs-fixer (#109)
* Enhancement: Require friendsofphp/php-cs-fixer * Enhancement: Add mimimum configuration for php-cs-fixer * Enhancement: Add composer script * Enhancement: Run php-cs-fixer against PHP5.3 on Travis
1 parent cfb7444 commit 8209194

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Vagrantfile
44
build/
55
vendor/
6+
.php_cs.cache
67
box.phar
78
composer.lock
89
composer.phar

.php_cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()->in(__DIR__);
4+
5+
$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;
6+
7+
return PhpCsFixer\Config::create()
8+
->setCacheFile($cacheDir . '/.php_cs.cache')
9+
->setFinder($finder)
10+
->setRules(array(
11+
'@PSR2' => true,
12+
'array_syntax' => array(
13+
'syntax' => 'long',
14+
),
15+
));

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ matrix:
77
- php: 5.3
88
env: WITH_LOWEST=true
99
- php: 5.3
10-
env: WITH_HIGHEST=true WITH_PHAR=true
10+
env: WITH_HIGHEST=true WITH_CS=true WITH_PHAR=true
1111
- php: 5.4
1212
env: WITH_LOWEST=true
1313
- php: 5.4
@@ -32,6 +32,7 @@ matrix:
3232
cache:
3333
directories:
3434
- $HOME/.composer/cache
35+
- $HOME/.php-cs-fixer
3536

3637
before_install:
3738
- source .travis/travis.sh
@@ -45,8 +46,10 @@ install:
4546
before_script:
4647
- git config --global user.email "travis-ci@codeclimate.com"
4748
- git config --global user.name "Travis CI"
49+
- mkdir -p "$HOME/.php-cs-fixer"
4850

4951
script:
52+
- if [[ "$WITH_CS" == "true" ]]; then vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --diff --dry-run; fi
5053
- run-tests
5154

5255
after_success:

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"symfony/console": "^2.0 || ^3.0"
2828
},
2929
"require-dev": {
30+
"friendsofphp/php-cs-fixer": "^2.0.0",
3031
"phpunit/phpunit": "^4.8.31"
3132
},
3233
"autoload": {
@@ -48,6 +49,10 @@
4849
"curl -LSs https://box-project.github.io/box2/installer.php | php",
4950
"php box.phar --version",
5051
"php box.phar build -v"
52+
],
53+
"cs": [
54+
"composer install --prefer-dist",
55+
"php-cs-fixer fix --config=.php_cs --verbose --diff"
5156
]
5257
},
5358
"extra": {

0 commit comments

Comments
 (0)