Skip to content

Commit 1904d0e

Browse files
author
Nico Stapelbroek
committed
Install the latest php-cs-fixer without composer on the 7.1 build target
1 parent 0275795 commit 1904d0e

File tree

2 files changed

+21
-45
lines changed

2 files changed

+21
-45
lines changed

.php_cs.dist

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,23 @@
11
<?php
22

3-
if (class_exists('\\PhpCsFixer\\Config')) {
4-
$cacheFile = getenv('TRAVIS') ? getenv('HOME') . '/.php_cs.cache' : __DIR__ . '/.php_cs.cache';
5-
$config = PhpCsFixer\Config::create()
6-
->setRules(array(
7-
'@PSR2' => true,
8-
'single_blank_line_before_namespace' => true,
9-
'concat_space' => array('spacing' => 'one'),
10-
'single_quote' => true,
11-
'braces' => true,
12-
))
13-
->setFinder(
14-
PhpCsFixer\Finder::create()
15-
->exclude('vendor')
16-
->exclude('docs')
17-
->in(__DIR__)
18-
)
19-
->setCacheFile($cacheFile)
20-
->setUsingCache(true)
21-
->setRiskyAllowed(true);
3+
$cacheFile = getenv('TRAVIS') ? getenv('HOME') . '/.php_cs.cache' : __DIR__ . '/.php_cs.cache';
4+
$config = PhpCsFixer\Config::create()
5+
->setRules(array(
6+
'@PSR2' => true,
7+
'single_blank_line_before_namespace' => true,
8+
'concat_space' => array('spacing' => 'one'),
9+
'single_quote' => true,
10+
'braces' => true,
11+
))
12+
->setFinder(
13+
PhpCsFixer\Finder::create()
14+
->exclude('vendor')
15+
->exclude('docs')
16+
->in(__DIR__)
17+
)
18+
->setCacheFile($cacheFile)
19+
->setUsingCache(true)
20+
->setRiskyAllowed(true);
2221

23-
return $config;
24-
} else {
25-
$config = Symfony\CS\Config\Config::create()
26-
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
27-
->fixers(
28-
array(
29-
'single_blank_line_before_namespace',
30-
'concat_with_spaces',
31-
'single_quote',
32-
'braces',
33-
)
34-
)
35-
->finder(
36-
Symfony\CS\Finder::create()
37-
->exclude('vendor')
38-
->exclude('docs')
39-
->in(__DIR__)
40-
)
41-
->setUsingCache(true);
42-
$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;
43-
$config->setDir($cacheDir);
44-
return $config;
45-
}
22+
return $config;
4623

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ before_install:
3838

3939
install:
4040
- composer update --prefer-source -o $COMPOSER_FLAGS
41+
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.1" ]]; then wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O $(pwd)/php-cs-fixer; fi
4142
- PHPUNIT_BIN=$(pwd)/vendor/bin/phpunit
42-
- PHPCS_FIXER_BIN=$(pwd)/vendor/bin/php-cs-fixer
43-
- $PHPCS_FIXER_BIN --version | grep -q "2.*.*" && PHPCS_FIXER_CONFIG_FLAG="--config=.php_cs.dist" || PHPCS_FIXER_CONFIG_FLAG="--config-file=.php_cs.dist"
4443
- cd ${TEST_DIR}
4544
- composer update --prefer-source -o $COMPOSER_FLAGS
4645

4746
script:
4847
- $PHPUNIT_BIN --coverage-clover=coverage.clover
49-
- test $TEST_DIR = "." && $PHPCS_FIXER_BIN fix $PHPCS_FIXER_CONFIG_FLAG --dry-run --diff $TRAVIS_BUILD_DIR || echo "Continue without php-cs-fixer"
48+
- test $TEST_DIR = "." && $(pwd)/php-cs-fixer fix --config=.php_cs.dist --dry-run --diff $TRAVIS_BUILD_DIR || echo "Continue without php-cs-fixer"
5049

5150
after_success:
5251
- wget https://scrutinizer-ci.com/ocular.phar

0 commit comments

Comments
 (0)