forked from akeneo/pim-community-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.php_cs.php
36 lines (29 loc) · 1.14 KB
/
.php_cs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
$branch = getenv('TRAVIS_BRANCH');
$phpVersion = getenv('TRAVIS_PHP_VERSION');
printf('Current branch inspected : %s' . PHP_EOL, $branch);
$finder = \Symfony\CS\Finder\DefaultFinder::create()
->files()
->exclude('app/check.php');
$fixers = require __DIR__ . '/.php_cs-fixers.php';
if (is_numeric(getenv('TRAVIS_PULL_REQUEST'))) {
$commitRange = str_replace('...', '..', getenv('TRAVIS_COMMIT_RANGE'));
printf('Commit range = %s' . PHP_EOL, $commitRange);
exec('git diff ' . $commitRange . ' --name-only --diff-filter=AMR | grep -v Spec.php$ | grep php$', $diff);
} else {
exec('git show --name-only --oneline --pretty="format:" --diff-filter=AMR | grep -v Spec.php$ | grep php$', $diff);
$diff = array_filter($diff);
}
foreach ($diff as $idx => $filename) {
if ($filename !== 'app/check.php') {
printf('Parsed file : %s' . PHP_EOL, $filename);
} else {
printf('Excluded file : %s' . PHP_EOL, $filename);
unset($diff[$idx]);
}
}
$finder->append($diff);
return \Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->fixers($fixers)
->finder($finder);