Skip to content

Commit 3342e4e

Browse files
authored
chore: Updating php-cs-fixer config file to support php-cs-fixer 3.0 (GoogleCloudPlatform#1442)
1 parent 55a800e commit 3342e4e

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
22

3-
return PhpCsFixer\Config::create()
3+
// php-cs-fixer 3.0 distributed config file
4+
5+
$config = new PhpCsFixer\Config();
6+
$config
47
->setRules([
58
'@PSR2' => true,
69
'concat_space' => ['spacing' => 'one'],
710
'no_unused_imports' => true,
8-
'method_argument_space' => false,
911
'whitespace_after_comma_in_array' => true,
1012
'method_argument_space' => [
11-
'keep_multiple_spaces_after_comma' => true
13+
'keep_multiple_spaces_after_comma' => true,
14+
'on_multiline' => 'ignore'
1215
],
1316
'return_type_declaration' => [
1417
'space_before' => 'none'
@@ -19,3 +22,5 @@
1922
->in(__DIR__)
2023
)
2124
;
25+
26+
return $config;

testing/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"google/auth": "^1.12",
88
"google/cloud-tools": "dev-master",
99
"guzzlehttp/guzzle": "^7.0",
10-
"phpunit/phpunit": "^7|^8"
10+
"phpunit/phpunit": "^7|^8",
11+
"friendsofphp/php-cs-fixer": "^3.0"
1112
}
1213
}

testing/run_cs_check.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@
1515

1616
set -ex
1717

18+
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."
19+
DIR="${1:-$PROJECT_ROOT}"
20+
21+
# we run the script from PROJECT_ROOT
22+
cd $PROJECT_ROOT
23+
24+
# install local version of php-cs-fixer 3.0 from composer.json
25+
composer -q install -d testing/
26+
1827
# run php-cs-fixer
1928
PHP_CS_FIXER="php-cs-fixer"
20-
if [ -f "vendor/bin/php-cs-fixer" ]; then
21-
PHP_CS_FIXER="vendor/bin/php-cs-fixer"
22-
elif [ -f "./php-cs-fixer" ]; then
23-
PHP_CS_FIXER="./php-cs-fixer"
29+
if [ -f "testing/vendor/bin/php-cs-fixer" ]; then
30+
PHP_CS_FIXER="testing/vendor/bin/php-cs-fixer"
2431
fi
2532

26-
PROJECT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."
27-
DIR="${1:-$PROJECT_ROOT}"
28-
29-
$PHP_CS_FIXER fix --dry-run --diff --config="${PROJECT_ROOT}/.php_cs.dist" --path-mode=intersection $DIR
33+
$PHP_CS_FIXER fix --dry-run --diff --config="${PROJECT_ROOT}/.php-cs-fixer.dist.php" --path-mode=intersection $DIR

0 commit comments

Comments
 (0)