Skip to content

Commit

Permalink
refactor: fixed code style with PHP CS Fixer (#7)
Browse files Browse the repository at this point in the history
* feat: added PHP CS Fixer to project

* refactor: refactored all files with cs-fixer
  • Loading branch information
SVillette committed Apr 6, 2023
1 parent b3f88c8 commit 0b3c6a5
Show file tree
Hide file tree
Showing 37 changed files with 715 additions and 115 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
- name: Run static analysis
run: composer run-script analyse

- name: Run PHP CS Fixer
run: composer run-script cs-fixer

- name: Execute tests (Unit tests) via PHPUnit
env:
SYMFONY_DEPRECATIONS_HELPER: 'max[direct]=0'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/local/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- name: Run static analysis
run: composer run-script analyse

- name: Run PHP CS Fixer
run: composer run-script cs-fixer

# - name: Mysql Dump
# run: MYSQL_PWD=root mysqldump -u root -h 172.17.0.2 -P 3306 --databases db_test_1 > db_test_1.sql

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

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('var')
;

return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'class_definition' => [
'multi_line_extends_each_single_line' => true,
'single_item_single_line' => true,
],
'concat_space' => [
'spacing' => 'one',
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'native_function_invocation' => [
'include' => [
'@all',
],
],
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['class', 'function', 'const'],
],
'phpdoc_align' => [
'align' => 'left',
],
'phpdoc_to_comment' => [
'ignored_tags' => ['var'],
],
'single_line_throw' => false,
])
->setFinder($finder)
->setRiskyAllowed(true)
;
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
"symfony/console": "^6.0",
"doctrine/orm": "^2.11",
"symfony/dotenv": "^6.0",
"webmozart/assert": "^1.11"
"webmozart/assert": "^1.11",
"friendsofphp/php-cs-fixer": "^3.16"
},
"scripts": {
"cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run",
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/phpunit"
}
Expand Down

0 comments on commit 0b3c6a5

Please sign in to comment.