Skip to content

Commit

Permalink
chore(ci): add php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetan-hexadog committed Apr 30, 2021
1 parent 9300e65 commit e064e26
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 46 deletions.
45 changes: 0 additions & 45 deletions .circleci/config.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check and fix code styling with php-cs-fixer

on:
pull_request:
push:

jobs:
style:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Run php-cs-fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4.10.0
with:
commit_message: Automatically applied php-cs-fixer changes
44 changes: 44 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->notPath('vendor/*')
->notPath('resources/*')
->notPath('database/*')
->notPath('storage/*')
->notPath('node_modules/*')
->in([
__DIR__ . '/src',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline_array' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"illuminate/view": "^7.0|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18",
"squizlabs/php_codesniffer": "3.*",
"phpunit/phpunit": "^7.0|^8.0|^9.0",
"orchestra/testbench": "~5.2"
Expand All @@ -45,6 +46,6 @@
"test": "vendor/bin/phpunit",
"test:windows": "vendor\\bin\\phpunit",
"check-style": "vendor/bin/phpcs --extensions=php ./src",
"fix-style": "vendor/bin/phpcbf --extensions=php ./src"
"fix-style": "vendor/bin/php-cs-fixer fix"
}
}

0 comments on commit e064e26

Please sign in to comment.