From 5866a853ec4d1eab44f8687cb53980af85fa1f26 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Wed, 16 Oct 2024 10:20:17 +0200 Subject: [PATCH 1/5] fix(LAR-73): failed tests --- resources/views/livewire/articles/_form.blade.php | 8 ++++---- resources/views/livewire/articles/create.blade.php | 4 +++- resources/views/livewire/discussions/_form.blade.php | 4 ++-- resources/views/livewire/discussions/create.blade.php | 6 +++++- resources/views/livewire/forum/_form.blade.php | 4 ++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/resources/views/livewire/articles/_form.blade.php b/resources/views/livewire/articles/_form.blade.php index d44422f6..da0239d5 100644 --- a/resources/views/livewire/articles/_form.blade.php +++ b/resources/views/livewire/articles/_form.blade.php @@ -17,10 +17,10 @@ class="flex items-center pl-3 font-sans text-base font-medium text-gray-500 dark
@hasanyrole('admin|moderator') - + {{ isset($article) ? __('Enregistrer') : __('Publier') }} - + @else @if (isset($article)) @@ -98,10 +98,10 @@ class="block px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:text-gray- @else - + {{ __('Enregistrer') }} - + @endif @endhasanyrole diff --git a/resources/views/livewire/articles/create.blade.php b/resources/views/livewire/articles/create.blade.php index bcb3cb68..e1ffa12e 100644 --- a/resources/views/livewire/articles/create.blade.php +++ b/resources/views/livewire/articles/create.blade.php @@ -1,3 +1,5 @@
- @include('livewire.articles._form') +
+ @include('livewire.articles._form') +
diff --git a/resources/views/livewire/discussions/_form.blade.php b/resources/views/livewire/discussions/_form.blade.php index f887f4f1..217056ae 100644 --- a/resources/views/livewire/discussions/_form.blade.php +++ b/resources/views/livewire/discussions/_form.blade.php @@ -38,10 +38,10 @@ class="mt-2"
- + Enregistrer - +
diff --git a/resources/views/livewire/discussions/create.blade.php b/resources/views/livewire/discussions/create.blade.php index c0958488..24acb4ad 100644 --- a/resources/views/livewire/discussions/create.blade.php +++ b/resources/views/livewire/discussions/create.blade.php @@ -1,3 +1,7 @@
- @include('livewire.discussions._form') +
+
+ @include('livewire.discussions._form') +
+
diff --git a/resources/views/livewire/forum/_form.blade.php b/resources/views/livewire/forum/_form.blade.php index c43edbd7..964ec643 100644 --- a/resources/views/livewire/forum/_form.blade.php +++ b/resources/views/livewire/forum/_form.blade.php @@ -49,10 +49,10 @@ class="font-medium text-primary-600 underline hover:text-primary-600-hover"
- + Enregistrer - +
From ba9659d98c27a0de8376cb64e5ad5b3f3fa276f7 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Wed, 16 Oct 2024 10:23:47 +0200 Subject: [PATCH 2/5] refactor: apply laravel pint --- app/Livewire/MarkdownX.php | 2 +- app/Models/User.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Livewire/MarkdownX.php b/app/Livewire/MarkdownX.php index 258ea9b8..c0e7008d 100644 --- a/app/Livewire/MarkdownX.php +++ b/app/Livewire/MarkdownX.php @@ -131,7 +131,7 @@ public function upload(array $payload): void @[, $file_data] = explode(',', $file_data); $type = explode('/', $type)[1]; - if ( ! in_array($type, config('markdownx.image.allowed_file_types'))) { + if (! in_array($type, config('markdownx.image.allowed_file_types'))) { $this->dispatch('markdown-x-image-uploaded', [ 'status' => 400, 'message' => 'File type not supported. Must be of type '.implode(', ', config('markdownx.image.allowed_file_types')), diff --git a/app/Models/User.php b/app/Models/User.php index 750efa8d..73019b48 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -207,8 +207,8 @@ public static function findOrCreateSocialUserProvider(SocialUser $socialUser, st 'name' => $socialUser->getName() ?? $socialUser->getNickName() ?? $socialUser->getId(), 'email' => $socialEmail, 'username' => $socialUser->getNickName() ?? $socialUser->getId(), - 'github_profile' => 'github' === $provider ? $socialUser->getNickName() : null, - 'twitter_profile' => 'twitter' === $provider ? $socialUser->getNickName() : null, + 'github_profile' => $provider === 'github' ? $socialUser->getNickName() : null, + 'twitter_profile' => $provider === 'twitter' ? $socialUser->getNickName() : null, 'email_verified_at' => now(), 'avatar_type' => $provider, ]); @@ -425,7 +425,6 @@ public function scopeMostSolutionsInLastDays(Builder $query, int $days): Builder * Scope for most submissions in the last days. * * @param Builder $query - * @param int $days * @return Builder */ public function scopeMostSubmissionsInLastDays(Builder $query, int $days): Builder From 91f05158d337bca6769cc140ac510e1762b46252 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Wed, 16 Oct 2024 10:26:35 +0200 Subject: [PATCH 3/5] feat: update composer dependencies --- composer.lock | 150 +------------------------------------------------- 1 file changed, 1 insertion(+), 149 deletions(-) diff --git a/composer.lock b/composer.lock index 3cbe38b1..2c9357c7 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": "ca3a6aab5b25386e7757bbf32f2befce", + "content-hash": "42f558fa0f8ae1e1ed438d0842232bcf", "packages": [ { "name": "abraham/twitteroauth", @@ -6297,154 +6297,6 @@ ], "time": "2024-08-19T11:52:18+00:00" }, - { - "name": "lorisleiva/laravel-actions", - "version": "v2.8.4", - "source": { - "type": "git", - "url": "https://github.com/lorisleiva/laravel-actions.git", - "reference": "5a168bfdd3b75dd6ff259019d4aeef784bbd5403" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lorisleiva/laravel-actions/zipball/5a168bfdd3b75dd6ff259019d4aeef784bbd5403", - "reference": "5a168bfdd3b75dd6ff259019d4aeef784bbd5403", - "shasum": "" - }, - "require": { - "illuminate/contracts": "^10.0|^11.0", - "lorisleiva/lody": "^0.5", - "php": "^8.1" - }, - "require-dev": { - "orchestra/testbench": "^8.0|^9.0", - "pestphp/pest": "^1.23|^2.34", - "phpunit/phpunit": "^9.6|^10.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Lorisleiva\\Actions\\ActionServiceProvider" - ], - "aliases": { - "Action": "Lorisleiva\\Actions\\Facades\\Actions" - } - } - }, - "autoload": { - "psr-4": { - "Lorisleiva\\Actions\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Loris Leiva", - "email": "loris.leiva@gmail.com", - "homepage": "https://lorisleiva.com", - "role": "Developer" - } - ], - "description": "Laravel components that take care of one specific task", - "homepage": "https://github.com/lorisleiva/laravel-actions", - "keywords": [ - "action", - "command", - "component", - "controller", - "job", - "laravel", - "listener", - "object" - ], - "support": { - "issues": "https://github.com/lorisleiva/laravel-actions/issues", - "source": "https://github.com/lorisleiva/laravel-actions/tree/v2.8.4" - }, - "funding": [ - { - "url": "https://github.com/sponsors/lorisleiva", - "type": "github" - } - ], - "time": "2024-09-10T09:57:29+00:00" - }, - { - "name": "lorisleiva/lody", - "version": "v0.5.0", - "source": { - "type": "git", - "url": "https://github.com/lorisleiva/lody.git", - "reference": "c2f51b070e99f3a240d66cf68ef1f232036917fe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lorisleiva/lody/zipball/c2f51b070e99f3a240d66cf68ef1f232036917fe", - "reference": "c2f51b070e99f3a240d66cf68ef1f232036917fe", - "shasum": "" - }, - "require": { - "illuminate/contracts": "^9.0|^10.0|^11.0", - "php": "^8.0" - }, - "require-dev": { - "orchestra/testbench": "^9.0", - "pestphp/pest": "^1.20|^2.34", - "phpunit/phpunit": "^9.5.10|^10.5" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Lorisleiva\\Lody\\LodyServiceProvider" - ], - "aliases": { - "Lody": "Lorisleiva\\Lody\\Lody" - } - } - }, - "autoload": { - "psr-4": { - "Lorisleiva\\Lody\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Loris Leiva", - "email": "loris.leiva@gmail.com", - "homepage": "https://lorisleiva.com", - "role": "Developer" - } - ], - "description": "Load files and classes as lazy collections in Laravel.", - "homepage": "https://github.com/lorisleiva/lody", - "keywords": [ - "classes", - "collection", - "files", - "laravel", - "load" - ], - "support": { - "issues": "https://github.com/lorisleiva/lody/issues", - "source": "https://github.com/lorisleiva/lody/tree/v0.5.0" - }, - "funding": [ - { - "url": "https://github.com/sponsors/lorisleiva", - "type": "github" - } - ], - "time": "2024-03-13T12:08:59+00:00" - }, { "name": "maennchen/zipstream-php", "version": "3.1.1", From f8cdb8796a487bdc60b2990e8a268b33134181b4 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Wed, 16 Oct 2024 10:34:35 +0200 Subject: [PATCH 4/5] feat: update create and like reply test --- app/Actions/Replies/CreateReply.php | 3 --- app/Actions/Replies/LikeReply.php | 6 ++---- app/Livewire/Discussions/AddComment.php | 3 ++- app/Livewire/Discussions/Comment.php | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/Actions/Replies/CreateReply.php b/app/Actions/Replies/CreateReply.php index ef445a71..76a0e44d 100644 --- a/app/Actions/Replies/CreateReply.php +++ b/app/Actions/Replies/CreateReply.php @@ -9,12 +9,9 @@ use App\Models\Reply; use App\Models\User; use Illuminate\Database\Eloquent\Model; -use Lorisleiva\Actions\Concerns\AsAction; final class CreateReply { - use AsAction; - public function handle(string $body, User $user, Model $model): Reply { $reply = new Reply(['body' => $body]); diff --git a/app/Actions/Replies/LikeReply.php b/app/Actions/Replies/LikeReply.php index 9ed88c5f..212a76e8 100644 --- a/app/Actions/Replies/LikeReply.php +++ b/app/Actions/Replies/LikeReply.php @@ -7,15 +7,13 @@ use App\Models\Reaction; use App\Models\Reply; use App\Models\User; -use Lorisleiva\Actions\Concerns\AsAction; final class LikeReply { - use AsAction; - public function handle(User $user, Reply $reply, string $reaction = 'love'): void { - $react = Reaction::where('name', $reaction)->first(); + /** @var Reaction $react */ + $react = Reaction::query()->where('name', $reaction)->first(); $user->reactTo($reply, $react); } diff --git a/app/Livewire/Discussions/AddComment.php b/app/Livewire/Discussions/AddComment.php index 4c85a04e..8d2d7bab 100644 --- a/app/Livewire/Discussions/AddComment.php +++ b/app/Livewire/Discussions/AddComment.php @@ -8,6 +8,7 @@ use App\Models\Discussion; use Filament\Notifications\Notification; use Illuminate\Contracts\View\View; +use Illuminate\Support\Facades\Auth; use Livewire\Component; final class AddComment extends Component @@ -32,7 +33,7 @@ public function saveComment(): void ['body.required' => __('Votre commentaire ne peut pas ĂȘtre vide')] ); - $comment = CreateReply::run($this->body, auth()->user(), $this->discussion); + $comment = app(CreateReply::class)->handle($this->body, Auth::user(), $this->discussion); // @phpstan-ignore-line $this->dispatch('$refresh')->self(); diff --git a/app/Livewire/Discussions/Comment.php b/app/Livewire/Discussions/Comment.php index 598172fc..ac930793 100644 --- a/app/Livewire/Discussions/Comment.php +++ b/app/Livewire/Discussions/Comment.php @@ -40,7 +40,7 @@ public function toggleLike(): void return; } - LikeReply::run(auth()->user(), $this->comment); + app(LikeReply::class)->handle(auth()->user(), $this->comment); $this->dispatch('reloadComment')->self(); } From c4a37fec6341b507dcfd3c6dc63c606969cd2432 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Wed, 16 Oct 2024 10:42:07 +0200 Subject: [PATCH 5/5] fix: config for phpstan --- app/Livewire/Discussions/Comment.php | 2 +- phpstan.neon | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Discussions/Comment.php b/app/Livewire/Discussions/Comment.php index ac930793..1f1e0061 100644 --- a/app/Livewire/Discussions/Comment.php +++ b/app/Livewire/Discussions/Comment.php @@ -40,7 +40,7 @@ public function toggleLike(): void return; } - app(LikeReply::class)->handle(auth()->user(), $this->comment); + app(LikeReply::class)->handle(auth()->user(), $this->comment); // @phpstan-ignore-line $this->dispatch('reloadComment')->self(); } diff --git a/phpstan.neon b/phpstan.neon index aa392bf5..7d917216 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -15,5 +15,5 @@ parameters: - app/Markdown/MarkdownHelper.php ignoreErrors: - "#^Cannot access property \\$transaction on array\\|object\\.$#" - checkGenericClassInNonGenericObjectType: false - checkMissingIterableValueType: false + - identifier: missingType.iterableValue + - identifier: missingType.generics