diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..026cfbfa --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,22 @@ +name: Format [PHP] + +on: + pull_request: + paths: + - '**.php' + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + steps: + - 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 + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Apply php-cs-fixer changes \ No newline at end of file diff --git a/.php_cs b/.php_cs new file mode 100644 index 00000000..a6b39063 --- /dev/null +++ b/.php_cs @@ -0,0 +1,19 @@ +notPath('node_modules') + ->notPath('vendor') + ->notPath('public') + ->notPath('resources') + ->in(__DIR__) + ->name('*.php') + ->notName('*.blade.php'); + +return PhpCsFixer\Config::create() + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sortAlgorithm' => 'alpha'], + 'no_unused_imports' => true, + ]) + ->setFinder($finder);