diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac312b8..ec79f26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,9 @@ jobs: DB_PORT: ${{ job.services.mysql.ports['3306'] }} REDIS_PORT: ${{ job.services.redis.ports['6379'] }} + - name: Test code style pint + run: composer run pint-test + - name: Test with phpunit run: composer run tests:coverage env: diff --git a/app/App/Shared/Exceptions/Handler.php b/app/App/Shared/Exceptions/Handler.php index 378d47d..0b53038 100644 --- a/app/App/Shared/Exceptions/Handler.php +++ b/app/App/Shared/Exceptions/Handler.php @@ -26,7 +26,6 @@ class Handler extends ExceptionHandler public function register(): void { $this->reportable(function (Throwable $e) { - // }); } } diff --git a/app/App/Shared/Http/Middleware/EncryptCookies.php b/app/App/Shared/Http/Middleware/EncryptCookies.php index 18e70c7..380ccc3 100644 --- a/app/App/Shared/Http/Middleware/EncryptCookies.php +++ b/app/App/Shared/Http/Middleware/EncryptCookies.php @@ -14,6 +14,5 @@ class EncryptCookies extends Middleware * @var array */ protected $except = [ - // ]; } diff --git a/app/App/Shared/Http/Middleware/PreventRequestsDuringMaintenance.php b/app/App/Shared/Http/Middleware/PreventRequestsDuringMaintenance.php index dc16938..6f6dfd3 100644 --- a/app/App/Shared/Http/Middleware/PreventRequestsDuringMaintenance.php +++ b/app/App/Shared/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -14,6 +14,5 @@ class PreventRequestsDuringMaintenance extends Middleware * @var array */ protected $except = [ - // ]; } diff --git a/app/App/Shared/Http/Middleware/RedirectIfAuthenticated.php b/app/App/Shared/Http/Middleware/RedirectIfAuthenticated.php index c8aa1cf..a144eea 100644 --- a/app/App/Shared/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/App/Shared/Http/Middleware/RedirectIfAuthenticated.php @@ -15,7 +15,7 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next + * @param Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next */ public function handle(Request $request, Closure $next, string ...$guards): Response { diff --git a/app/App/Shared/Http/Middleware/VerifyCsrfToken.php b/app/App/Shared/Http/Middleware/VerifyCsrfToken.php index abdb44d..54ff41d 100644 --- a/app/App/Shared/Http/Middleware/VerifyCsrfToken.php +++ b/app/App/Shared/Http/Middleware/VerifyCsrfToken.php @@ -14,6 +14,5 @@ class VerifyCsrfToken extends Middleware * @var array */ protected $except = [ - // ]; } diff --git a/app/App/Shared/Providers/AppServiceProvider.php b/app/App/Shared/Providers/AppServiceProvider.php index 99400b6..0651336 100644 --- a/app/App/Shared/Providers/AppServiceProvider.php +++ b/app/App/Shared/Providers/AppServiceProvider.php @@ -10,11 +10,9 @@ class AppServiceProvider extends ServiceProvider { public function register(): void { - // } public function boot(): void { - // } } diff --git a/app/App/Shared/Providers/AuthServiceProvider.php b/app/App/Shared/Providers/AuthServiceProvider.php index ff4e1e2..1ed1032 100644 --- a/app/App/Shared/Providers/AuthServiceProvider.php +++ b/app/App/Shared/Providers/AuthServiceProvider.php @@ -15,11 +15,9 @@ class AuthServiceProvider extends ServiceProvider * @var array */ protected $policies = [ - // ]; public function boot(): void { - // } } diff --git a/app/App/Shared/Providers/EventServiceProvider.php b/app/App/Shared/Providers/EventServiceProvider.php index f0341b3..1b4433b 100644 --- a/app/App/Shared/Providers/EventServiceProvider.php +++ b/app/App/Shared/Providers/EventServiceProvider.php @@ -26,7 +26,6 @@ class EventServiceProvider extends ServiceProvider */ public function boot(): void { - // } /** diff --git a/composer.json b/composer.json index cd685d6..62b579e 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ }, "require-dev": { "fakerphp/faker": "^1.9.1", - "laravel/pint": "^1.0", + "laravel/pint": "^1.13", "laravel/sail": "^1.18", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", @@ -36,6 +36,10 @@ "scripts": { "tests": "vendor/bin/phpunit", "tests:coverage": "vendor/bin/phpunit --coverage-clover coverage.xml", + "pint": "./vendor/bin/pint", + "pint-dirty": "./vendor/bin/pint --dirty", + "pint-test": "./vendor/bin/pint --test", + "pint-test-dirty": "./vendor/bin/pint --test --dirty", "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" diff --git a/composer.lock b/composer.lock index e399317..c49dc1a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9c491b8531eec05ba41a11d9276a5749", + "content-hash": "6707bd0c24075e843a93f12dec991b03", "packages": [ { "name": "brick/math", diff --git a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php index f1bb20c..545734f 100644 --- a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php +++ b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php @@ -6,7 +6,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('password_reset_tokens', function (Blueprint $table) { diff --git a/docs/technical/local-development.md b/docs/technical/local-development.md index 0589e84..ca4b117 100644 --- a/docs/technical/local-development.md +++ b/docs/technical/local-development.md @@ -52,3 +52,24 @@ If you want to execute scripts or run commands, you need to open up a shell proc ```shell docker compose exec php sh ``` + + +## Code style + +We've implemented a code style checker and fixer called Laravel Pint, which is a wrapper around PHP-CS-Fixer. + +The following composer scripts can be run: + +```shell +# To fix the codebase code style +composer run pint + +# Fix code style on the changes you made +composer run pint-dirty + +# Test the code style of the codebase +composer run pint-test + +# Test the code style of the changes you made +composer run pint-test-dirty +``` diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..e146d3b --- /dev/null +++ b/pint.json @@ -0,0 +1,52 @@ +{ + "preset": "laravel", + "exclude": [ + "config", + "lang" + ], + "rules": { + "no_extra_blank_lines": { + "tokens": [ + "attribute", + "break", + "case", + "continue", + "curly_brace_block", + "default", + "extra", + "parenthesis_brace_block", + "return", + "square_brace_block", + "switch", + "throw", + "use", + "use_trait" + ] + }, + "method_argument_space": { + "on_multiline": "ensure_fully_multiline" + }, + "align_multiline_comment": true, + "class_definition": { + "single_line": false + }, + "new_with_braces": { + "anonymous_class": false, + "named_class": true + }, + "global_namespace_import": { + "import_classes": true, + "import_constants": true, + "import_functions": false + }, + "is_null": true, + "logical_operators": true, + "no_empty_comment": true, + "ordered_traits": true, + "ternary_to_null_coalescing": true, + "explicit_indirect_variable": true, + "modernize_types_casting": true, + "no_useless_else": true, + "nullable_type_declaration_for_default_null_value": true + } +}