Skip to content

Commit

Permalink
Add check by PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeliot-Tm committed May 21, 2024
1 parent 8b15f09 commit a3053e3
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/automated_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate --strict

cs-fixer:
name: Check code style with CS Fixer
runs-on: ubuntu-latest

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- uses: actions/checkout@v4

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: "${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}"
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Check code style
run: composer run cs-fixer-check -- --show-progress=none

phpstan:
name: Static analyze with PHPStan
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
/.phpunit.cache/
/vendor/
/.php-cs-fixer.cache
14 changes: 14 additions & 0 deletions .php-cs-fixer-finder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

return $finder = (new PhpCsFixer\Finder())
->files()
->in(__DIR__)
->exclude(['var', 'vendor'])
->append([
'bin/dev/php-cs-fixer-update-baseline',
]);



19 changes: 19 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

$rules = [
'@Symfony' => true,
'@Symfony:risky' => true,
'concat_space' => [
'spacing' => 'one',
],
'phpdoc_align' => ['align' => 'left'],
];

$config = (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules($rules);

/** @var PhpCsFixer\Finder $finder */
$finder = require __DIR__ . '/.php-cs-fixer-finder.php';

return $config->setFinder($finder);
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
"sort-packages": true
},
"scripts": {
"cs-check": "@cs-fixer-check",
"cs-fix": "@cs-fixer-fix",
"cs-fixer-check": "vendor/bin/php-cs-fixer fix --dry-run",
"cs-fixer-fix": "vendor/bin/php-cs-fixer fix -vv",
"phpstan": [
"@phpstan-clear",
"@phpstan-analyse"
Expand Down

0 comments on commit a3053e3

Please sign in to comment.