Skip to content

Commit e064e26

Browse files
chore(ci): add php-cs-fixer
1 parent 9300e65 commit e064e26

File tree

4 files changed

+71
-46
lines changed

4 files changed

+71
-46
lines changed

.circleci/config.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/php-cs-fixer.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Check and fix code styling with php-cs-fixer
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
style:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
with:
15+
ref: ${{ github.head_ref }}
16+
17+
- name: Run php-cs-fixer
18+
uses: docker://oskarstark/php-cs-fixer-ga
19+
with:
20+
args: --config=.php_cs.dist --allow-risky=yes
21+
22+
- name: Commit changes
23+
uses: stefanzweifel/git-auto-commit-action@v4.10.0
24+
with:
25+
commit_message: Automatically applied php-cs-fixer changes

.php_cs.dist

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->notPath('vendor/*')
5+
->notPath('resources/*')
6+
->notPath('database/*')
7+
->notPath('storage/*')
8+
->notPath('node_modules/*')
9+
->in([
10+
__DIR__ . '/src',
11+
])
12+
->name('*.php')
13+
->notName('*.blade.php')
14+
->ignoreDotFiles(true)
15+
->ignoreVCS(true);
16+
17+
return PhpCsFixer\Config::create()
18+
->setRules([
19+
'@PSR2' => true,
20+
'array_syntax' => ['syntax' => 'short'],
21+
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
22+
'no_unused_imports' => true,
23+
'not_operator_with_successor_space' => true,
24+
'trailing_comma_in_multiline_array' => true,
25+
'phpdoc_scalar' => true,
26+
'unary_operator_spaces' => true,
27+
'binary_operator_spaces' => true,
28+
'blank_line_before_statement' => [
29+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
30+
],
31+
'phpdoc_single_line_var_spacing' => true,
32+
'phpdoc_var_without_name' => true,
33+
'class_attributes_separation' => [
34+
'elements' => [
35+
'method',
36+
],
37+
],
38+
'method_argument_space' => [
39+
'on_multiline' => 'ensure_fully_multiline',
40+
'keep_multiple_spaces_after_comma' => true,
41+
],
42+
'single_trait_insert_per_statement' => true,
43+
])
44+
->setFinder($finder);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"illuminate/view": "^7.0|^8.0"
2020
},
2121
"require-dev": {
22+
"friendsofphp/php-cs-fixer": "^2.18",
2223
"squizlabs/php_codesniffer": "3.*",
2324
"phpunit/phpunit": "^7.0|^8.0|^9.0",
2425
"orchestra/testbench": "~5.2"
@@ -45,6 +46,6 @@
4546
"test": "vendor/bin/phpunit",
4647
"test:windows": "vendor\\bin\\phpunit",
4748
"check-style": "vendor/bin/phpcs --extensions=php ./src",
48-
"fix-style": "vendor/bin/phpcbf --extensions=php ./src"
49+
"fix-style": "vendor/bin/php-cs-fixer fix"
4950
}
5051
}

0 commit comments

Comments
 (0)