From 2e8a3e5e77c3a3f873c70da797c4ee40a6a38871 Mon Sep 17 00:00:00 2001 From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com> Date: Tue, 19 Mar 2024 08:58:40 +0100 Subject: [PATCH] chore: update Pint (#22) * WIP * style: apply Pint --------- Co-authored-by: ralphjsmit --- .github/workflows/php-cs-fixer.yml | 23 ----------- .github/workflows/pint.yml | 27 +++++++++++++ .php_cs.dist.php | 40 ------------------- pint.json | 19 +++++++++ resources/lang/en/translations.php | 2 +- tests/Fixtures/Http/Livewire/CreatePost.php | 2 +- tests/Fixtures/Http/Livewire/EditPost.php | 2 +- .../migrations/create_test_tables.php | 3 +- tests/SEOTest.php | 7 ++-- 9 files changed, 54 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/php-cs-fixer.yml create mode 100644 .github/workflows/pint.yml delete mode 100644 .php_cs.dist.php create mode 100644 pint.json diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml deleted file mode 100644 index 36e842c..0000000 --- a/.github/workflows/php-cs-fixer.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Check & fix styling - -on: [ push ] - -jobs: - php-cs-fixer: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - - - name: Run PHP CS Fixer - uses: docker://oskarstark/php-cs-fixer-ga - with: - args: --config=.php_cs.dist.php --allow-risky=yes - - - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: Fix styling diff --git a/.github/workflows/pint.yml b/.github/workflows/pint.yml new file mode 100644 index 0000000..7fed9c2 --- /dev/null +++ b/.github/workflows/pint.yml @@ -0,0 +1,27 @@ +name: Lint with Pint + +on: + pull_request: + workflow_call: + workflow_dispatch: + +jobs: + pint: + name: Run Pint + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Run Pint + uses: aglipanci/laravel-pint-action@latest + with: + verboseMode: true + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "style: apply Pint" \ No newline at end of file diff --git a/.php_cs.dist.php b/.php_cs.dist.php deleted file mode 100644 index 8d8a790..0000000 --- a/.php_cs.dist.php +++ /dev/null @@ -1,40 +0,0 @@ -in([ - __DIR__ . '/src', - __DIR__ . '/tests', - ]) - ->name('*.php') - ->notName('*.blade.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return (new PhpCsFixer\Config()) - ->setRules([ - '@PSR12' => 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, - 'class_attributes_separation' => [ - 'elements' => [ - 'method' => 'one', - ], - ], - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'single_trait_insert_per_statement' => true, - ]) - ->setFinder($finder); diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..e0aa46e --- /dev/null +++ b/pint.json @@ -0,0 +1,19 @@ +{ + "preset": "laravel", + "rules": { + "no_superfluous_phpdoc_tags": true, + "concat_space": { + "spacing": "one" + }, + "single_quote": true, + "combine_consecutive_issets": true, + "combine_consecutive_unsets": true, + "explicit_string_variable": true, + "global_namespace_import": true, + "single_trait_insert_per_statement": true, + "ordered_traits": true, + "types_spaces": { + "space": "single" + } + } +} \ No newline at end of file diff --git a/resources/lang/en/translations.php b/resources/lang/en/translations.php index 77a821f..e5969a8 100644 --- a/resources/lang/en/translations.php +++ b/resources/lang/en/translations.php @@ -6,4 +6,4 @@ 'author' => 'Author name', 'image' => 'Image', 'characters' => 'Characters', -]; \ No newline at end of file +]; diff --git a/tests/Fixtures/Http/Livewire/CreatePost.php b/tests/Fixtures/Http/Livewire/CreatePost.php index 8abbc11..2bb9176 100644 --- a/tests/Fixtures/Http/Livewire/CreatePost.php +++ b/tests/Fixtures/Http/Livewire/CreatePost.php @@ -42,7 +42,7 @@ protected function getFormStatePath(): ?string return 'data'; } - protected function getFormModel(): Model|string|null + protected function getFormModel(): Model | string | null { return Post::class; } diff --git a/tests/Fixtures/Http/Livewire/EditPost.php b/tests/Fixtures/Http/Livewire/EditPost.php index 90fe3a5..364519a 100644 --- a/tests/Fixtures/Http/Livewire/EditPost.php +++ b/tests/Fixtures/Http/Livewire/EditPost.php @@ -33,7 +33,7 @@ public function render(): View return view('livewire.edit-post'); } - protected function getFormModel(): Model|string|null + protected function getFormModel(): Model | string | null { return $this->post; } diff --git a/tests/Fixtures/migrations/create_test_tables.php b/tests/Fixtures/migrations/create_test_tables.php index 367e3f3..59beae4 100644 --- a/tests/Fixtures/migrations/create_test_tables.php +++ b/tests/Fixtures/migrations/create_test_tables.php @@ -4,7 +4,8 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class () extends Migration { +return new class() extends Migration +{ public function up(): void { Schema::create('posts', function (Blueprint $table) { diff --git a/tests/SEOTest.php b/tests/SEOTest.php index 9bd6803..d9edbe6 100644 --- a/tests/SEOTest.php +++ b/tests/SEOTest.php @@ -1,14 +1,13 @@