forked from akeneo/pim-community-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.php_cs.php
43 lines (35 loc) · 1.17 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
37
38
39
40
41
42
43
<?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();
$fixers = [
'-concat_without_spaces',
'-empty_return',
'-multiline_array_trailing_comma',
'-phpdoc_short_description',
'-single_quote',
'-trim_array_spaces',
'-operators_spaces',
'-unary_operators_spaces',
'-unalign_equals',
'-unalign_double_arrow',
'newline_after_open_tag',
'ordered_use',
'phpdoc_order'
];
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/', $diff);
} else {
exec('git show --name-only --oneline --pretty="format:" --diff-filter=AMR | grep -v ^spec/', $diff);
$diff = array_filter($diff);
}
foreach ($diff as $filename) {
printf('Parsed file : %s' .PHP_EOL, $filename);
}
$finder->append($diff);
return \Symfony\CS\Config\Config::create()
->fixers($fixers)
->finder($finder);