From 70d5156b6cffe4a607a75c91c209f9e539e56a3a Mon Sep 17 00:00:00 2001 From: Andrei Ciungulete Date: Tue, 8 Jun 2021 15:40:33 +0300 Subject: [PATCH] Update php cs fixer (#29) * Update php-cs-fixer * Fix styling Co-authored-by: ciungulete --- .github/workflows/php-cs-fixer.yml | 32 ++++++++++++------------------ .php-cs-fixer.cache | 1 + .php_cs => .php-cs-fixer.dist.php | 20 +++++-------------- 3 files changed, 19 insertions(+), 34 deletions(-) create mode 100644 .php-cs-fixer.cache rename .php_cs => .php-cs-fixer.dist.php (73%) diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index 5cb3a86..502dbe7 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -3,27 +3,21 @@ name: Check & fix styling on: [push] jobs: - style: + php-cs-fixer: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v1 + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} - - name: Fix style - uses: docker://oskarstark/php-cs-fixer-ga - with: - args: --config=.php_cs --allow-risky=yes + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php-cs-fixer.dist.php --allow-risky=yes - - name: Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v2.3.0 - with: - commit_message: Fix styling - branch: ${{ steps.extract_branch.outputs.branch }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Fix styling diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache new file mode 100644 index 0000000..b8da5de --- /dev/null +++ b/.php-cs-fixer.cache @@ -0,0 +1 @@ +{"php":"8.0.5","version":"3.0.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sort_algorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":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,"single_trait_insert_per_statement":true},"hashes":{"src\/Invoice.php":2278568339,"src\/MoneyFormatter.php":1206229440,"src\/IsInvoicable\/IsInvoicableTrait.php":1957151012,"src\/InvoicableServiceProvider.php":672820863,"src\/InvoiceLine.php":3758312924,"src\/InvoiceReferenceGenerator.php":7251896,"config\/invoicable.php":47350322,"tests\/Feature\/InvoiceTest.php":1299334751,"tests\/AbstractTestCase.php":2619638986,"tests\/TestModel.php":482200789,"tests\/CreateTestModelsTable.php":2612826604,"tests\/Unit\/InvoiceReferenceTest.php":240943663,"tests\/Unit\/MoneyFormatterTest.php":1490742050,"database\/migrations\/2017_06_17_163005_create_invoices_tables.php":1842077571}} \ No newline at end of file diff --git a/.php_cs b/.php-cs-fixer.dist.php similarity index 73% rename from .php_cs rename to .php-cs-fixer.dist.php index b87a594..4eda2a2 100644 --- a/.php_cs +++ b/.php-cs-fixer.dist.php @@ -1,7 +1,5 @@ notPath('vendor') ->in([ __DIR__ . '/src', __DIR__ . '/config', @@ -13,16 +11,14 @@ ->ignoreDotFiles(true) ->ignoreVCS(true); -$config = new PhpCsFixer\Config(); -$config - ->setRiskyAllowed(true) +return (new PhpCsFixer\Config()) ->setRules([ '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => ['sortAlgorithm' => 'alpha'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], 'no_unused_imports' => true, 'not_operator_with_successor_space' => true, - 'trailing_comma_in_multiline_array' => true, + 'trailing_comma_in_multiline' => true, 'phpdoc_scalar' => true, 'unary_operator_spaces' => true, 'binary_operator_spaces' => true, @@ -31,16 +27,10 @@ ], 'phpdoc_single_line_var_spacing' => true, 'phpdoc_var_without_name' => true, - 'class_attributes_separation' => [ - 'elements' => [ - 'method', 'property', - ], - ], 'method_argument_space' => [ 'on_multiline' => 'ensure_fully_multiline', 'keep_multiple_spaces_after_comma' => true, - ] + ], + 'single_trait_insert_per_statement' => true, ]) ->setFinder($finder); - -return $config;