From bdea2e4918ffe983cd758323d761352aca2ff5d5 Mon Sep 17 00:00:00 2001 From: Ved Date: Thu, 27 Jan 2022 08:01:03 +0545 Subject: [PATCH 1/2] Github action --- .github/workflows/php-cs-fixer.yml | 26 ++++++++++++++++++++++ .github/workflows/psalm.yml | 33 ++++++++++++++++++++++++++++ .github/workflows/run-tests.yml | 30 +++++++++++++++++++++++++ .gitignore | 1 + .php-cs-fixer.dist.php | 35 ++++++++++++++++++++++++++++++ composer.json | 10 +++++++-- psalm.xml.dist | 16 ++++++++++++++ 7 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/php-cs-fixer.yml create mode 100644 .github/workflows/psalm.yml create mode 100644 .github/workflows/run-tests.yml create mode 100644 .php-cs-fixer.dist.php create mode 100644 psalm.xml.dist diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..d45fe27 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,26 @@ +name: Check & fix styling + +on: [push] + +jobs: + style: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v1 + - name: Fix style + 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 }} diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..e48b24f --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,33 @@ +name: Psalm + +on: + push: + paths: + - '**.php' + - 'psalm.xml.dist' + +jobs: + psalm: + name: psalm + runs-on: ubuntu-latest + steps: + - 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, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + + - name: Run composer install + run: composer install -n --prefer-dist + + - name: Run psalm + run: ./vendor/bin/psalm --output-format=github diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..ff12e5a --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,30 @@ +name: "Run Tests - Current" + +on: [ push, pull_request ] + +jobs: + test: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: test_db + ports: + - 3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v1 + - name: Copy .env + run: php -r "file_exists('.env') || copy('.env.example', '.env');" + - name: Install Composer Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist + - name: Generate Key + run: php artisan key:generate + - name: Execute tests (Unit and Feature tests) via PHPUnit + env: + DB_PORT: ${{ job.services.mysql.ports[3306] }} + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index d3fd3ac..7bef785 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ yarn-error.log /.vscode public/dist resources/assets/js/routes.generated.js +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..d281d32 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,35 @@ +in([ + __DIR__.'/app', + __DIR__.'/tests', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR2' => 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, + '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/composer.json b/composer.json index 8490511..b8d7dd5 100644 --- a/composer.json +++ b/composer.json @@ -20,10 +20,12 @@ "require-dev": { "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", + "friendsofphp/php-cs-fixer": "^3.5", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^5.10", - "phpunit/phpunit": "^9.5.10" + "phpunit/phpunit": "^9.5.10", + "vimeo/psalm": "^4.18" }, "autoload": { "psr-4": { @@ -47,7 +49,11 @@ ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" - ] + ], + "psalm": "vendor/bin/psalm", + "test": "./vendor/bin/testbench package:test --parallel --no-coverage", + "test-coverage": "vendor/bin/phpunit --coverage-html coverage", + "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes" }, "extra": { "laravel": { diff --git a/psalm.xml.dist b/psalm.xml.dist new file mode 100644 index 0000000..f327d32 --- /dev/null +++ b/psalm.xml.dist @@ -0,0 +1,16 @@ + + + + + + + + + From 431e80acf13e0c5ebf1dd305f32ff04d83d667b5 Mon Sep 17 00:00:00 2001 From: bedus-creation Date: Thu, 27 Jan 2022 02:17:02 +0000 Subject: [PATCH 2/2] Fix styling --- app/Application/Inertia/AppData.php | 1 - app/Application/Inertia/Translations.php | 5 ++--- .../ModulesEloquentRepository.php | 2 +- .../Users/Actions/Auth/RegisterNewUser.php | 10 ++++----- .../Actions/UpdateUserProfileInformation.php | 17 +++++++------- app/Domain/Users/Casts/FullNameCast.php | 2 +- app/Domain/Users/DTO/FullNameDto.php | 22 +++++++++---------- app/Domain/Users/Models/Permission.php | 1 - app/Domain/Users/Models/Role.php | 1 - app/Domain/Users/Models/User.php | 4 ++-- .../Repositories/PermissionsRepository.php | 1 - .../Users/Repositories/RolesRepository.php | 1 - .../Users/Repositories/UsersRepository.php | 1 - app/Enums/DBTables.php | 18 +++++++-------- app/Infrastructure/Kernels/HttpKernel.php | 16 +++++++------- .../Middleware/Authenticate.php | 2 +- .../Middleware/RedirectIfAuthenticated.php | 2 +- .../Providers/RouteServiceProvider.php | 2 +- .../DataTransferObject/DataTransferObject.php | 2 +- .../DataTransferObject/DtoInterface.php | 1 - app/Infrastructure/Support/Helper.php | 1 - .../Support/Inertia/InertiaData.php | 6 ++--- .../Translations/TranslationCaching.php | 4 ++-- tests/Feature/ExampleTest.php | 1 - 24 files changed, 56 insertions(+), 67 deletions(-) diff --git a/app/Application/Inertia/AppData.php b/app/Application/Inertia/AppData.php index c8291f3..14114cd 100644 --- a/app/Application/Inertia/AppData.php +++ b/app/Application/Inertia/AppData.php @@ -12,7 +12,6 @@ */ class AppData implements InertiaDataSharable { - public function key(): string { return 'app'; diff --git a/app/Application/Inertia/Translations.php b/app/Application/Inertia/Translations.php index 052a90d..fe4b25f 100644 --- a/app/Application/Inertia/Translations.php +++ b/app/Application/Inertia/Translations.php @@ -13,7 +13,6 @@ */ class Translations implements InertiaDataSharable { - public function key(): string { return 'translations'; @@ -23,9 +22,9 @@ public function data(): Closure|array { return function () { $translations = new TranslationCaching(); - $locale = app()->getLocale(); + $locale = app()->getLocale(); - if ( app()->environment('local') ) { + if (app()->environment('local')) { $translations->flush($locale); } diff --git a/app/Domain/Modules/Repositories/ModulesEloquentRepository.php b/app/Domain/Modules/Repositories/ModulesEloquentRepository.php index 2288c0a..ed82f60 100644 --- a/app/Domain/Modules/Repositories/ModulesEloquentRepository.php +++ b/app/Domain/Modules/Repositories/ModulesEloquentRepository.php @@ -30,7 +30,7 @@ public function findByName(string $name): Module|array $modules = $this->getBuilder()->where('name', $name)->get(); $this->resetModel(); - if ( $modules->isEmpty() ) { + if ($modules->isEmpty()) { throw new ModelNotFoundException(); } diff --git a/app/Domain/Users/Actions/Auth/RegisterNewUser.php b/app/Domain/Users/Actions/Auth/RegisterNewUser.php index 2e91b24..f4f7c5c 100644 --- a/app/Domain/Users/Actions/Auth/RegisterNewUser.php +++ b/app/Domain/Users/Actions/Auth/RegisterNewUser.php @@ -33,16 +33,16 @@ public function create(array $input) Validator::make($input, [ 'full_name' => ['required', 'string', 'max:255'], - 'email' => ['required', 'string', 'email', 'max:255', "unique:{$usersTable},email"], - 'password' => $this->passwordRules(), - 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['required', 'accepted'] : '', + 'email' => ['required', 'string', 'email', 'max:255', "unique:{$usersTable},email"], + 'password' => $this->passwordRules(), + 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['required', 'accepted'] : '', ])->validate(); return tap( app(UsersRepository::class)->create([ 'full_name' => FullNameDto::fromString($input['full_name']), - 'email' => $input['email'], - 'password' => $input['password'], + 'email' => $input['email'], + 'password' => $input['password'], ]), function (User $user) { $user->assignRole(Jetstream::defaultRole()); diff --git a/app/Domain/Users/Actions/UpdateUserProfileInformation.php b/app/Domain/Users/Actions/UpdateUserProfileInformation.php index b0a5b38..a800703 100644 --- a/app/Domain/Users/Actions/UpdateUserProfileInformation.php +++ b/app/Domain/Users/Actions/UpdateUserProfileInformation.php @@ -23,23 +23,22 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation public function update($user, array $input) { Validator::make($input, [ - 'name' => ['required', 'string', 'max:255'], + 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'email', 'max:255', Rule::unique(DBTables::AUTH_USERS)->ignore($user->id)], 'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:1024'], ])->validateWithBag('updateProfileInformation'); - if ( isset($input['photo']) ) { + if (isset($input['photo'])) { $user->updateProfilePhoto($input['photo']); } - if ( $input['email'] !== $user->email && - $user instanceof MustVerifyEmail ) { + if ($input['email'] !== $user->email && + $user instanceof MustVerifyEmail) { $this->updateVerifiedUser($user, $input); - } - else { + } else { $user->forceFill([ 'full_name' => FullNameDto::fromString($input['name']), - 'email' => $input['email'], + 'email' => $input['email'], ])->save(); } } @@ -55,8 +54,8 @@ public function update($user, array $input) protected function updateVerifiedUser($user, array $input) { $user->forceFill([ - 'full_name' => FullNameDto::fromString($input['name']), - 'email' => $input['email'], + 'full_name' => FullNameDto::fromString($input['name']), + 'email' => $input['email'], 'email_verified_at' => null, ])->save(); diff --git a/app/Domain/Users/Casts/FullNameCast.php b/app/Domain/Users/Casts/FullNameCast.php index e00e488..3affe0c 100644 --- a/app/Domain/Users/Casts/FullNameCast.php +++ b/app/Domain/Users/Casts/FullNameCast.php @@ -41,7 +41,7 @@ public function get($model, string $key, $value, array $attributes) */ public function set($model, string $key, $value, array $attributes) { - if ( !$value instanceof FullNameDto ) { + if (! $value instanceof FullNameDto) { throw new InvalidArgumentException('The given value is not an FullNameDto instance.'); } diff --git a/app/Domain/Users/DTO/FullNameDto.php b/app/Domain/Users/DTO/FullNameDto.php index bdf4b60..738ca64 100644 --- a/app/Domain/Users/DTO/FullNameDto.php +++ b/app/Domain/Users/DTO/FullNameDto.php @@ -20,38 +20,38 @@ public static function fromString(string $name): self { $explodedName = explode(' ', $name); - $firstName = array_shift($explodedName); - $lastName = array_pop($explodedName) ?? ''; + $firstName = array_shift($explodedName); + $lastName = array_pop($explodedName) ?? ''; $middleName = count($explodedName) ? trim(implode(' ', $explodedName)) : ''; return new static([ - 'first_name' => $firstName, + 'first_name' => $firstName, 'middle_name' => $middleName, - 'last_name' => $lastName, + 'last_name' => $lastName, ]); } public function toArray(): array { return [ - 'first_name' => $this->firstName, + 'first_name' => $this->firstName, 'middle_name' => $this->middleName, - 'last_name' => $this->lastName, + 'last_name' => $this->lastName, ]; } public function toString(): string { $fullName = []; - if ( $this->firstName ) { + if ($this->firstName) { $fullName[] = $this->firstName; } - if ( $this->middleName ) { + if ($this->middleName) { $fullName[] = $this->middleName; } - if ( $this->lastName ) { + if ($this->lastName) { $fullName[] = $this->lastName; } @@ -60,8 +60,8 @@ public function toString(): string protected function map(array $data): void { - $this->firstName = Arr::get($data, 'first_name'); + $this->firstName = Arr::get($data, 'first_name'); $this->middleName = Arr::get($data, 'middle_name'); - $this->lastName = Arr::get($data, 'last_name'); + $this->lastName = Arr::get($data, 'last_name'); } } diff --git a/app/Domain/Users/Models/Permission.php b/app/Domain/Users/Models/Permission.php index 4686bdc..5d6098a 100644 --- a/app/Domain/Users/Models/Permission.php +++ b/app/Domain/Users/Models/Permission.php @@ -19,5 +19,4 @@ */ class Permission extends BasePermission { - } diff --git a/app/Domain/Users/Models/Role.php b/app/Domain/Users/Models/Role.php index 6c0a65d..3f339b3 100644 --- a/app/Domain/Users/Models/Role.php +++ b/app/Domain/Users/Models/Role.php @@ -18,5 +18,4 @@ */ class Role extends BaseRole { - } diff --git a/app/Domain/Users/Models/User.php b/app/Domain/Users/Models/User.php index e0e7629..22d835e 100644 --- a/app/Domain/Users/Models/User.php +++ b/app/Domain/Users/Models/User.php @@ -81,7 +81,7 @@ class User extends Authenticatable ]; protected $casts = [ - 'full_name' => FullNameCast::class, + 'full_name' => FullNameCast::class, 'two_factor_recovery_codes' => 'array', ]; @@ -112,7 +112,7 @@ protected static function newFactory() public function setPasswordAttribute(string $password): void { /** @var HashManager $hashManager */ - $hashManager = app()->make(HashManager::class); + $hashManager = app()->make(HashManager::class); $this->attributes['password'] = $hashManager->needsRehash($password) ? $hashManager->make($password) : $password; } diff --git a/app/Domain/Users/Repositories/PermissionsRepository.php b/app/Domain/Users/Repositories/PermissionsRepository.php index 7962cde..a0557b0 100644 --- a/app/Domain/Users/Repositories/PermissionsRepository.php +++ b/app/Domain/Users/Repositories/PermissionsRepository.php @@ -11,5 +11,4 @@ */ interface PermissionsRepository extends RepositoryInterface { - } diff --git a/app/Domain/Users/Repositories/RolesRepository.php b/app/Domain/Users/Repositories/RolesRepository.php index 41f311d..aeb9b7c 100644 --- a/app/Domain/Users/Repositories/RolesRepository.php +++ b/app/Domain/Users/Repositories/RolesRepository.php @@ -11,5 +11,4 @@ */ interface RolesRepository extends RepositoryInterface { - } diff --git a/app/Domain/Users/Repositories/UsersRepository.php b/app/Domain/Users/Repositories/UsersRepository.php index 26dbf96..4700723 100644 --- a/app/Domain/Users/Repositories/UsersRepository.php +++ b/app/Domain/Users/Repositories/UsersRepository.php @@ -11,5 +11,4 @@ */ interface UsersRepository extends RepositoryInterface { - } diff --git a/app/Enums/DBTables.php b/app/Enums/DBTables.php index 53f1db8..9e8d3d9 100644 --- a/app/Enums/DBTables.php +++ b/app/Enums/DBTables.php @@ -10,16 +10,16 @@ enum DBTables { public const SYS_FAILED_JOBS = 'sys_failed_jobs'; - public const SYS_SESSIONS = 'sys_sessions'; - public const SYS_MIGRATIONS = 'sys_migrations'; - public const SYS_MODULES = 'sys_modules'; + public const SYS_SESSIONS = 'sys_sessions'; + public const SYS_MIGRATIONS = 'sys_migrations'; + public const SYS_MODULES = 'sys_modules'; - public const AUTH_USERS = 'auth_users'; + public const AUTH_USERS = 'auth_users'; public const AUTH_PASSWORD_RESETS = 'auth_password_resets'; public const AUTH_PERSONAL_ACCESS_TOKENS = 'auth_personal_access_tokens'; - public const AUTH_ROLES = 'auth_roles'; - public const AUTH_PERMISSIONS = 'auth_permissions'; - public const AUTH_USERS_PERMISSIONS = 'auth_users_permissions'; - public const AUTH_USERS_ROLES = 'auth_users_roles'; - public const AUTH_ROLES_PERMISSIONS = 'auth_roles_permissions'; + public const AUTH_ROLES = 'auth_roles'; + public const AUTH_PERMISSIONS = 'auth_permissions'; + public const AUTH_USERS_PERMISSIONS = 'auth_users_permissions'; + public const AUTH_USERS_ROLES = 'auth_users_roles'; + public const AUTH_ROLES_PERMISSIONS = 'auth_roles_permissions'; } diff --git a/app/Infrastructure/Kernels/HttpKernel.php b/app/Infrastructure/Kernels/HttpKernel.php index c4ad6ab..b1414f8 100644 --- a/app/Infrastructure/Kernels/HttpKernel.php +++ b/app/Infrastructure/Kernels/HttpKernel.php @@ -60,14 +60,14 @@ class HttpKernel extends Kernel * @var array */ protected $routeMiddleware = [ - 'auth' => \App\Infrastructure\Middleware\Authenticate::class, - 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, - 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, - 'can' => \Illuminate\Auth\Middleware\Authorize::class, - 'guest' => \App\Infrastructure\Middleware\RedirectIfAuthenticated::class, + 'auth' => \App\Infrastructure\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Infrastructure\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, - 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, - 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, - 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, ]; } diff --git a/app/Infrastructure/Middleware/Authenticate.php b/app/Infrastructure/Middleware/Authenticate.php index 3adc621..8a2b8ba 100644 --- a/app/Infrastructure/Middleware/Authenticate.php +++ b/app/Infrastructure/Middleware/Authenticate.php @@ -21,7 +21,7 @@ class Authenticate extends Middleware */ protected function redirectTo($request) { - if ( !$request->expectsJson() ) { + if (! $request->expectsJson()) { return route('login'); } } diff --git a/app/Infrastructure/Middleware/RedirectIfAuthenticated.php b/app/Infrastructure/Middleware/RedirectIfAuthenticated.php index b537fba..7ae52c1 100644 --- a/app/Infrastructure/Middleware/RedirectIfAuthenticated.php +++ b/app/Infrastructure/Middleware/RedirectIfAuthenticated.php @@ -28,7 +28,7 @@ public function handle(Request $request, Closure $next, ...$guards) $guards = empty($guards) ? [null] : $guards; foreach ($guards as $guard) { - if ( Auth::guard($guard)->check() ) { + if (Auth::guard($guard)->check()) { return redirect(RouteServiceProvider::HOME); } } diff --git a/app/Infrastructure/Providers/RouteServiceProvider.php b/app/Infrastructure/Providers/RouteServiceProvider.php index f113478..f9e7632 100644 --- a/app/Infrastructure/Providers/RouteServiceProvider.php +++ b/app/Infrastructure/Providers/RouteServiceProvider.php @@ -43,7 +43,7 @@ public function boot() $this->configureRateLimiting(); $this->routes(function () { - if ( app()->environment() !== 'production' ) { + if (app()->environment() !== 'production') { Route::prefix('dev')->middleware('web')->group(base_path('routes/dev.php')); } diff --git a/app/Infrastructure/Support/DataTransferObject/DataTransferObject.php b/app/Infrastructure/Support/DataTransferObject/DataTransferObject.php index 2ef80a5..1919b64 100644 --- a/app/Infrastructure/Support/DataTransferObject/DataTransferObject.php +++ b/app/Infrastructure/Support/DataTransferObject/DataTransferObject.php @@ -16,7 +16,7 @@ public function __construct(array $data) { $validator = Validator::make($data, $this->validationRules()); - if ( $validator->fails() ) { + if ($validator->fails()) { throw new InvalidArgumentException('Error: '.$validator->errors()->first()); } diff --git a/app/Infrastructure/Support/DataTransferObject/DtoInterface.php b/app/Infrastructure/Support/DataTransferObject/DtoInterface.php index ab8bf62..fe1c1df 100644 --- a/app/Infrastructure/Support/DataTransferObject/DtoInterface.php +++ b/app/Infrastructure/Support/DataTransferObject/DtoInterface.php @@ -9,5 +9,4 @@ */ interface DtoInterface { - } diff --git a/app/Infrastructure/Support/Helper.php b/app/Infrastructure/Support/Helper.php index 5bc5501..d2fc1f9 100644 --- a/app/Infrastructure/Support/Helper.php +++ b/app/Infrastructure/Support/Helper.php @@ -9,5 +9,4 @@ */ class Helper { - } diff --git a/app/Infrastructure/Support/Inertia/InertiaData.php b/app/Infrastructure/Support/Inertia/InertiaData.php index 51778c7..497f8b7 100644 --- a/app/Infrastructure/Support/Inertia/InertiaData.php +++ b/app/Infrastructure/Support/Inertia/InertiaData.php @@ -19,7 +19,7 @@ class InertiaData */ public function get(): array { - $path = config('inertia.shareable_path'); + $path = config('inertia.shareable_path'); $namespace = config('inertia.shareable_namespace'); $finder = new Finder(); @@ -31,7 +31,7 @@ public function get(): array $class = $file->getBasename('.php'); $class = sprintf("%s\\%s", $namespace, $class); - if ( !class_exists($class) ) { + if (! class_exists($class)) { throw new InvalidInertiaDataSharableClassException( sprintf('Inertia Class %s does not exist', $class) ); @@ -39,7 +39,7 @@ public function get(): array $instance = app()->make($class); - if ( !$instance instanceof InertiaDataSharable ) { + if (! $instance instanceof InertiaDataSharable) { throw new InvalidInertiaDataSharableClassException( sprintf('Inertia Class %s does not implement InertiaDataSharable', $class) ); diff --git a/app/Libraries/Translations/TranslationCaching.php b/app/Libraries/Translations/TranslationCaching.php index 08a2f35..135b5ce 100644 --- a/app/Libraries/Translations/TranslationCaching.php +++ b/app/Libraries/Translations/TranslationCaching.php @@ -19,7 +19,7 @@ public function getAll(string $locale): Collection $files = File::files(resource_path("lang/{$locale}")); return collect($files) - ->map(fn($file) => [$file->getFilenameWithoutExtension() => require($file)]) + ->map(fn ($file) => [$file->getFilenameWithoutExtension() => require($file)]) ->collapse(); }); } @@ -45,7 +45,7 @@ public function flushAll(): void protected function availableLocales(): array { - return collect(File::directories(resource_path('lang')))->map(fn($path) => basename($path))->toArray(); + return collect(File::directories(resource_path('lang')))->map(fn ($path) => basename($path))->toArray(); } protected function getCacheKey(string $locale): string diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 4ae02bc..0894c60 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -2,7 +2,6 @@ namespace Tests\Feature; -use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class ExampleTest extends TestCase