Skip to content

Commit

Permalink
Merge pull request #13 from Treggats/auto-format
Browse files Browse the repository at this point in the history
  • Loading branch information
mazedlx authored Mar 17, 2023
2 parents d675282 + 5bd741d commit 4af1d28
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 7,769 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Analyse and format

on:
push:
pull_request:

jobs:
analysis:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
php:
- 7.4
- 8.0
- 8.1

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
tools: composer:v2,phpstan
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest

- name: Run analysis
run: phpstan analyse --no-ansi --no-interaction --no-progress

format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
tools: composer:v2,php-cs-fixer
coverage: none

- name: Run formatter
run: php-cs-fixer fix --no-ansi

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: '*.php'
create_branch: false
add_options: '-u'
push_options: '--force-with-lease'
commit_message: ":hammer: :construction_worker: formatting changes"
56 changes: 13 additions & 43 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ on:
pull_request:

jobs:
test74:
runs-on: ubuntu-latest
phpunit:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
php:
- 7.4
- 8.0
- 8.1

steps:
- name: Checkout code
Expand All @@ -15,47 +25,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
tools: composer:v2
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest

- name: Execute tests
run: vendor/bin/phpunit --verbose
test80:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
tools: composer:v2
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-suggest

- name: Execute tests
run: vendor/bin/phpunit --verbose
test81:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
tools: composer:v2
coverage: none
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ docs
vendor
coverage
.phpunit.result.cache
.php-cs-fixer.cache
45 changes: 30 additions & 15 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
<?php

return PhpCsFixer\Config::create()
->setUsingCache(false)
$finder = PhpCsFixer\Finder::create()
->ignoreDotFiles(false)
->ignoreVCSIgnored(true)
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/config',
]);

return (new PhpCsFixer\Config())
->setFinder($finder)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'method_separation' => true,
'no_multiline_whitespace_before_semicolons' => true,
'phpdoc_separation' => true,
'multiline_whitespace_before_semicolons' => true,
'single_quote' => true,

'binary_operator_spaces' => [
'align_double_arrow' => false,
'align_equals' => false,
'operators' => [
'=' => 'single_space',
'=>' => 'single_space',
'<>' => 'single_space',
],
],
'not_operator_with_successor_space' => true,
// 'blank_line_after_opening_tag' => true,
// 'blank_line_before_return' => true,
'braces' => [
Expand All @@ -24,7 +37,7 @@
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'single_line_comment_style' => true,
'include' => true,
'lowercase_cast' => true,
// 'native_function_casing' => true,
Expand All @@ -34,13 +47,15 @@
// 'no_empty_comment' => true,
// 'no_empty_phpdoc' => true,
// 'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => [
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
'use',
'no_extra_blank_lines' => [
'tokens' => [
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
'use',
],
],
// 'no_leading_import_slash' => true,
// 'no_leading_namespace_whitespace' => true,
Expand Down Expand Up @@ -85,7 +100,7 @@
// 'space_after_semicolon' => true,
// 'standardize_not_equals' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"minimum-stability": "stable",
"require": {
"php": "^7.0|^8.0|^8.1",
"php": "^7.1|^8.0|^8.1",
"illuminate/http": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0",
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0"
},
Expand Down
Loading

0 comments on commit 4af1d28

Please sign in to comment.