diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index 6c533063..dc91af02 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -11,18 +11,10 @@ use Illuminate\Validation\Rule; use Laravel\Fortify\Contracts\CreatesNewUsers; -class CreateNewUser implements CreatesNewUsers +final class CreateNewUser implements CreatesNewUsers { use PasswordValidationRules; - /** - * Validate and create a newly registered user. - * - * @param array $input - * @return \App\Models\User - * - * @throws \Illuminate\Validation\ValidationException - */ public function create(array $input): User { Validator::make($input, [ diff --git a/app/Actions/Fortify/ResetUserPassword.php b/app/Actions/Fortify/ResetUserPassword.php index ccd8d040..45d145ae 100644 --- a/app/Actions/Fortify/ResetUserPassword.php +++ b/app/Actions/Fortify/ResetUserPassword.php @@ -4,24 +4,16 @@ namespace App\Actions\Fortify; +use App\Models\User; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\ResetsUserPasswords; -class ResetUserPassword implements ResetsUserPasswords +final class ResetUserPassword implements ResetsUserPasswords { use PasswordValidationRules; - /** - * Validate and reset the user's forgotten password. - * - * @param mixed $user - * @param array $input - * @return void - * - * @throws \Illuminate\Validation\ValidationException - */ - public function reset($user, array $input): void + public function reset(User $user, array $input): void { Validator::make($input, [ 'password' => $this->passwordRules(), diff --git a/app/Actions/Fortify/UpdateUserPassword.php b/app/Actions/Fortify/UpdateUserPassword.php index b5ce0a27..44569c4c 100644 --- a/app/Actions/Fortify/UpdateUserPassword.php +++ b/app/Actions/Fortify/UpdateUserPassword.php @@ -9,22 +9,17 @@ use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\UpdatesUserPasswords; -class UpdateUserPassword implements UpdatesUserPasswords +final class UpdateUserPassword implements UpdatesUserPasswords { use PasswordValidationRules; - /** - * - * @param User $user - * @param string[] $input - */ public function update(User $user, array $input): void { Validator::make($input, [ 'current_password' => ['required', 'string'], 'password' => $this->passwordRules(), - ])->after(function ($validator) use ($user, $input) { - if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) { + ])->after(function ($validator) use ($user, $input): void { + if ( ! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) { $validator->errors()->add('current_password', __('Le mot de passe fourni ne correspond pas à votre mot de passe actuel.')); } })->validateWithBag('updatePassword'); diff --git a/app/Actions/Fortify/UpdateUserProfileInformation.php b/app/Actions/Fortify/UpdateUserProfileInformation.php index eaa5361d..bb88729c 100644 --- a/app/Actions/Fortify/UpdateUserProfileInformation.php +++ b/app/Actions/Fortify/UpdateUserProfileInformation.php @@ -9,12 +9,8 @@ use Illuminate\Validation\Rule; use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; -class UpdateUserProfileInformation implements UpdatesUserProfileInformation +final class UpdateUserProfileInformation implements UpdatesUserProfileInformation { - /** - * @param User $user - * @param string[] $input - */ public function update(User $user, array $input): void { Validator::make($input, [ @@ -39,11 +35,7 @@ public function update(User $user, array $input): void } } - /** - * @param mixed $user - * @param string[] $input - */ - protected function updateVerifiedUser(User $user, array $input): void + private function updateVerifiedUser(User $user, array $input): void { $user->forceFill([ 'name' => $input['name'], diff --git a/app/Console/Commands/AssignUserRole.php b/app/Console/Commands/AssignUserRole.php index ffe2f681..045333af 100644 --- a/app/Console/Commands/AssignUserRole.php +++ b/app/Console/Commands/AssignUserRole.php @@ -7,7 +7,7 @@ use App\Models\User; use Illuminate\Console\Command; -class AssignUserRole extends Command +final class AssignUserRole extends Command { protected $signature = 'lcm:assign-user-role'; diff --git a/app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php b/app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php index 96a371b8..19746dfb 100644 --- a/app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php +++ b/app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php @@ -8,7 +8,7 @@ use App\Notifications\SendEMailToDeletedUser; use Illuminate\Console\Command; -class DeleteOldUnverifiedUsers extends Command +final class DeleteOldUnverifiedUsers extends Command { protected $signature = 'lcm:delete-old-unverified-users'; diff --git a/app/Console/Commands/CreateAdminUser.php b/app/Console/Commands/CreateAdminUser.php index 540eb900..163e2755 100644 --- a/app/Console/Commands/CreateAdminUser.php +++ b/app/Console/Commands/CreateAdminUser.php @@ -8,8 +8,9 @@ use Illuminate\Console\Command; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\Hash; +use Exception; -class CreateAdminUser extends Command +final class CreateAdminUser extends Command { protected $signature = 'lcm:admin'; @@ -50,7 +51,7 @@ protected function createUser(): void $user = User::query()->create($userData); $user->assignRole('admin'); - } catch (\Exception|QueryException $e) { + } catch (Exception|QueryException $e) { $this->error($e->getMessage()); } } diff --git a/app/Console/Commands/GenerateSitemap.php b/app/Console/Commands/GenerateSitemap.php index ebeb9b37..79bff9c9 100644 --- a/app/Console/Commands/GenerateSitemap.php +++ b/app/Console/Commands/GenerateSitemap.php @@ -10,7 +10,7 @@ use Spatie\Sitemap\SitemapGenerator; use Spatie\Sitemap\Tags\Url; -class GenerateSitemap extends Command +final class GenerateSitemap extends Command { protected $signature = 'sitemap:generate'; @@ -28,9 +28,7 @@ class GenerateSitemap extends Command public function handle(): void { SitemapGenerator::create(config('app.url')) - ->shouldCrawl(function (UriInterface $url) { - return $this->shouldIndex($url->getPath()); - }) + ->shouldCrawl(fn (UriInterface $url) => $this->shouldIndex($url->getPath())) ->hasCrawled(function (Url $url) { if ($this->shouldNotIndex($url->path())) { return; diff --git a/app/Console/Commands/PostArticleToTelegram.php b/app/Console/Commands/PostArticleToTelegram.php index 26a099a0..ed490999 100644 --- a/app/Console/Commands/PostArticleToTelegram.php +++ b/app/Console/Commands/PostArticleToTelegram.php @@ -9,7 +9,7 @@ use Illuminate\Console\Command; use Illuminate\Notifications\AnonymousNotifiable; -class PostArticleToTelegram extends Command +final class PostArticleToTelegram extends Command { protected $signature = 'lcm:post-article-to-telegram'; diff --git a/app/Console/Commands/PostArticleToTwitter.php b/app/Console/Commands/PostArticleToTwitter.php index 6261e00c..32110fee 100644 --- a/app/Console/Commands/PostArticleToTwitter.php +++ b/app/Console/Commands/PostArticleToTwitter.php @@ -9,7 +9,7 @@ use Illuminate\Console\Command; use Illuminate\Notifications\AnonymousNotifiable; -class PostArticleToTwitter extends Command +final class PostArticleToTwitter extends Command { protected $signature = 'lcm:post-article-to-twitter'; diff --git a/app/Console/Commands/PublishArticles.php b/app/Console/Commands/PublishArticles.php index aca7cc33..e1d190fe 100644 --- a/app/Console/Commands/PublishArticles.php +++ b/app/Console/Commands/PublishArticles.php @@ -7,7 +7,7 @@ use App\Models\Article; use Illuminate\Console\Command; -class PublishArticles extends Command +final class PublishArticles extends Command { protected $signature = 'lcm:publish-articles'; diff --git a/app/Console/Commands/SendUnVerifiedMails.php b/app/Console/Commands/SendUnVerifiedMails.php index c34e1721..35e1151f 100644 --- a/app/Console/Commands/SendUnVerifiedMails.php +++ b/app/Console/Commands/SendUnVerifiedMails.php @@ -9,7 +9,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\Mail; -class SendUnVerifiedMails extends Command +final class SendUnVerifiedMails extends Command { protected $signature = 'lcm:send-unverified-mails'; diff --git a/app/Console/Commands/SendWelcomeMailToUsers.php b/app/Console/Commands/SendWelcomeMailToUsers.php index f6f4095b..65868982 100644 --- a/app/Console/Commands/SendWelcomeMailToUsers.php +++ b/app/Console/Commands/SendWelcomeMailToUsers.php @@ -9,7 +9,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\Mail; -class SendWelcomeMailToUsers extends Command +final class SendWelcomeMailToUsers extends Command { protected $signature = 'lcm:send-welcome-mails'; diff --git a/app/Console/Commands/UpdateUserBestRepliesPoints.php b/app/Console/Commands/UpdateUserBestRepliesPoints.php index e3e3994b..7fc30bf3 100644 --- a/app/Console/Commands/UpdateUserBestRepliesPoints.php +++ b/app/Console/Commands/UpdateUserBestRepliesPoints.php @@ -8,7 +8,7 @@ use App\Models\Thread; use Illuminate\Console\Command; -class UpdateUserBestRepliesPoints extends Command +final class UpdateUserBestRepliesPoints extends Command { protected $signature = 'lcm:update-users-bests-replies-points'; diff --git a/app/Console/Commands/UpdateUserDiscussionsPoints.php b/app/Console/Commands/UpdateUserDiscussionsPoints.php index 26772b26..b86f9f14 100644 --- a/app/Console/Commands/UpdateUserDiscussionsPoints.php +++ b/app/Console/Commands/UpdateUserDiscussionsPoints.php @@ -8,7 +8,7 @@ use App\Models\Discussion; use Illuminate\Console\Command; -class UpdateUserDiscussionsPoints extends Command +final class UpdateUserDiscussionsPoints extends Command { protected $signature = 'lcm:update-users-discussions-points'; diff --git a/app/Console/Commands/UpdateUserPostsPoints.php b/app/Console/Commands/UpdateUserPostsPoints.php index f370cad7..3bd8440d 100644 --- a/app/Console/Commands/UpdateUserPostsPoints.php +++ b/app/Console/Commands/UpdateUserPostsPoints.php @@ -8,7 +8,7 @@ use App\Models\Article; use Illuminate\Console\Command; -class UpdateUserPostsPoints extends Command +final class UpdateUserPostsPoints extends Command { protected $signature = 'lcm:update-users-posts-points'; diff --git a/app/Console/Commands/UpdateUserRepliesPoints.php b/app/Console/Commands/UpdateUserRepliesPoints.php index 32aa56de..9bee3d8a 100644 --- a/app/Console/Commands/UpdateUserRepliesPoints.php +++ b/app/Console/Commands/UpdateUserRepliesPoints.php @@ -8,7 +8,7 @@ use App\Models\Reply; use Illuminate\Console\Command; -class UpdateUserRepliesPoints extends Command +final class UpdateUserRepliesPoints extends Command { protected $signature = 'lcm:update-users-replies-points'; diff --git a/app/Console/Commands/UpdateUserThreadsPoints.php b/app/Console/Commands/UpdateUserThreadsPoints.php index 310fc887..a7daca01 100644 --- a/app/Console/Commands/UpdateUserThreadsPoints.php +++ b/app/Console/Commands/UpdateUserThreadsPoints.php @@ -8,7 +8,7 @@ use App\Models\Thread; use Illuminate\Console\Command; -class UpdateUserThreadsPoints extends Command +final class UpdateUserThreadsPoints extends Command { protected $signature = 'lcm:update-users-threads-points'; diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index bc41ff3b..ad9992d9 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -4,18 +4,14 @@ namespace App\Console; +use App\Console\Commands\Cleanup\DeleteOldUnverifiedUsers; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; -class Kernel extends ConsoleKernel +final class Kernel extends ConsoleKernel { - /** - * The Artisan commands provided by your application. - * - * @var string[] - */ protected $commands = [ - \App\Console\Commands\Cleanup\DeleteOldUnverifiedUsers::class, + DeleteOldUnverifiedUsers::class, ]; protected function schedule(Schedule $schedule): void diff --git a/app/Contracts/ReactableInterface.php b/app/Contracts/ReactableInterface.php index 275504c5..0778828a 100644 --- a/app/Contracts/ReactableInterface.php +++ b/app/Contracts/ReactableInterface.php @@ -9,9 +9,6 @@ interface ReactableInterface { - /** - * Returns an Eloquent collection of reactions to the current item. - */ public function reactions(): MorphToMany; /** diff --git a/app/Enums/EnterpriseSize.php b/app/Enums/EnterpriseSize.php index 18170472..0880d1f3 100644 --- a/app/Enums/EnterpriseSize.php +++ b/app/Enums/EnterpriseSize.php @@ -4,21 +4,19 @@ namespace App\Enums; -use BenSampo\Enum\Enum; - -final class EnterpriseSize extends Enum +enum EnterpriseSize: string { - public const SEED = '1-10'; + case SEED = '1-10'; - public const SMALL = '11-50'; + case SMALL = '11-50'; - public const MEDIUM = '51-200'; + case MEDIUM = '51-200'; - public const LARGE = '201-500'; + case LARGE = '201-500'; - public const VERY_LARGE = '501-1000'; + case VERY_LARGE = '501-1000'; - public const ENTERPRISE = '1001-5000'; + case ENTERPRISE = '1001-5000'; - public const LARGE_ENTERPRISE = '5000+'; + case LARGE_ENTERPRISE = '5000+'; } diff --git a/app/Enums/PaymentType.php b/app/Enums/PaymentType.php index f159f8b9..00d2a4ff 100644 --- a/app/Enums/PaymentType.php +++ b/app/Enums/PaymentType.php @@ -7,5 +7,6 @@ enum PaymentType: string { case SUBSCRIPTION = 'subscription'; + case SPONSORING = 'sponsoring'; } diff --git a/app/Enums/PlanType.php b/app/Enums/PlanType.php index 9637a15f..cda4806e 100644 --- a/app/Enums/PlanType.php +++ b/app/Enums/PlanType.php @@ -7,5 +7,6 @@ enum PlanType: string { case DEVELOPER = 'developer'; + case ENTERPRISE = 'enterprise'; } diff --git a/app/Enums/TransactionStatus.php b/app/Enums/TransactionStatus.php index 8dab741e..d129b580 100644 --- a/app/Enums/TransactionStatus.php +++ b/app/Enums/TransactionStatus.php @@ -7,7 +7,10 @@ enum TransactionStatus: string { case PENDING = 'pending'; + case COMPLETE = 'complete'; + case CANCELED = 'canceled'; + case Failed = 'failed'; } diff --git a/app/Enums/TransactionType.php b/app/Enums/TransactionType.php index 9dd99d20..097ad4bc 100644 --- a/app/Enums/TransactionType.php +++ b/app/Enums/TransactionType.php @@ -7,5 +7,6 @@ enum TransactionType: string { case ONETIME = 'one-time'; + case RECURSIVE = 'recursive'; } diff --git a/app/Events/ApiRegistered.php b/app/Events/ApiRegistered.php index d1d1467d..a6feb1d7 100644 --- a/app/Events/ApiRegistered.php +++ b/app/Events/ApiRegistered.php @@ -7,7 +7,7 @@ use App\Models\User; use Illuminate\Queue\SerializesModels; -class ApiRegistered +final class ApiRegistered { use SerializesModels; diff --git a/app/Events/ArticleWasSubmittedForApproval.php b/app/Events/ArticleWasSubmittedForApproval.php index fa6a3e18..af63cafe 100644 --- a/app/Events/ArticleWasSubmittedForApproval.php +++ b/app/Events/ArticleWasSubmittedForApproval.php @@ -7,7 +7,7 @@ use App\Models\Article; use Illuminate\Queue\SerializesModels; -class ArticleWasSubmittedForApproval +final class ArticleWasSubmittedForApproval { use SerializesModels; diff --git a/app/Events/EmailAddressWasChanged.php b/app/Events/EmailAddressWasChanged.php index cd1f4e5f..8ddd66fc 100644 --- a/app/Events/EmailAddressWasChanged.php +++ b/app/Events/EmailAddressWasChanged.php @@ -8,7 +8,7 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; -class EmailAddressWasChanged +final class EmailAddressWasChanged { use Dispatchable; use SerializesModels; diff --git a/app/Events/ReplyWasCreated.php b/app/Events/ReplyWasCreated.php index b0c05ed2..5d9b03c1 100644 --- a/app/Events/ReplyWasCreated.php +++ b/app/Events/ReplyWasCreated.php @@ -7,7 +7,7 @@ use App\Models\Reply; use Illuminate\Queue\SerializesModels; -class ReplyWasCreated +final class ReplyWasCreated { use SerializesModels; diff --git a/app/Events/SponsoringPaymentInitialize.php b/app/Events/SponsoringPaymentInitialize.php index de99fede..1529423f 100644 --- a/app/Events/SponsoringPaymentInitialize.php +++ b/app/Events/SponsoringPaymentInitialize.php @@ -7,7 +7,7 @@ use App\Models\Transaction; use Illuminate\Queue\SerializesModels; -class SponsoringPaymentInitialize +final class SponsoringPaymentInitialize { use SerializesModels; diff --git a/app/Events/ThreadWasCreated.php b/app/Events/ThreadWasCreated.php index 927f64ea..5f746628 100644 --- a/app/Events/ThreadWasCreated.php +++ b/app/Events/ThreadWasCreated.php @@ -7,7 +7,7 @@ use App\Models\Thread; use Illuminate\Queue\SerializesModels; -class ThreadWasCreated +final class ThreadWasCreated { use SerializesModels; diff --git a/app/Exceptions/CannotCreateUser.php b/app/Exceptions/CannotCreateUser.php index 4a1b6983..888a7f94 100644 --- a/app/Exceptions/CannotCreateUser.php +++ b/app/Exceptions/CannotCreateUser.php @@ -10,11 +10,11 @@ final class CannotCreateUser extends Exception { public static function duplicateEmailAddress(string $emailAddress): self { - return new static("Cet adresse e-mail [$emailAddress] existe déjà."); + return new static("Cet adresse e-mail [{$emailAddress}] existe déjà."); } public static function duplicateUsername(string $username): self { - return new static("Ce pseudo [$username] existe déjà."); + return new static("Ce pseudo [{$username}] existe déjà."); } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 4bc790a9..658a1dd5 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -7,36 +7,19 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; -class Handler extends ExceptionHandler +final class Handler extends ExceptionHandler { - /** - * A list of the exception types that are not reported. - * - * @var array> - */ - protected $dontReport = [ - // - ]; + protected $dontReport = []; - /** - * A list of the inputs that are never flashed for validation exceptions. - * - * @var array - */ protected $dontFlash = [ 'current_password', 'password', 'password_confirmation', ]; - /** - * Register the exception handling callbacks for the application. - * - * @return void - */ public function register(): void { - $this->reportable(function (Throwable $e) { + $this->reportable(function (Throwable $e): void { if ($this->shouldReport($e) && app()->bound('sentry')) { app('sentry')->captureException($e); } diff --git a/app/Filters/AbstractFilter.php b/app/Filters/AbstractFilter.php index 65be742c..c74dd386 100644 --- a/app/Filters/AbstractFilter.php +++ b/app/Filters/AbstractFilter.php @@ -11,9 +11,6 @@ abstract class AbstractFilter { abstract public function filter(Builder $builder, string $value): Builder; - /** - * @return string[] - */ public function mappings(): array { return []; diff --git a/app/Filters/AbstractFilters.php b/app/Filters/AbstractFilters.php index 98ee163b..bbb1a767 100644 --- a/app/Filters/AbstractFilters.php +++ b/app/Filters/AbstractFilters.php @@ -11,9 +11,6 @@ abstract class AbstractFilters { protected Builder $builder; - /** - * @var string[] - */ protected array $filters = []; public function __construct(public Request $request) @@ -29,12 +26,6 @@ public function filter(Builder $builder): Builder return $builder; } - /** - * Add Filters to current filter class. - * - * @param string[] $filters - * @return $this - */ public function add(array $filters): self { $this->filters = array_merge($this->filters, $filters); @@ -47,11 +38,6 @@ public function resolverFilter(string $filter): mixed return new $this->filters[$filter](); } - /** - * Fetch all relevant filters from the request. - * - * @return string[] - */ public function getFilters(): array { return array_filter($this->request->only(array_keys($this->filters))); diff --git a/app/Filters/Enterprise/EnterpriseFilters.php b/app/Filters/Enterprise/EnterpriseFilters.php index 5274baca..a8af47cb 100644 --- a/app/Filters/Enterprise/EnterpriseFilters.php +++ b/app/Filters/Enterprise/EnterpriseFilters.php @@ -8,10 +8,5 @@ final class EnterpriseFilters extends AbstractFilters { - /** - * Registered filters to operate upon. - * - * @var string[] - */ protected array $filters = []; } diff --git a/app/Filters/Thread/SortByFilter.php b/app/Filters/Thread/SortByFilter.php index ea29e1dc..18914b6a 100644 --- a/app/Filters/Thread/SortByFilter.php +++ b/app/Filters/Thread/SortByFilter.php @@ -8,11 +8,8 @@ use App\Models\Thread; use Illuminate\Database\Eloquent\Builder; -class SortByFilter extends AbstractFilter +final class SortByFilter extends AbstractFilter { - /** - * @return string[] - */ public function mappings(): array { return [ diff --git a/app/Filters/Thread/ThreadFilters.php b/app/Filters/Thread/ThreadFilters.php index 6212a797..e7137fb6 100644 --- a/app/Filters/Thread/ThreadFilters.php +++ b/app/Filters/Thread/ThreadFilters.php @@ -6,13 +6,8 @@ use App\Filters\AbstractFilters; -class ThreadFilters extends AbstractFilters +final class ThreadFilters extends AbstractFilters { - /** - * Registered filters to operate upon. - * - * @var string[] - */ protected array $filters = [ 'sortBy' => SortByFilter::class, ]; diff --git a/app/Gamify/Points/AddPhone.php b/app/Gamify/Points/AddPhone.php index e77ca708..b527ed77 100644 --- a/app/Gamify/Points/AddPhone.php +++ b/app/Gamify/Points/AddPhone.php @@ -7,7 +7,7 @@ use App\Models\User; use QCod\Gamify\PointType; -class AddPhone extends PointType +final class AddPhone extends PointType { public int $points = 10; diff --git a/app/Gamify/Points/AddSocialLinks.php b/app/Gamify/Points/AddSocialLinks.php index f209c971..e789fc28 100644 --- a/app/Gamify/Points/AddSocialLinks.php +++ b/app/Gamify/Points/AddSocialLinks.php @@ -7,7 +7,7 @@ use App\Models\User; use QCod\Gamify\PointType; -class AddSocialLinks extends PointType +final class AddSocialLinks extends PointType { public int $points = 15; diff --git a/app/Gamify/Points/BestReply.php b/app/Gamify/Points/BestReply.php index eed89dee..e7b41703 100644 --- a/app/Gamify/Points/BestReply.php +++ b/app/Gamify/Points/BestReply.php @@ -6,7 +6,7 @@ use QCod\Gamify\PointType; -class BestReply extends PointType +final class BestReply extends PointType { public int $points = 20; diff --git a/app/Gamify/Points/DiscussionCreated.php b/app/Gamify/Points/DiscussionCreated.php index 021c26fd..04083e9c 100644 --- a/app/Gamify/Points/DiscussionCreated.php +++ b/app/Gamify/Points/DiscussionCreated.php @@ -8,7 +8,7 @@ use App\Models\User; use QCod\Gamify\PointType; -class DiscussionCreated extends PointType +final class DiscussionCreated extends PointType { public int $points = 20; diff --git a/app/Gamify/Points/PostCreated.php b/app/Gamify/Points/PostCreated.php index 70f5332e..950a7180 100644 --- a/app/Gamify/Points/PostCreated.php +++ b/app/Gamify/Points/PostCreated.php @@ -8,7 +8,7 @@ use App\Models\User; use QCod\Gamify\PointType; -class PostCreated extends PointType +final class PostCreated extends PointType { public int $points = 50; diff --git a/app/Gamify/Points/ReplyCreated.php b/app/Gamify/Points/ReplyCreated.php index ea97b97f..4da306f7 100644 --- a/app/Gamify/Points/ReplyCreated.php +++ b/app/Gamify/Points/ReplyCreated.php @@ -7,7 +7,7 @@ use App\Models\User; use QCod\Gamify\PointType; -class ReplyCreated extends PointType +final class ReplyCreated extends PointType { public int $points = 10; diff --git a/app/Gamify/Points/ThreadCreated.php b/app/Gamify/Points/ThreadCreated.php index efd82b45..9cbf930b 100644 --- a/app/Gamify/Points/ThreadCreated.php +++ b/app/Gamify/Points/ThreadCreated.php @@ -8,7 +8,7 @@ use App\Models\User; use QCod\Gamify\PointType; -class ThreadCreated extends PointType +final class ThreadCreated extends PointType { public int $points = 55; diff --git a/app/Http/Controllers/Api/Auth/ForgotPasswordController.php b/app/Http/Controllers/Api/Auth/ForgotPasswordController.php index b81ef14c..91a874e3 100644 --- a/app/Http/Controllers/Api/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Api/Auth/ForgotPasswordController.php @@ -9,7 +9,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Password; -class ForgotPasswordController extends Controller +final class ForgotPasswordController extends Controller { public function __invoke(ForgotPasswordRequest $request): JsonResponse { @@ -17,7 +17,7 @@ public function __invoke(ForgotPasswordRequest $request): JsonResponse $request->only('email') ); - return $status === Password::RESET_LINK_SENT + return Password::RESET_LINK_SENT === $status ? response()->json(['message' => __('L\'e-mail de réinitialisation du mot de passe a été envoyé avec succès !')]) : response()->json(['error' => __('Un courriel ne pourrait être envoyé à cette adresse électronique !')], 401); } diff --git a/app/Http/Controllers/Api/Auth/LoginController.php b/app/Http/Controllers/Api/Auth/LoginController.php index 3d666d72..5bb52ce8 100644 --- a/app/Http/Controllers/Api/Auth/LoginController.php +++ b/app/Http/Controllers/Api/Auth/LoginController.php @@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Validation\ValidationException; -class LoginController extends Controller +final class LoginController extends Controller { use UserResponse; @@ -23,21 +23,21 @@ public function login(LoginRequest $request): JsonResponse /** @var User $user */ $user = User::query() ->with(['roles', 'permissions']) - ->where('email', strtolower($request->input('email'))) + ->where('email', mb_strtolower($request->input('email'))) ->first(); $sanitized = [ - 'email' => strtolower($request->input('email')), + 'email' => mb_strtolower($request->input('email')), 'password' => $request->input('password'), ]; - if (!$user || ! Auth::attempt($sanitized)) { + if ( ! $user || ! Auth::attempt($sanitized)) { throw ValidationException::withMessages([ 'email' => __('Les informations d\'identification fournies sont incorrectes.'), ]); } - if (! $user->tokens()) { + if ( ! $user->tokens()) { $user->tokens()->delete(); } diff --git a/app/Http/Controllers/Api/Auth/RegisterController.php b/app/Http/Controllers/Api/Auth/RegisterController.php index 7d48c856..a3139d74 100644 --- a/app/Http/Controllers/Api/Auth/RegisterController.php +++ b/app/Http/Controllers/Api/Auth/RegisterController.php @@ -15,7 +15,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Hash; -class RegisterController extends Controller +final class RegisterController extends Controller { use UserResponse; @@ -25,7 +25,7 @@ public function register(RegisterRequest $request): JsonResponse $user = User::query()->create([ 'name' => $request->input('name'), 'username' => $request->input('name'), - 'email' => strtolower($request->input('email')), + 'email' => mb_strtolower($request->input('email')), 'password' => Hash::make($request->input('password')), ]); @@ -48,14 +48,14 @@ public function googleAuthenticator(Request $request): JsonResponse $user = User::query()->where('email', $socialUser['email'])->first(); - if (! $user) { + if ( ! $user) { /** @var User $user */ $user = User::query()->create([ 'name' => $socialUser['name'], 'email' => $socialUser['email'], 'username' => $socialUser['id'], 'email_verified_at' => now(), - 'avatar_type' => strtolower($socialUser['provider']), + 'avatar_type' => mb_strtolower($socialUser['provider']), ]); $user->assignRole('company'); @@ -67,9 +67,9 @@ public function googleAuthenticator(Request $request): JsonResponse ], 401); } - if (! $user->hasProvider($socialUser['provider'])) { + if ( ! $user->hasProvider($socialUser['provider'])) { $user->providers()->save(new SocialAccount([ - 'provider' => strtolower($socialUser['provider']), + 'provider' => mb_strtolower($socialUser['provider']), 'provider_id' => $socialUser['id'], 'token' => $socialUser['idToken'], 'avatar' => $socialUser['photoUrl'], diff --git a/app/Http/Controllers/Api/Auth/ResetPasswordController.php b/app/Http/Controllers/Api/Auth/ResetPasswordController.php index 3677e39e..fc43fdc1 100644 --- a/app/Http/Controllers/Api/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Api/Auth/ResetPasswordController.php @@ -6,19 +6,20 @@ use App\Http\Controllers\Controller; use App\Http\Requests\Api\ResetPasswordRequest; +use App\Models\User; use Illuminate\Auth\Events\PasswordReset; use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Password; use Illuminate\Support\Str; -class ResetPasswordController extends Controller +final class ResetPasswordController extends Controller { public function __invoke(ResetPasswordRequest $request): JsonResponse { $status = Password::reset( $request->only('email', 'password', 'password_confirmation', 'token'), - function ($user) use ($request) { + function (User $user) use ($request): void { $user->forceFill([ 'password' => Hash::make($request->password), 'remember_token' => Str::random(60), @@ -28,7 +29,7 @@ function ($user) use ($request) { } ); - return $status === Password::PASSWORD_RESET + return Password::PASSWORD_RESET === $status ? response()->json(['message' => __('Votre mot de passe a été réinitialisé avec succès !')]) : response()->json(['error' => __('Le jeton de réinitialisation du mot de passe est invalide !')], 401); } diff --git a/app/Http/Controllers/Api/Auth/VerifyEmailController.php b/app/Http/Controllers/Api/Auth/VerifyEmailController.php index 5d1b876a..60100a53 100644 --- a/app/Http/Controllers/Api/Auth/VerifyEmailController.php +++ b/app/Http/Controllers/Api/Auth/VerifyEmailController.php @@ -11,7 +11,7 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -class VerifyEmailController extends Controller +final class VerifyEmailController extends Controller { public function verify(Request $request): RedirectResponse { diff --git a/app/Http/Controllers/Api/Enterprise/PublicController.php b/app/Http/Controllers/Api/Enterprise/PublicController.php index e3c906a3..57e76bab 100644 --- a/app/Http/Controllers/Api/Enterprise/PublicController.php +++ b/app/Http/Controllers/Api/Enterprise/PublicController.php @@ -11,7 +11,7 @@ use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\AnonymousResourceCollection; -class PublicController extends Controller +final class PublicController extends Controller { public function featured(): AnonymousResourceCollection { diff --git a/app/Http/Controllers/Api/Enterprise/RegisterController.php b/app/Http/Controllers/Api/Enterprise/RegisterController.php index 7f76636d..02eac8a0 100644 --- a/app/Http/Controllers/Api/Enterprise/RegisterController.php +++ b/app/Http/Controllers/Api/Enterprise/RegisterController.php @@ -11,7 +11,7 @@ use App\Models\User; use Illuminate\Http\JsonResponse; -class RegisterController extends Controller +final class RegisterController extends Controller { public function __invoke(RegisterRequest $request): JsonResponse { diff --git a/app/Http/Controllers/Api/PremiumController.php b/app/Http/Controllers/Api/PremiumController.php index 14429e7b..d96bf358 100644 --- a/app/Http/Controllers/Api/PremiumController.php +++ b/app/Http/Controllers/Api/PremiumController.php @@ -10,20 +10,18 @@ use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Cache; -class PremiumController extends Controller +final class PremiumController extends Controller { public function users(): JsonResponse { - $users = Cache::remember('premium_users', now()->addMonth(), function () { - return User::select('name', 'username')->limit(48)->get(); - }); + $users = Cache::remember('premium_users', now()->addMonth(), fn () => User::select('name', 'username')->limit(48)->get()); $premium = collect(); foreach ($users->chunk(16) as $key => $usersRow) { $usersArray[$key] = []; foreach ($usersRow as $user) { - array_push($usersArray[$key], new PremiumUserResource($user)); + $usersArray[$key][] = new PremiumUserResource($user); } $premium->push($usersArray[$key]); } diff --git a/app/Http/Controllers/Api/User/ProfileController.php b/app/Http/Controllers/Api/User/ProfileController.php index fccddcf4..56f16df4 100644 --- a/app/Http/Controllers/Api/User/ProfileController.php +++ b/app/Http/Controllers/Api/User/ProfileController.php @@ -9,7 +9,7 @@ use App\Models\User; use Illuminate\Http\JsonResponse; -class ProfileController extends Controller +final class ProfileController extends Controller { public function me(): JsonResponse { diff --git a/app/Http/Controllers/ArticlesController.php b/app/Http/Controllers/ArticlesController.php index caad5bc5..7b2c0dc5 100644 --- a/app/Http/Controllers/ArticlesController.php +++ b/app/Http/Controllers/ArticlesController.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Cache; -class ArticlesController extends Controller +final class ArticlesController extends Controller { public function __construct() { diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index f3d25c0a..533f7afd 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -9,7 +9,7 @@ use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; -class Controller extends BaseController +abstract class Controller extends BaseController { use AuthorizesRequests; use DispatchesJobs; diff --git a/app/Http/Controllers/Cpanel/AnalyticsController.php b/app/Http/Controllers/Cpanel/AnalyticsController.php index 607fa1cd..7a929851 100644 --- a/app/Http/Controllers/Cpanel/AnalyticsController.php +++ b/app/Http/Controllers/Cpanel/AnalyticsController.php @@ -7,7 +7,7 @@ use App\Http\Controllers\Controller; use Illuminate\Contracts\View\View; -class AnalyticsController extends Controller +final class AnalyticsController extends Controller { public function __invoke(): View { diff --git a/app/Http/Controllers/Cpanel/DashboardController.php b/app/Http/Controllers/Cpanel/DashboardController.php index 5a3f8b55..7014c7f6 100644 --- a/app/Http/Controllers/Cpanel/DashboardController.php +++ b/app/Http/Controllers/Cpanel/DashboardController.php @@ -10,7 +10,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Cache; -class DashboardController extends Controller +final class DashboardController extends Controller { public function __invoke(): View { diff --git a/app/Http/Controllers/Cpanel/UserController.php b/app/Http/Controllers/Cpanel/UserController.php index 6748ea5c..1775a601 100644 --- a/app/Http/Controllers/Cpanel/UserController.php +++ b/app/Http/Controllers/Cpanel/UserController.php @@ -8,7 +8,7 @@ use App\Models\User; use Illuminate\Contracts\View\View; -class UserController extends Controller +final class UserController extends Controller { public function __invoke(): View { diff --git a/app/Http/Controllers/DiscussionController.php b/app/Http/Controllers/DiscussionController.php index 201c8da6..24adbd70 100644 --- a/app/Http/Controllers/DiscussionController.php +++ b/app/Http/Controllers/DiscussionController.php @@ -8,7 +8,7 @@ use App\Policies\DiscussionPolicy; use Illuminate\Contracts\View\View; -class DiscussionController extends Controller +final class DiscussionController extends Controller { public function __construct() { diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 109ac9ac..968dbef0 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -11,7 +11,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Cache; -class HomeController extends Controller +final class HomeController extends Controller { public function __invoke(): View { diff --git a/app/Http/Controllers/NotchPayCallBackController.php b/app/Http/Controllers/NotchPayCallBackController.php index 4b2375a7..4d35bdb3 100644 --- a/app/Http/Controllers/NotchPayCallBackController.php +++ b/app/Http/Controllers/NotchPayCallBackController.php @@ -14,7 +14,7 @@ use NotchPay\NotchPay; use NotchPay\Payment; -class NotchPayCallBackController extends Controller +final class NotchPayCallBackController extends Controller { public function __invoke(Request $request): RedirectResponse { diff --git a/app/Http/Controllers/OAuthController.php b/app/Http/Controllers/OAuthController.php index 46afff7c..47197179 100644 --- a/app/Http/Controllers/OAuthController.php +++ b/app/Http/Controllers/OAuthController.php @@ -13,13 +13,13 @@ use Laravel\Socialite\Two\InvalidStateException; use Laravel\Socialite\Contracts\User as SocialUser; -class OAuthController extends Controller +final class OAuthController extends Controller { use HasSocialite; public function redirectToProvider(string $provider): RedirectResponse | \Symfony\Component\HttpFoundation\RedirectResponse { - if (! in_array($provider, $this->getAcceptedProviders(), true)) { + if ( ! in_array($provider, $this->getAcceptedProviders(), true)) { return redirect() ->route('login') ->withErrors(__('La connexion via :provider n\'est pas disponible', ['provider' => e($provider)])); @@ -66,7 +66,7 @@ private function userNotFound(User $socialUser, string $errorMessage): RedirectR private function updateOrRegisterProvider(User $user, SocialUser $socialiteUser, string $provider): void { - if (! $user->hasProvider($provider)) { + if ( ! $user->hasProvider($provider)) { $user->providers()->save(new SocialAccount([ 'provider' => $provider, 'provider_id' => $socialiteUser->id, diff --git a/app/Http/Controllers/ReplyAbleController.php b/app/Http/Controllers/ReplyAbleController.php index c864684f..073d8572 100644 --- a/app/Http/Controllers/ReplyAbleController.php +++ b/app/Http/Controllers/ReplyAbleController.php @@ -7,7 +7,7 @@ use App\Models\Reply; use Illuminate\Http\RedirectResponse; -class ReplyAbleController extends Controller +final class ReplyAbleController extends Controller { public function redirect(int $id, string $type): RedirectResponse { diff --git a/app/Http/Controllers/SlackController.php b/app/Http/Controllers/SlackController.php index ab128018..0ec6fdf5 100644 --- a/app/Http/Controllers/SlackController.php +++ b/app/Http/Controllers/SlackController.php @@ -9,7 +9,7 @@ use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -class SlackController extends Controller +final class SlackController extends Controller { public function __invoke(Request $request): RedirectResponse { diff --git a/app/Http/Controllers/SponsoringController.php b/app/Http/Controllers/SponsoringController.php index 1dc16612..f2db091c 100644 --- a/app/Http/Controllers/SponsoringController.php +++ b/app/Http/Controllers/SponsoringController.php @@ -8,7 +8,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Cache; -class SponsoringController extends Controller +final class SponsoringController extends Controller { public function sponsors(): View { diff --git a/app/Http/Controllers/User/DashboardController.php b/app/Http/Controllers/User/DashboardController.php index b134a144..81313d79 100644 --- a/app/Http/Controllers/User/DashboardController.php +++ b/app/Http/Controllers/User/DashboardController.php @@ -9,7 +9,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Support\Facades\Auth; -class DashboardController extends Controller +final class DashboardController extends Controller { public function dashboard(): View { diff --git a/app/Http/Controllers/User/SettingController.php b/app/Http/Controllers/User/SettingController.php index 37d96d09..7c6b6c7d 100644 --- a/app/Http/Controllers/User/SettingController.php +++ b/app/Http/Controllers/User/SettingController.php @@ -18,7 +18,7 @@ use Jenssegers\Agent\Agent; use Stevebauman\Location\Facades\Location; -class SettingController extends Controller +final class SettingController extends Controller { public function profile(): View { @@ -34,7 +34,7 @@ public function update(UpdateProfileRequest $request): RedirectResponse $user->update([ 'name' => $request->name, 'email' => $request->email, - 'username' => strtolower($request->username), + 'username' => mb_strtolower($request->username), 'bio' => trim(strip_tags((string) $request->bio)), 'twitter_profile' => $request->twitter_profile, 'github_profile' => $request->github_profile, @@ -71,7 +71,7 @@ public function password(): View 'is_current_device' => $session->id === request()->session()->getId(), 'last_active' => Carbon::createFromTimestamp($session->last_activity)->diffForHumans(), 'location' => Location::get($session->ip_address), - ]); + ]); }), ]); } @@ -87,7 +87,7 @@ public function updatePassword(UpdatePasswordRequest $request): RedirectResponse protected function createAgent(mixed $session): mixed { - return tap(new Agent(), function ($agent) use ($session) { + return tap(new Agent(), function ($agent) use ($session): void { $agent->setUserAgent($session->user_agent); }); } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 710a176f..394a4eeb 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -6,15 +6,8 @@ use Illuminate\Foundation\Http\Kernel as HttpKernel; -class Kernel extends HttpKernel +final class Kernel extends HttpKernel { - /** - * The application's global HTTP middleware stack. - * - * These middleware are run during every request to your application. - * - * @var array - */ protected $middleware = [ // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, @@ -26,11 +19,6 @@ class Kernel extends HttpKernel \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, ]; - /** - * The application's route middleware groups. - * - * @var array> - */ protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, @@ -49,13 +37,6 @@ class Kernel extends HttpKernel ], ]; - /** - * The application's route middleware. - * - * These middleware may be assigned to groups or used individually. - * - * @var array - */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, diff --git a/app/Http/Livewire/Articles/Browse.php b/app/Http/Livewire/Articles/Browse.php index 59ed3ad2..5aec7d03 100644 --- a/app/Http/Livewire/Articles/Browse.php +++ b/app/Http/Livewire/Articles/Browse.php @@ -11,7 +11,7 @@ use Illuminate\Contracts\View\View; use Livewire\Component; -class Browse extends Component +final class Browse extends Component { use WithInfiniteScroll; use WithTags; @@ -56,7 +56,7 @@ public function render(): View ->orderByDesc('sponsored_at') ->orderByDesc('published_at'); - $tags = Tag::whereHas('articles', function ($query) { + $tags = Tag::whereHas('articles', function ($query): void { $query->published(); })->orderBy('name')->get(); diff --git a/app/Http/Livewire/Articles/Create.php b/app/Http/Livewire/Articles/Create.php index 6aa8c481..847a6514 100644 --- a/app/Http/Livewire/Articles/Create.php +++ b/app/Http/Livewire/Articles/Create.php @@ -18,11 +18,11 @@ use Livewire\Component; use Livewire\WithFileUploads; -class Create extends Component +final class Create extends Component { + use WithArticleAttributes; use WithFileUploads; use WithTagsAssociation; - use WithArticleAttributes; /** * @var string[] diff --git a/app/Http/Livewire/Articles/Edit.php b/app/Http/Livewire/Articles/Edit.php index 266cfcc7..a8b5ee71 100644 --- a/app/Http/Livewire/Articles/Edit.php +++ b/app/Http/Livewire/Articles/Edit.php @@ -15,11 +15,11 @@ use Livewire\Component; use Livewire\WithFileUploads; -class Edit extends Component +final class Edit extends Component { + use WithArticleAttributes; use WithFileUploads; use WithTagsAssociation; - use WithArticleAttributes; public Article $article; @@ -48,7 +48,7 @@ public function mount(Article $article): void public function submit(): void { - $this->alreadySubmitted = $this->article->submitted_at !== null; + $this->alreadySubmitted = null !== $this->article->submitted_at; $this->submitted_at = $this->article->submitted_at ?? now(); $this->store(); } diff --git a/app/Http/Livewire/Discussions/AddComment.php b/app/Http/Livewire/Discussions/AddComment.php index a1b23190..f0eb5b4d 100644 --- a/app/Http/Livewire/Discussions/AddComment.php +++ b/app/Http/Livewire/Discussions/AddComment.php @@ -10,7 +10,7 @@ use Illuminate\Contracts\View\View; use Livewire\Component; -class AddComment extends Component +final class AddComment extends Component { public ?Discussion $discussion; diff --git a/app/Http/Livewire/Discussions/Browse.php b/app/Http/Livewire/Discussions/Browse.php index 6a96527f..b6fc248d 100644 --- a/app/Http/Livewire/Discussions/Browse.php +++ b/app/Http/Livewire/Discussions/Browse.php @@ -11,7 +11,7 @@ use Illuminate\Contracts\View\View; use Livewire\Component; -class Browse extends Component +final class Browse extends Component { use WithInfiniteScroll; use WithTags; diff --git a/app/Http/Livewire/Discussions/Comment.php b/app/Http/Livewire/Discussions/Comment.php index c3f3d8f5..42acc57a 100644 --- a/app/Http/Livewire/Discussions/Comment.php +++ b/app/Http/Livewire/Discussions/Comment.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class Comment extends Component +final class Comment extends Component { public Reply $comment; @@ -35,7 +35,7 @@ public function delete(): void public function toggleLike(): void { - if (! Auth::check()) { + if ( ! Auth::check()) { Notification::make() ->title(__('Vous devez être connecté pour liker un commentaire.')) ->danger() diff --git a/app/Http/Livewire/Discussions/Comments.php b/app/Http/Livewire/Discussions/Comments.php index a552f65a..8213fe9d 100644 --- a/app/Http/Livewire/Discussions/Comments.php +++ b/app/Http/Livewire/Discussions/Comments.php @@ -10,7 +10,7 @@ use Illuminate\Support\Collection; use Livewire\Component; -class Comments extends Component +final class Comments extends Component { public Discussion $discussion; diff --git a/app/Http/Livewire/Discussions/Create.php b/app/Http/Livewire/Discussions/Create.php index 76b8586b..110971b0 100644 --- a/app/Http/Livewire/Discussions/Create.php +++ b/app/Http/Livewire/Discussions/Create.php @@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class Create extends Component +final class Create extends Component { use WithTagsAssociation; diff --git a/app/Http/Livewire/Discussions/Edit.php b/app/Http/Livewire/Discussions/Edit.php index a200ba0b..ad69d48e 100644 --- a/app/Http/Livewire/Discussions/Edit.php +++ b/app/Http/Livewire/Discussions/Edit.php @@ -10,7 +10,7 @@ use Illuminate\Contracts\View\View; use Livewire\Component; -class Edit extends Component +final class Edit extends Component { use WithTagsAssociation; diff --git a/app/Http/Livewire/Discussions/Subscribe.php b/app/Http/Livewire/Discussions/Subscribe.php index 819c79b0..7f232ab8 100644 --- a/app/Http/Livewire/Discussions/Subscribe.php +++ b/app/Http/Livewire/Discussions/Subscribe.php @@ -14,7 +14,7 @@ use Livewire\Component; use Ramsey\Uuid\Uuid; -class Subscribe extends Component +final class Subscribe extends Component { use AuthorizesRequests; diff --git a/app/Http/Livewire/Editor.php b/app/Http/Livewire/Editor.php index fc5370b7..e08264da 100644 --- a/app/Http/Livewire/Editor.php +++ b/app/Http/Livewire/Editor.php @@ -8,7 +8,7 @@ use Illuminate\Contracts\View\View; use Livewire\Component; -class Editor extends Component +final class Editor extends Component { public string $placeholder = 'laisser une réponse...'; diff --git a/app/Http/Livewire/Forum/CreateReply.php b/app/Http/Livewire/Forum/CreateReply.php index 8fe9de8b..c457c198 100644 --- a/app/Http/Livewire/Forum/CreateReply.php +++ b/app/Http/Livewire/Forum/CreateReply.php @@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class CreateReply extends Component +final class CreateReply extends Component { use AuthorizesRequests; diff --git a/app/Http/Livewire/Forum/CreateThread.php b/app/Http/Livewire/Forum/CreateThread.php index 9ef365c9..55837bc5 100644 --- a/app/Http/Livewire/Forum/CreateThread.php +++ b/app/Http/Livewire/Forum/CreateThread.php @@ -14,7 +14,7 @@ use Livewire\Component; use Ramsey\Uuid\Uuid; -class CreateThread extends Component +final class CreateThread extends Component { use WithChannelsAssociation; diff --git a/app/Http/Livewire/Forum/EditThread.php b/app/Http/Livewire/Forum/EditThread.php index e224228e..8760553c 100644 --- a/app/Http/Livewire/Forum/EditThread.php +++ b/app/Http/Livewire/Forum/EditThread.php @@ -10,7 +10,7 @@ use Illuminate\Contracts\View\View; use Livewire\Component; -class EditThread extends Component +final class EditThread extends Component { use WithChannelsAssociation; diff --git a/app/Http/Livewire/Forum/Reply.php b/app/Http/Livewire/Forum/Reply.php index d2f5e668..1b9d78ec 100644 --- a/app/Http/Livewire/Forum/Reply.php +++ b/app/Http/Livewire/Forum/Reply.php @@ -15,7 +15,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class Reply extends Component +final class Reply extends Component { use AuthorizesRequests; diff --git a/app/Http/Livewire/Forum/Subscribe.php b/app/Http/Livewire/Forum/Subscribe.php index d8c99498..2497b441 100644 --- a/app/Http/Livewire/Forum/Subscribe.php +++ b/app/Http/Livewire/Forum/Subscribe.php @@ -14,7 +14,7 @@ use Livewire\Component; use Ramsey\Uuid\Uuid; -class Subscribe extends Component +final class Subscribe extends Component { use AuthorizesRequests; diff --git a/app/Http/Livewire/MarkdownX.php b/app/Http/Livewire/MarkdownX.php index 92607f3d..b34ea360 100644 --- a/app/Http/Livewire/MarkdownX.php +++ b/app/Http/Livewire/MarkdownX.php @@ -14,7 +14,7 @@ use Illuminate\Support\Str; use Livewire\Component; -class MarkdownX extends Component +final class MarkdownX extends Component { public string $content; @@ -115,7 +115,7 @@ public function upload(array $payload): void { $payload = (object) $payload; - $path = 'images/'.strtolower(date('FY')).'/'; + $path = 'images/'.mb_strtolower(date('FY')).'/'; $fullPath = ''; try { @@ -136,7 +136,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->dispatchBrowserEvent('markdown-x-image-uploaded', [ 'status' => 400, 'message' => 'File type not supported. Must be of type '.implode(', ', config('markdownx.image.allowed_file_types')), @@ -268,17 +268,17 @@ function (User $user) { public function getSearchPeoples(array $payload): void { $users = User::where('name', 'like', '%'.$payload['search'].'%') - ->orWhere('username', 'like', '%'.$payload['search'].'%') - ->orderBy('name') - ->limit(30) - ->get() - ->map(function (User $user) { - $people['name'] = $user->name; - $people['picture'] = $user->profile_photo_url; - $people['username'] = $user->username; - - return $people; - }); + ->orWhere('username', 'like', '%'.$payload['search'].'%') + ->orderBy('name') + ->limit(30) + ->get() + ->map(function (User $user) { + $people['name'] = $user->name; + $people['picture'] = $user->profile_photo_url; + $people['username'] = $user->username; + + return $people; + }); $this->dispatchBrowserEvent('markdown-x-peoples-results', [ 'status' => 200, diff --git a/app/Http/Livewire/Modals/AnonymousSponsors.php b/app/Http/Livewire/Modals/AnonymousSponsors.php index 3dffa453..ab8e5a3d 100644 --- a/app/Http/Livewire/Modals/AnonymousSponsors.php +++ b/app/Http/Livewire/Modals/AnonymousSponsors.php @@ -14,14 +14,20 @@ use NotchPay\NotchPay; use NotchPay\Payment; -class AnonymousSponsors extends ModalComponent +final class AnonymousSponsors extends ModalComponent { public ?string $amount = null; + public ?string $option = null; + public ?string $name = null; + public ?string $email = null; + public string $type = 'company'; + public string $currency = 'XAF'; + public ?string $url = null; public function mount(string $amount, string $option, string $currency): void @@ -59,7 +65,7 @@ public function submit(): void 'email' => $this->email, 'name' => $this->name, 'currency' => $this->currency, - 'reference' => $adminUser->id . '-' . $adminUser->username() . '-' . uniqid(), + 'reference' => $adminUser->id.'-'.$adminUser->username().'-'.uniqid(), 'callback' => route('notchpay-callback'), 'description' => __('Soutien de la communauté Laravel & PHP Cameroun.'), ]); @@ -70,7 +76,7 @@ public function submit(): void 'transaction_reference' => $payload->transaction->reference, 'user_id' => $adminUser->id, 'fees' => $payload->transaction->fee, - 'type' => $this->option === 'one-time' + 'type' => 'one-time' === $this->option ? TransactionType::ONETIME->value : TransactionType::RECURSIVE->value, 'metadata' => [ diff --git a/app/Http/Livewire/Modals/ApprovedArticle.php b/app/Http/Livewire/Modals/ApprovedArticle.php index c0794f22..110bb1d1 100644 --- a/app/Http/Livewire/Modals/ApprovedArticle.php +++ b/app/Http/Livewire/Modals/ApprovedArticle.php @@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Cache; use LivewireUI\Modal\ModalComponent; -class ApprovedArticle extends ModalComponent +final class ApprovedArticle extends ModalComponent { use AuthorizesRequests; diff --git a/app/Http/Livewire/Modals/DeleteArticle.php b/app/Http/Livewire/Modals/DeleteArticle.php index 8f21fa5c..af3b49e7 100644 --- a/app/Http/Livewire/Modals/DeleteArticle.php +++ b/app/Http/Livewire/Modals/DeleteArticle.php @@ -10,7 +10,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use LivewireUI\Modal\ModalComponent; -class DeleteArticle extends ModalComponent +final class DeleteArticle extends ModalComponent { use AuthorizesRequests; diff --git a/app/Http/Livewire/Modals/DeleteDiscussion.php b/app/Http/Livewire/Modals/DeleteDiscussion.php index 97b93877..bf83e086 100644 --- a/app/Http/Livewire/Modals/DeleteDiscussion.php +++ b/app/Http/Livewire/Modals/DeleteDiscussion.php @@ -10,7 +10,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use LivewireUI\Modal\ModalComponent; -class DeleteDiscussion extends ModalComponent +final class DeleteDiscussion extends ModalComponent { use AuthorizesRequests; diff --git a/app/Http/Livewire/Modals/DeleteReply.php b/app/Http/Livewire/Modals/DeleteReply.php index 5f309b7b..0acc47f9 100644 --- a/app/Http/Livewire/Modals/DeleteReply.php +++ b/app/Http/Livewire/Modals/DeleteReply.php @@ -10,7 +10,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use LivewireUI\Modal\ModalComponent; -class DeleteReply extends ModalComponent +final class DeleteReply extends ModalComponent { use AuthorizesRequests; diff --git a/app/Http/Livewire/Modals/DeleteThread.php b/app/Http/Livewire/Modals/DeleteThread.php index 76bca373..a6992efa 100644 --- a/app/Http/Livewire/Modals/DeleteThread.php +++ b/app/Http/Livewire/Modals/DeleteThread.php @@ -10,7 +10,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use LivewireUI\Modal\ModalComponent; -class DeleteThread extends ModalComponent +final class DeleteThread extends ModalComponent { use AuthorizesRequests; diff --git a/app/Http/Livewire/Modals/Unsplash.php b/app/Http/Livewire/Modals/Unsplash.php index 9c396530..64ae7475 100644 --- a/app/Http/Livewire/Modals/Unsplash.php +++ b/app/Http/Livewire/Modals/Unsplash.php @@ -7,7 +7,7 @@ use Illuminate\Contracts\View\View; use LivewireUI\Modal\ModalComponent; -class Unsplash extends ModalComponent +final class Unsplash extends ModalComponent { public ?string $query = null; diff --git a/app/Http/Livewire/NotificationCount.php b/app/Http/Livewire/NotificationCount.php index c0a3379b..cffab96e 100644 --- a/app/Http/Livewire/NotificationCount.php +++ b/app/Http/Livewire/NotificationCount.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class NotificationCount extends Component +final class NotificationCount extends Component { public int $count = 0; diff --git a/app/Http/Livewire/NotificationIndicator.php b/app/Http/Livewire/NotificationIndicator.php index 8fb1243c..419cf575 100644 --- a/app/Http/Livewire/NotificationIndicator.php +++ b/app/Http/Livewire/NotificationIndicator.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class NotificationIndicator extends Component +final class NotificationIndicator extends Component { public bool $hasNotification = false; diff --git a/app/Http/Livewire/NotificationsPage.php b/app/Http/Livewire/NotificationsPage.php index f217849a..49f0e0a1 100644 --- a/app/Http/Livewire/NotificationsPage.php +++ b/app/Http/Livewire/NotificationsPage.php @@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class NotificationsPage extends Component +final class NotificationsPage extends Component { use AuthorizesRequests; diff --git a/app/Http/Livewire/Reactions.php b/app/Http/Livewire/Reactions.php index c101aed2..857fbd22 100644 --- a/app/Http/Livewire/Reactions.php +++ b/app/Http/Livewire/Reactions.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class Reactions extends Component +final class Reactions extends Component { public ReactableInterface $model; diff --git a/app/Http/Livewire/SponsorSubscription.php b/app/Http/Livewire/SponsorSubscription.php index 9d296361..6818a55a 100644 --- a/app/Http/Livewire/SponsorSubscription.php +++ b/app/Http/Livewire/SponsorSubscription.php @@ -14,10 +14,12 @@ use NotchPay\NotchPay; use NotchPay\Payment; -class SponsorSubscription extends Component +final class SponsorSubscription extends Component { public string $option = 'one-time'; + public string $amount = ''; + public string $currency = 'XAF'; public function chooseOption(string $option): void @@ -29,7 +31,7 @@ public function subscribe(): void { $this->validate(['amount' => 'required']); - if (!Auth::check()) { + if ( ! Auth::check()) { $this->emit('openModal', 'modals.anonymous-sponsors', [ 'amount' => $this->amount, 'option' => $this->option, @@ -47,7 +49,7 @@ public function subscribe(): void 'email' => Auth::user()?->email, 'name' => Auth::user()?->name, 'currency' => $this->currency, - 'reference' => Auth::id() . '-' . Auth::user()?->username() . '-' . uniqid(), + 'reference' => Auth::id().'-'.Auth::user()?->username().'-'.uniqid(), 'callback' => route('notchpay-callback'), 'description' => __('Soutien de la communauté Laravel & PHP Cameroun.'), ]); @@ -58,7 +60,7 @@ public function subscribe(): void 'transaction_reference' => $payload->transaction->reference, 'user_id' => Auth::id(), 'fees' => $payload->transaction->fee, - 'type' => $this->option === 'one-time' + 'type' => 'one-time' === $this->option ? TransactionType::ONETIME->value : TransactionType::RECURSIVE->value, 'metadata' => [ diff --git a/app/Http/Livewire/User/Settings/Customization.php b/app/Http/Livewire/User/Settings/Customization.php index c59bccff..14814293 100644 --- a/app/Http/Livewire/User/Settings/Customization.php +++ b/app/Http/Livewire/User/Settings/Customization.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class Customization extends Component +final class Customization extends Component { public string $theme = 'theme-light'; diff --git a/app/Http/Livewire/User/Settings/Notifications.php b/app/Http/Livewire/User/Settings/Notifications.php index bfa200e5..52f3313d 100644 --- a/app/Http/Livewire/User/Settings/Notifications.php +++ b/app/Http/Livewire/User/Settings/Notifications.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth; use Livewire\Component; -class Notifications extends Component +final class Notifications extends Component { use AuthorizesRequests; diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 0d826f20..dd826969 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -6,17 +6,11 @@ use Illuminate\Auth\Middleware\Authenticate as Middleware; -class Authenticate extends Middleware +final class Authenticate extends Middleware { - /** - * Get the path the user should be redirected to when they are not authenticated. - * - * @param \Illuminate\Http\Request $request - * @return string|null - */ protected function redirectTo($request): ?string { - if (! $request->expectsJson()) { + if ( ! $request->expectsJson()) { return route('login'); } diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php index a2930776..dddc45b4 100644 --- a/app/Http/Middleware/EncryptCookies.php +++ b/app/Http/Middleware/EncryptCookies.php @@ -6,14 +6,7 @@ use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; -class EncryptCookies extends Middleware +final class EncryptCookies extends Middleware { - /** - * The names of the cookies that should not be encrypted. - * - * @var array - */ - protected $except = [ - // - ]; + protected $except = []; } diff --git a/app/Http/Middleware/HttpsProtocol.php b/app/Http/Middleware/HttpsProtocol.php index a1e24b83..5f04f144 100644 --- a/app/Http/Middleware/HttpsProtocol.php +++ b/app/Http/Middleware/HttpsProtocol.php @@ -11,7 +11,7 @@ use Illuminate\Http\Response; use Symfony\Component\HttpFoundation\BinaryFileResponse; -class HttpsProtocol +final class HttpsProtocol { public function handle(Request $request, Closure $next): RedirectResponse | Response | JsonResponse | BinaryFileResponse { diff --git a/app/Http/Middleware/PreventRequestsDuringMaintenance.php b/app/Http/Middleware/PreventRequestsDuringMaintenance.php index d7353a24..3422e264 100644 --- a/app/Http/Middleware/PreventRequestsDuringMaintenance.php +++ b/app/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -6,14 +6,7 @@ use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware; -class PreventRequestsDuringMaintenance extends Middleware +final class PreventRequestsDuringMaintenance extends Middleware { - /** - * The URIs that should be reachable while maintenance mode is enabled. - * - * @var array - */ - protected $except = [ - // - ]; + protected $except = []; } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index d6553eab..e3c5685c 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -6,20 +6,14 @@ use App\Providers\RouteServiceProvider; use Closure; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Http\Response; use Illuminate\Support\Facades\Auth; -class RedirectIfAuthenticated +final class RedirectIfAuthenticated { - /** - * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @param string|null ...$guards - * @return mixed - */ - public function handle(Request $request, Closure $next, ...$guards) + public function handle(Request $request, Closure $next, ...$guards): Response | RedirectResponse { $guards = empty($guards) ? [null] : $guards; diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php index b538af8a..8157eeaf 100644 --- a/app/Http/Middleware/TrimStrings.php +++ b/app/Http/Middleware/TrimStrings.php @@ -6,13 +6,8 @@ use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; -class TrimStrings extends Middleware +final class TrimStrings extends Middleware { - /** - * The names of the attributes that should not be trimmed. - * - * @var array - */ protected $except = [ 'current_password', 'password', diff --git a/app/Http/Middleware/TrustHosts.php b/app/Http/Middleware/TrustHosts.php index 387344b7..88e1410b 100644 --- a/app/Http/Middleware/TrustHosts.php +++ b/app/Http/Middleware/TrustHosts.php @@ -6,13 +6,8 @@ use Illuminate\Http\Middleware\TrustHosts as Middleware; -class TrustHosts extends Middleware +final class TrustHosts extends Middleware { - /** - * Get the host patterns that should be trusted. - * - * @return array - */ public function hosts(): array { return [ diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 5ec274de..171a1d1e 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -5,22 +5,12 @@ namespace App\Http\Middleware; use Illuminate\Http\Middleware\TrustProxies as Middleware; -use Illuminate\Http\Request; +use Symfony\Component\HttpFoundation\Request; -class TrustProxies extends Middleware +final class TrustProxies extends Middleware { - /** - * The trusted proxies for this application. - * - * @var array|string|null - */ protected $proxies; - /** - * The headers that should be used to detect proxies. - * - * @var int - */ protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index c4527eef..8b799f8e 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -6,14 +6,7 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; -class VerifyCsrfToken extends Middleware +final class VerifyCsrfToken extends Middleware { - /** - * The URIs that should be excluded from CSRF verification. - * - * @var array - */ - protected $except = [ - // - ]; + protected $except = []; } diff --git a/app/Http/Requests/Api/Enterprise/RegisterRequest.php b/app/Http/Requests/Api/Enterprise/RegisterRequest.php index ddae3922..7f9d51e4 100644 --- a/app/Http/Requests/Api/Enterprise/RegisterRequest.php +++ b/app/Http/Requests/Api/Enterprise/RegisterRequest.php @@ -6,23 +6,13 @@ use Illuminate\Foundation\Http\FormRequest; -class RegisterRequest extends FormRequest +final class RegisterRequest extends FormRequest { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ public function authorize(): bool { return auth()->user()->isEnterprise(); // @phpstan-ignore-line } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ public function rules(): array { $regex = '/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/'; diff --git a/app/Http/Requests/Api/ForgotPasswordRequest.php b/app/Http/Requests/Api/ForgotPasswordRequest.php index 775dde03..1e595da0 100644 --- a/app/Http/Requests/Api/ForgotPasswordRequest.php +++ b/app/Http/Requests/Api/ForgotPasswordRequest.php @@ -6,23 +6,13 @@ use Illuminate\Foundation\Http\FormRequest; -class ForgotPasswordRequest extends FormRequest +final class ForgotPasswordRequest extends FormRequest { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ public function authorize(): bool { return true; } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/LoginRequest.php b/app/Http/Requests/Api/LoginRequest.php index 15855f1f..c76b01ae 100644 --- a/app/Http/Requests/Api/LoginRequest.php +++ b/app/Http/Requests/Api/LoginRequest.php @@ -6,23 +6,13 @@ use Illuminate\Foundation\Http\FormRequest; -class LoginRequest extends FormRequest +final class LoginRequest extends FormRequest { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ public function authorize(): bool { return true; } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/RegisterRequest.php b/app/Http/Requests/Api/RegisterRequest.php index 982e4665..f9c043af 100644 --- a/app/Http/Requests/Api/RegisterRequest.php +++ b/app/Http/Requests/Api/RegisterRequest.php @@ -6,23 +6,13 @@ use Illuminate\Foundation\Http\FormRequest; -class RegisterRequest extends FormRequest +final class RegisterRequest extends FormRequest { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ public function authorize(): bool { return true; } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/Api/ResetPasswordRequest.php b/app/Http/Requests/Api/ResetPasswordRequest.php index c7d3226e..d3bd43fa 100644 --- a/app/Http/Requests/Api/ResetPasswordRequest.php +++ b/app/Http/Requests/Api/ResetPasswordRequest.php @@ -7,23 +7,13 @@ use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rules\Password; -class ResetPasswordRequest extends FormRequest +final class ResetPasswordRequest extends FormRequest { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ public function authorize(): bool { return true; } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/UpdatePasswordRequest.php b/app/Http/Requests/UpdatePasswordRequest.php index 572d86b4..b9b1885e 100644 --- a/app/Http/Requests/UpdatePasswordRequest.php +++ b/app/Http/Requests/UpdatePasswordRequest.php @@ -8,16 +8,13 @@ use Illuminate\Foundation\Http\FormRequest; use Illuminate\Validation\Rules\Password; -class UpdatePasswordRequest extends FormRequest +final class UpdatePasswordRequest extends FormRequest { public function authorize(): bool { return auth()->check(); } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Requests/UpdateProfileRequest.php b/app/Http/Requests/UpdateProfileRequest.php index 1c5acdeb..3e0dd640 100644 --- a/app/Http/Requests/UpdateProfileRequest.php +++ b/app/Http/Requests/UpdateProfileRequest.php @@ -7,23 +7,13 @@ use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Auth; -class UpdateProfileRequest extends FormRequest +final class UpdateProfileRequest extends FormRequest { - /** - * Determine if the user is authorized to make this request. - * - * @return bool - */ public function authorize(): bool { return auth()->check(); } - /** - * Get the validation rules that apply to the request. - * - * @return array - */ public function rules(): array { return [ diff --git a/app/Http/Resources/AuthenticateUserResource.php b/app/Http/Resources/AuthenticateUserResource.php index ad2d0a7b..e19ebb26 100644 --- a/app/Http/Resources/AuthenticateUserResource.php +++ b/app/Http/Resources/AuthenticateUserResource.php @@ -10,14 +10,8 @@ /** * @mixin IdeHelperUser */ -class AuthenticateUserResource extends JsonResource +final class AuthenticateUserResource extends JsonResource { - /** - * Transform the resource into an array. - * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ public function toArray($request): array { return [ diff --git a/app/Http/Resources/DateTimeResource.php b/app/Http/Resources/DateTimeResource.php index 2b236ff1..7379aea1 100644 --- a/app/Http/Resources/DateTimeResource.php +++ b/app/Http/Resources/DateTimeResource.php @@ -6,13 +6,8 @@ use Illuminate\Http\Resources\Json\JsonResource; -class DateTimeResource extends JsonResource +final class DateTimeResource extends JsonResource { - /** - * Transform the resource into an array. - * - * @param \Illuminate\Http\Request $request - */ public function toArray($request): array { return [ diff --git a/app/Http/Resources/EnterpriseResource.php b/app/Http/Resources/EnterpriseResource.php index 3b00ed59..0a1fec08 100644 --- a/app/Http/Resources/EnterpriseResource.php +++ b/app/Http/Resources/EnterpriseResource.php @@ -10,7 +10,7 @@ /** * @mixin IdeHelperEnterprise */ -class EnterpriseResource extends JsonResource +final class EnterpriseResource extends JsonResource { public function toArray($request): array { diff --git a/app/Http/Resources/EnterpriseResourceCollection.php b/app/Http/Resources/EnterpriseResourceCollection.php index 442903a9..de21bccc 100644 --- a/app/Http/Resources/EnterpriseResourceCollection.php +++ b/app/Http/Resources/EnterpriseResourceCollection.php @@ -4,7 +4,7 @@ namespace App\Http\Resources; -class EnterpriseResourceCollection extends PaginationResourceCollection +final class EnterpriseResourceCollection extends PaginationResourceCollection { public function toArray($request): array { diff --git a/app/Http/Resources/PaginationResourceCollection.php b/app/Http/Resources/PaginationResourceCollection.php index 354ca3b4..2f6407ca 100644 --- a/app/Http/Resources/PaginationResourceCollection.php +++ b/app/Http/Resources/PaginationResourceCollection.php @@ -6,7 +6,7 @@ use Illuminate\Http\Resources\Json\ResourceCollection; -class PaginationResourceCollection extends ResourceCollection +abstract class PaginationResourceCollection extends ResourceCollection { public function __construct($resource, public $filters = []) { diff --git a/app/Http/Resources/PremiumUserResource.php b/app/Http/Resources/PremiumUserResource.php index 6d4cb085..4b307671 100644 --- a/app/Http/Resources/PremiumUserResource.php +++ b/app/Http/Resources/PremiumUserResource.php @@ -4,17 +4,15 @@ namespace App\Http\Resources; +use App\Models\IdeHelperUser; use Illuminate\Http\Resources\Json\JsonResource; -class PremiumUserResource extends JsonResource +/** + * @mixin IdeHelperUser + */ +final class PremiumUserResource extends JsonResource { - /** - * Transform the resource into an array. - * - * @param \Illuminate\Http\Request $request - * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable - */ - public function toArray($request) + public function toArray($request): array { return [ 'name' => $this->name, diff --git a/app/Http/Resources/ReplyResource.php b/app/Http/Resources/ReplyResource.php index 8e9450ac..661c59ef 100644 --- a/app/Http/Resources/ReplyResource.php +++ b/app/Http/Resources/ReplyResource.php @@ -10,7 +10,7 @@ /** * @mixin IdeHelperReply */ -class ReplyResource extends JsonResource +final class ReplyResource extends JsonResource { public function toArray($request): array { @@ -20,8 +20,8 @@ public function toArray($request): array 'model_type' => $this->replyable_type, 'model_id' => $this->replyable_id, 'created_at' => $this->created_at->getTimestamp(), - 'author' => new UserResource($this->author), - 'experience' => $this->author->getPoints(), + 'author' => new UserResource($this->user), + 'experience' => $this->user->getPoints(), 'has_replies' => $this->allChildReplies->isNotEmpty(), // @phpstan-ignore-next-line 'likes_count' => $this->getReactionsSummary()->sum('count'), diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php index fde615eb..6d74626c 100644 --- a/app/Http/Resources/UserResource.php +++ b/app/Http/Resources/UserResource.php @@ -10,7 +10,7 @@ /** * @mixin IdeHelperUser */ -class UserResource extends JsonResource +final class UserResource extends JsonResource { public function toArray($request): array { diff --git a/app/Listeners/NotifyMentionedUsers.php b/app/Listeners/NotifyMentionedUsers.php index b41e0920..f1330ed8 100644 --- a/app/Listeners/NotifyMentionedUsers.php +++ b/app/Listeners/NotifyMentionedUsers.php @@ -8,7 +8,7 @@ use App\Models\User; use App\Notifications\YouWereMentioned; -class NotifyMentionedUsers +final class NotifyMentionedUsers { public function handle(ReplyWasCreated $event): void { diff --git a/app/Listeners/PostNewThreadNotification.php b/app/Listeners/PostNewThreadNotification.php index 6404fc83..ca0b994f 100644 --- a/app/Listeners/PostNewThreadNotification.php +++ b/app/Listeners/PostNewThreadNotification.php @@ -7,7 +7,7 @@ use App\Events\ThreadWasCreated; use App\Notifications\PostThreadToTelegram; -class PostNewThreadNotification +final class PostNewThreadNotification { public function handle(ThreadWasCreated $event): void { diff --git a/app/Mail/NewReplyEmail.php b/app/Mail/NewReplyEmail.php index e3949571..69c99d4f 100644 --- a/app/Mail/NewReplyEmail.php +++ b/app/Mail/NewReplyEmail.php @@ -10,15 +10,10 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; -class NewReplyEmail extends Mailable implements ShouldQueue +final class NewReplyEmail extends Mailable implements ShouldQueue { use Queueable; - /** - * Create a new message instance. - * - * @return void - */ public function __construct( public readonly Reply $reply, public readonly Subscribe $subscription diff --git a/app/Mail/SendMailToUnVerifiedUsers.php b/app/Mail/SendMailToUnVerifiedUsers.php index 8e6e93d7..08a39917 100644 --- a/app/Mail/SendMailToUnVerifiedUsers.php +++ b/app/Mail/SendMailToUnVerifiedUsers.php @@ -10,7 +10,7 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -class SendMailToUnVerifiedUsers extends Mailable implements ShouldQueue +final class SendMailToUnVerifiedUsers extends Mailable implements ShouldQueue { use Queueable; use SerializesModels; diff --git a/app/Mail/Welcome.php b/app/Mail/Welcome.php index 6beda517..efe74d48 100644 --- a/app/Mail/Welcome.php +++ b/app/Mail/Welcome.php @@ -10,7 +10,7 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -class Welcome extends Mailable implements ShouldQueue +final class Welcome extends Mailable implements ShouldQueue { use Queueable; use SerializesModels; diff --git a/app/Markdown/MarkdownHelper.php b/app/Markdown/MarkdownHelper.php index 2d4bcdbb..cb7bc119 100644 --- a/app/Markdown/MarkdownHelper.php +++ b/app/Markdown/MarkdownHelper.php @@ -4,7 +4,7 @@ namespace App\Markdown; -class MarkdownHelper +final class MarkdownHelper { public static function parseLiquidTags(string $html): string { @@ -71,7 +71,7 @@ public static function replaceCodePenTag(string $html, array $tagArray, string $ if (isset($tagArray[2])) { $codepenEmbedURL = str_replace('/pen/', '/embed/', $tagArray[2]); $defaultTag = 'default-tab=result'; - if (isset($tagArray[3]) && $tagArray[3] != '%}') { + if (isset($tagArray[3]) && '%}' !== $tagArray[3]) { $defaultTag = $tagArray[3]; } $codepenEmbed = '
'; @@ -89,11 +89,11 @@ public static function replaceCodePenTag(string $html, array $tagArray, string $ */ public static function replaceCodeSandboxTag(string $html, array $tagArray, string $original_string): string { - if (isset($tagArray[2]) && $tagArray[2] !== '%}') { + if (isset($tagArray[2]) && '%}' !== $tagArray[2]) { $codesandbox = $tagArray[2]; $url = parse_url($codesandbox); // @phpstan-ignore-next-line - if (filter_var($codesandbox, FILTER_VALIDATE_URL) && ($url['host'] == 'www.codesandbox.io' || $url['host'] == 'codesandbox.io')) { + if (filter_var($codesandbox, FILTER_VALIDATE_URL) && ('www.codesandbox.io' === $url['host'] || 'codesandbox.io' === $url['host'])) { $codesandboxEmbed = ''; $html = str_replace($original_string, $codesandboxEmbed, $html); } @@ -110,7 +110,7 @@ public static function replaceCodeSandboxTag(string $html, array $tagArray, stri */ public static function replaceBuyMeACoffeeTag(string $html, array $tagArray, string $original_string): string { - if (isset($tagArray[2]) && $tagArray[2] != '%}') { + if (isset($tagArray[2]) && '%}' !== $tagArray[2]) { $buyMeACoffee = $tagArray[2]; $bmcEmbed = '
Buy Me A Coffee '.$buyMeACoffee.'
'; $html = str_replace($original_string, $bmcEmbed, $html); diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 4d549eb9..6af4db60 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -13,15 +13,10 @@ /** * @mixin IdeHelperActivity */ -class Activity extends Model +final class Activity extends Model { use HasFactory; - /** - * The attributes that are mass assignable. - * - * @var string[] - */ protected $fillable = [ 'user_id', 'data', @@ -30,11 +25,6 @@ class Activity extends Model 'type', ]; - /** - * The attributes that should be cast. - * - * @var array - */ protected $casts = [ 'data' => 'array', ]; diff --git a/app/Models/Article.php b/app/Models/Article.php index 6b6b7ceb..bc23c948 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -23,7 +23,7 @@ /** * @mixin IdeHelperArticle */ -class Article extends Model implements ReactableInterface, HasMedia, Viewable +final class Article extends Model implements ReactableInterface, HasMedia, Viewable { use HasAuthor; use HasFactory; @@ -34,11 +34,6 @@ class Article extends Model implements ReactableInterface, HasMedia, Viewable use Reactable; use RecordsActivity; - /** - * The attributes that are mass assignable. - * - * @var string[] - */ protected $fillable = [ 'title', 'body', @@ -57,11 +52,6 @@ class Article extends Model implements ReactableInterface, HasMedia, Viewable 'published_at', ]; - /** - * The attributes that should be cast. - * - * @var array - */ protected $casts = [ 'submitted_at' => 'datetime', 'approved_at' => 'datetime', @@ -73,22 +63,12 @@ class Article extends Model implements ReactableInterface, HasMedia, Viewable 'is_pinned' => 'boolean', ]; - /** - * The relations to eager load on every query. - * - * @var string[] - */ protected $with = [ 'media', ]; protected bool $removeViewsOnDelete = true; - /** - * Get the route key for the model. - * - * @return string - */ public function getRouteKeyName(): string { return 'slug'; @@ -168,7 +148,7 @@ public function isSubmitted(): bool public function isNotSubmitted(): bool { - return $this->submitted_at === null; + return null === $this->submitted_at; } public function isApproved(): bool @@ -178,7 +158,7 @@ public function isApproved(): bool public function isNotApproved(): bool { - return $this->approved_at === null; + return null === $this->approved_at; } public function isSponsored(): bool @@ -188,7 +168,7 @@ public function isSponsored(): bool public function isNotSponsored(): bool { - return $this->sponsored_at === null; + return null === $this->sponsored_at; } public function isDeclined(): bool @@ -198,7 +178,7 @@ public function isDeclined(): bool public function isNotDeclined(): bool { - return $this->declined_at === null; + return null === $this->declined_at; } public function isPublished(): bool @@ -218,7 +198,7 @@ public function isPinned(): bool public function isNotShared(): bool { - return $this->shared_at === null; + return null === $this->shared_at; } public function isShared(): bool @@ -303,7 +283,7 @@ public function scopePublished(Builder $query): Builder */ public function scopeNotPublished(Builder $query): Builder { - return $query->where(function ($query) { + return $query->where(function ($query): void { $query->whereNull('submitted_at') ->orWhereNull('approved_at') ->orWhereNull('published_at') @@ -421,7 +401,7 @@ public function scopePopular(Builder $query): Builder */ public function scopeTrending(Builder $query): Builder { - return $query->withCount(['reactions' => function ($query) { + return $query->withCount(['reactions' => function ($query): void { $query->where('created_at', '>=', now()->subWeek()); }]) ->orderBy('reactions_count', 'desc') diff --git a/app/Models/Channel.php b/app/Models/Channel.php index 546abe83..2952a82c 100644 --- a/app/Models/Channel.php +++ b/app/Models/Channel.php @@ -15,16 +15,11 @@ /** * @mixin IdeHelperChannel */ -class Channel extends Model +final class Channel extends Model { use HasFactory; use HasSlug; - /** - * The attributes that are mass assignable. - * - * @var string[] - */ protected $fillable = [ 'name', 'slug', @@ -32,11 +27,6 @@ class Channel extends Model 'color', ]; - /** - * The relationship counts that should be eager loaded on every query. - * - * @var string[] - */ protected $withCount = [ 'threads', ]; @@ -45,7 +35,7 @@ protected static function boot(): void { parent::boot(); - static::saving(function ($channel) { + static::saving(function ($channel): void { if ($channel->parent_id) { if ($record = self::find($channel->parent_id)) { if ($record->exists() && $record->parent_id) { // @phpstan-ignore-line @@ -56,11 +46,6 @@ protected static function boot(): void }); } - /** - * Get the route key for the model. - * - * @return string - */ public function getRouteKeyName(): string { return 'slug'; diff --git a/app/Models/Discussion.php b/app/Models/Discussion.php index ebd95baa..3c41f9d0 100644 --- a/app/Models/Discussion.php +++ b/app/Models/Discussion.php @@ -24,23 +24,18 @@ /** * @mixin IdeHelperDiscussion */ -class Discussion extends Model implements ReactableInterface, ReplyInterface, SubscribeInterface, Viewable +final class Discussion extends Model implements ReactableInterface, ReplyInterface, SubscribeInterface, Viewable { use HasAuthor; use HasFactory; use HasReplies; - use HasSubscribers; use HasSlug; + use HasSubscribers; use HasTags; use InteractsWithViews; use Reactable; use RecordsActivity; - /** - * The attributes that are mass assignable. - * - * @var string[] - */ protected $fillable = [ 'title', 'body', @@ -50,32 +45,17 @@ class Discussion extends Model implements ReactableInterface, ReplyInterface, Su 'locked', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'locked' => 'boolean', 'is_pinned' => 'boolean', ]; - /** - * The accessors to append to the model's array form. - * - * @var array - */ protected $appends = [ 'count_all_replies_with_child', ]; protected bool $removeViewsOnDelete = true; - /** - * Get the route key for the model. - * - * @return string - */ public function getRouteKeyName(): string { return 'slug'; @@ -147,7 +127,7 @@ public function scopePopular(Builder $query): Builder public function scopeActive(Builder $query): Builder { - return $query->withCount(['replies' => function ($query) { + return $query->withCount(['replies' => function ($query): void { $query->where('created_at', '>=', now()->subWeek()); }]) ->orderBy('replies_count', 'desc'); @@ -164,11 +144,11 @@ public function lockedDiscussion(): void $this->update(['locked' => true]); } - public function delete() + public function delete(): ?bool { $this->removeTags(); $this->deleteReplies(); - parent::delete(); + return parent::delete(); } } diff --git a/app/Models/Enterprise.php b/app/Models/Enterprise.php index 3dbff13d..78868b86 100644 --- a/app/Models/Enterprise.php +++ b/app/Models/Enterprise.php @@ -18,11 +18,11 @@ /** * @mixin IdeHelperEnterprise */ -class Enterprise extends Model implements HasMedia +final class Enterprise extends Model implements HasMedia { use HasFactory; - use HasSlug; use HasSettings; + use HasSlug; use InteractsWithMedia; protected $fillable = [ @@ -42,11 +42,6 @@ class Enterprise extends Model implements HasMedia 'settings', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'settings' => 'array', 'is_public' => 'boolean', diff --git a/app/Models/Feature.php b/app/Models/Feature.php index 60fe6b6c..8c6bd20b 100644 --- a/app/Models/Feature.php +++ b/app/Models/Feature.php @@ -10,7 +10,7 @@ /** * @mixin IdeHelperFeature */ -class Feature extends Model +final class Feature extends Model { use HasFactory; diff --git a/app/Models/Premium/Feature.php b/app/Models/Premium/Feature.php index 291d2b8b..0fbb9fe0 100644 --- a/app/Models/Premium/Feature.php +++ b/app/Models/Premium/Feature.php @@ -10,7 +10,7 @@ /** * @mixin IdeHelperFeature */ -class Feature extends Model +final class Feature extends Model { use HasFactory; } diff --git a/app/Models/Premium/Plan.php b/app/Models/Premium/Plan.php index f3ca7ec4..54ce1321 100644 --- a/app/Models/Premium/Plan.php +++ b/app/Models/Premium/Plan.php @@ -4,6 +4,7 @@ namespace App\Models\Premium; +use App\Enums\PlanType; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Rinvex\Subscriptions\Models\Plan as Model; @@ -11,17 +12,17 @@ /** * @mixin IdeHelperPlan */ -class Plan extends Model +final class Plan extends Model { use HasFactory; public function scopeDeveloper(Builder $query): Builder { - return $query->where('type', \App\Enums\PlanType::DEVELOPER); + return $query->where('type', PlanType::DEVELOPER->value); } public function scopeEnterprise(Builder $query): Builder { - return $query->where('type', \App\Enums\PlanType::ENTERPRISE); + return $query->where('type', PlanType::ENTERPRISE->value); } } diff --git a/app/Models/Premium/Subscription.php b/app/Models/Premium/Subscription.php index 43942b78..65354500 100644 --- a/app/Models/Premium/Subscription.php +++ b/app/Models/Premium/Subscription.php @@ -10,7 +10,7 @@ /** * @mixin IdeHelperSubscription */ -class Subscription extends Model +final class Subscription extends Model { use HasFactory; } diff --git a/app/Models/Premium/SubscriptionUsage.php b/app/Models/Premium/SubscriptionUsage.php index 3c0b598b..48e462c2 100644 --- a/app/Models/Premium/SubscriptionUsage.php +++ b/app/Models/Premium/SubscriptionUsage.php @@ -10,7 +10,7 @@ /** * @mixin IdeHelperSubscriptionUsage */ -class SubscriptionUsage extends Model +final class SubscriptionUsage extends Model { use HasFactory; } diff --git a/app/Models/Reaction.php b/app/Models/Reaction.php index b31e07a1..aaf69573 100644 --- a/app/Models/Reaction.php +++ b/app/Models/Reaction.php @@ -10,13 +10,10 @@ /** * @mixin IdeHelperReaction */ -class Reaction extends Model +final class Reaction extends Model { use HasFactory; - /** - * @var string[]|bool - */ protected $guarded = []; public static function createFromName(string $name): self @@ -24,9 +21,6 @@ public static function createFromName(string $name): self return self::create(['name' => $name]); } - /** - * @return mixed - */ public function getResponder(): mixed { if ($this->getOriginal('pivot_responder_type', null)) { diff --git a/app/Models/Reply.php b/app/Models/Reply.php index ec4b412e..2555c9ef 100644 --- a/app/Models/Reply.php +++ b/app/Models/Reply.php @@ -22,7 +22,7 @@ /** * @mixin IdeHelperReply */ -class Reply extends Model implements ReactableInterface, ReplyInterface +final class Reply extends Model implements ReactableInterface, ReplyInterface { use HasAuthor; use HasFactory; @@ -30,11 +30,6 @@ class Reply extends Model implements ReactableInterface, ReplyInterface use Reactable; use RecordsActivity; - /** - * The attributes that are mass assignable. - * - * @var string[] - */ protected $fillable = [ 'body', ]; @@ -69,9 +64,6 @@ public function excerpt(int $limit = 100): string return Str::limit(strip_tags((string) md_to_html($this->body)), $limit); } - /** - * @return string[] - */ public function mentionedUsers(): array { preg_match_all('/@([a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?!\w))/', $this->body, $matches); diff --git a/app/Models/SocialAccount.php b/app/Models/SocialAccount.php index b2073495..63144afc 100644 --- a/app/Models/SocialAccount.php +++ b/app/Models/SocialAccount.php @@ -10,15 +10,10 @@ /** * @mixin IdeHelperSocialAccount */ -class SocialAccount extends Model +final class SocialAccount extends Model { use HasFactory; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'user_id', 'provider', diff --git a/app/Models/Subscribe.php b/app/Models/Subscribe.php index b2fe5f6c..6360e4b6 100644 --- a/app/Models/Subscribe.php +++ b/app/Models/Subscribe.php @@ -13,7 +13,7 @@ /** * @mixin IdeHelperSubscribe */ -class Subscribe extends Model +final class Subscribe extends Model { use HasFactory; use HasUuid; diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 3b887205..8ff3b918 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -13,7 +13,7 @@ /** * @mixin IdeHelperTag */ -class Tag extends Model +final class Tag extends Model { use HasFactory; use HasSlug; @@ -28,11 +28,6 @@ class Tag extends Model 'concerns', ]; - /** - * The attributes that should be cast. - * - * @var array - */ protected $casts = [ 'concerns' => 'array', ]; diff --git a/app/Models/Thread.php b/app/Models/Thread.php index 0b826d3a..23b5291d 100644 --- a/app/Models/Thread.php +++ b/app/Models/Thread.php @@ -35,12 +35,12 @@ /** * @mixin IdeHelperThread */ -class Thread extends Model implements Feedable, ReactableInterface, ReplyInterface, SubscribeInterface, Viewable +final class Thread extends Model implements Feedable, ReactableInterface, ReplyInterface, SubscribeInterface, Viewable { use HasAuthor; use HasFactory; - use HasSlug; use HasReplies; + use HasSlug; use HasSubscribers; use InteractsWithViews; use Notifiable; @@ -49,11 +49,6 @@ class Thread extends Model implements Feedable, ReactableInterface, ReplyInterfa public const FEED_PAGE_SIZE = 20; - /** - * The attributes that are mass assignable. - * - * @var string[] - */ protected $fillable = [ 'title', 'body', @@ -61,32 +56,17 @@ class Thread extends Model implements Feedable, ReactableInterface, ReplyInterfa 'user_id', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'locked' => 'boolean', 'last_posted_at' => 'datetime', ]; - /** - * The relations to eager load on every query. - * - * @var array - */ protected $with = [ 'channels', ]; protected bool $removeViewsOnDelete = true; - /** - * Get the route key for the model. - * - * @return string - */ public function getRouteKeyName(): string { return 'slug'; @@ -138,7 +118,7 @@ public function isSolutionReply(Reply $reply): bool public function isSolved(): bool { - return ! is_null($this->solution_reply_id); + return null !== $this->solution_reply_id; } public function wasResolvedBy(User $user): bool @@ -154,7 +134,7 @@ public function markSolution(Reply $reply, User $user): void { $thread = $reply->replyAble; - if (! $thread instanceof self) { + if ( ! $thread instanceof self) { throw CouldNotMarkReplyAsSolution::replyAbleIsNotAThread($reply); } @@ -172,7 +152,7 @@ public function unmarkSolution(): void public function scopeForChannel(Builder $query, Channel $channel): Builder { - return $query->whereHas('channels', function ($query) use ($channel) { + return $query->whereHas('channels', function ($query) use ($channel): void { if ($channel->hasItems()) { $query->whereIn('channels.id', array_merge([$channel->id], $channel->items->modelKeys())); } else { @@ -259,7 +239,7 @@ public function scopeFeedQuery(Builder $query): Builder 'channels', 'user', ]) - ->leftJoin('replies', function ($join) { + ->leftJoin('replies', function ($join): void { $join->on('threads.id', 'replies.replyable_id') ->where('replies.replyable_type', self::class); }) diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 9505b3bc..6d50ffb6 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -14,7 +14,7 @@ /** * @mixin IdeHelperTransaction */ -class Transaction extends Model +final class Transaction extends Model { use HasFactory; use HasUuids; diff --git a/app/Models/User.php b/app/Models/User.php index c8edf851..57f47fc9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -35,20 +35,20 @@ /** * @mixin IdeHelperUser */ -class User extends Authenticatable implements MustVerifyEmail, HasMedia, FeaturableInterface, FilamentUser, HasName, HasAvatar +final class User extends Authenticatable implements MustVerifyEmail, HasMedia, FeaturableInterface, FilamentUser, HasName, HasAvatar { + use Featurable; use Gamify; + use HasApiTokens; use HasFactory; use HasPlanSubscriptions; use HasProfilePhoto; - use HasApiTokens; use HasRoles; - use HasUsername; use HasSettings; + use HasUsername; use InteractsWithMedia; use Notifiable; use Reacts; - use Featurable; protected $fillable = [ 'name', @@ -98,7 +98,7 @@ class User extends Authenticatable implements MustVerifyEmail, HasMedia, Featura public function hasProvider(string $provider): bool { foreach ($this->providers as $p) { - if ($p->provider == $provider) { + if ($p->provider === $provider) { return true; } } @@ -113,7 +113,7 @@ public function enterprise(): HasOne public function hasEnterprise(): bool { - return $this->enterprise !== null; + return null !== $this->enterprise; } public function getRolesLabelAttribute(): string @@ -121,9 +121,7 @@ public function getRolesLabelAttribute(): string $roles = $this->getRoleNames()->toArray(); if (count($roles)) { - return implode(', ', array_map(function ($item) { - return ucwords($item); - }, $roles)); + return implode(', ', array_map(fn ($item) => ucwords($item), $roles)); } return 'N/A'; @@ -207,13 +205,13 @@ public static function findOrCreateSocialUserProvider(SocialUser $socialUser, st $user = static::where('email', $socialEmail)->first(); - if (! $user) { + if ( ! $user) { $user = self::create([ 'name' => $socialUser->getName() ?? $socialUser->getNickName() ?? $socialUser->getId(), 'email' => $socialEmail, 'username' => $socialUser->getNickName() ?? $socialUser->getId(), - 'github_profile' => $provider === 'github' ? $socialUser->getNickName() : null, - 'twitter_profile' => $provider === 'twitter' ? $socialUser->getNickName() : null, + 'github_profile' => 'github' === $provider ? $socialUser->getNickName() : null, + 'twitter_profile' => 'twitter' === $provider ? $socialUser->getNickName() : null, 'email_verified_at' => now(), 'avatar_type' => $provider, ]); @@ -309,7 +307,7 @@ public function linkedin(): ?string public function scopeModerators(Builder $query): Builder { - return $query->whereHas('roles', function ($query) { + return $query->whereHas('roles', function ($query): void { $query->where('name', '<>', 'user'); }); } @@ -333,20 +331,20 @@ public function hasPassword(): bool { $password = $this->getAuthPassword(); - return $password !== '' && $password !== null; + return '' !== $password && null !== $password; } - public function delete() + public function delete(): ?bool { $this->deleteThreads(); $this->deleteReplies(); - parent::delete(); + return parent::delete(); } public function scopeHasActivity(Builder $query): Builder { - return $query->where(function ($query) { + return $query->where(function ($query): void { $query->has('threads') ->orHas('replyAble'); }); diff --git a/app/Notifications/ArticleSubmitted.php b/app/Notifications/ArticleSubmitted.php index f1f3550d..a801b6eb 100644 --- a/app/Notifications/ArticleSubmitted.php +++ b/app/Notifications/ArticleSubmitted.php @@ -11,7 +11,7 @@ use NotificationChannels\Telegram\TelegramChannel; use NotificationChannels\Telegram\TelegramMessage; -class ArticleSubmitted extends Notification implements ShouldQueue +final class ArticleSubmitted extends Notification implements ShouldQueue { use Queueable; @@ -19,9 +19,6 @@ public function __construct(private readonly Article $article) { } - /** - * @return array|string[] - */ public function via(mixed $notifiable): array { if ( diff --git a/app/Notifications/NewCommentNotification.php b/app/Notifications/NewCommentNotification.php index ccfc4deb..ac77905e 100644 --- a/app/Notifications/NewCommentNotification.php +++ b/app/Notifications/NewCommentNotification.php @@ -12,7 +12,7 @@ use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -class NewCommentNotification extends Notification implements ShouldQueue +final class NewCommentNotification extends Notification implements ShouldQueue { use Queueable; @@ -34,11 +34,11 @@ public function via(mixed $notifiable): array public function toMail(): MailMessage { return (new MailMessage()) - ->subject("Re: {$this->discussion->subject()}") - ->line(__('@:name a répondu à ce sujet.', ['name' => $this->reply->user?->username])) - ->line($this->reply->excerpt(150)) - ->action(__('Voir la discussion'), route('discussions.show', $this->discussion)) - ->line(__('Vous recevez ceci parce que vous êtes abonné à cette discussion.')); + ->subject("Re: {$this->discussion->subject()}") + ->line(__('@:name a répondu à ce sujet.', ['name' => $this->reply->user?->username])) + ->line($this->reply->excerpt(150)) + ->action(__('Voir la discussion'), route('discussions.show', $this->discussion)) + ->line(__('Vous recevez ceci parce que vous êtes abonné à cette discussion.')); } /** diff --git a/app/Notifications/NewReplyNotification.php b/app/Notifications/NewReplyNotification.php index 7532217e..10289299 100644 --- a/app/Notifications/NewReplyNotification.php +++ b/app/Notifications/NewReplyNotification.php @@ -12,7 +12,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Notification; -class NewReplyNotification extends Notification implements ShouldQueue +final class NewReplyNotification extends Notification implements ShouldQueue { use Queueable; @@ -20,9 +20,6 @@ public function __construct(public Reply $reply, public Subscribe $subscription) { } - /** - * @return string[] - */ public function via(mixed $notifiable): array { return ['mail', 'database']; diff --git a/app/Notifications/NewSponsorPaymentNotification.php b/app/Notifications/NewSponsorPaymentNotification.php index af7fa96f..47253867 100644 --- a/app/Notifications/NewSponsorPaymentNotification.php +++ b/app/Notifications/NewSponsorPaymentNotification.php @@ -11,7 +11,7 @@ use NotificationChannels\Telegram\TelegramChannel; use NotificationChannels\Telegram\TelegramMessage; -class NewSponsorPaymentNotification extends Notification implements ShouldQueue +final class NewSponsorPaymentNotification extends Notification implements ShouldQueue { use Queueable; @@ -19,9 +19,6 @@ public function __construct(public readonly Transaction $transaction) { } - /** - * @return array|string[] - */ public function via(mixed $notifiable): array { if ( @@ -46,7 +43,7 @@ private function content(): string { $content = "*Nouveau paiement de Sponsoring enregistré!*\n\n"; $content .= 'Auteur: '.$this->transaction->getMetadata('merchant')['name']."\n"; - $content .= 'Montant: '. $this->transaction->amount; + $content .= 'Montant: '.$this->transaction->amount; if ($this->transaction->getMetadata('merchant')['laravel_cm_id']) { $content .= 'Profil Laravel Cameroun: [@'.$this->transaction->user?->username.']('.route('profile', $this->transaction->user?->username).')'; diff --git a/app/Notifications/PostArticleToTelegram.php b/app/Notifications/PostArticleToTelegram.php index 14afed7d..d35aafcf 100644 --- a/app/Notifications/PostArticleToTelegram.php +++ b/app/Notifications/PostArticleToTelegram.php @@ -10,7 +10,7 @@ use NotificationChannels\Telegram\TelegramChannel; use NotificationChannels\Telegram\TelegramMessage; -class PostArticleToTelegram extends Notification +final class PostArticleToTelegram extends Notification { use Queueable; @@ -18,9 +18,6 @@ public function __construct(public Article $article) { } - /** - * @return string[] - */ public function via(mixed $notifiable): array { return [TelegramChannel::class]; diff --git a/app/Notifications/PostArticleToTwitter.php b/app/Notifications/PostArticleToTwitter.php index f196b288..c2243ff7 100644 --- a/app/Notifications/PostArticleToTwitter.php +++ b/app/Notifications/PostArticleToTwitter.php @@ -11,7 +11,7 @@ use NotificationChannels\Twitter\TwitterChannel; use NotificationChannels\Twitter\TwitterStatusUpdate; -class PostArticleToTwitter extends Notification +final class PostArticleToTwitter extends Notification { use Queueable; @@ -22,9 +22,6 @@ public function __construct(Article $article) $this->article = $article->load('user'); } - /** - * @return string[] - */ public function via(mixed $notifiable): array { return [TwitterChannel::class]; diff --git a/app/Notifications/PostDiscussionToTelegram.php b/app/Notifications/PostDiscussionToTelegram.php index b7a77b68..5801c91b 100644 --- a/app/Notifications/PostDiscussionToTelegram.php +++ b/app/Notifications/PostDiscussionToTelegram.php @@ -10,7 +10,7 @@ use NotificationChannels\Telegram\TelegramChannel; use NotificationChannels\Telegram\TelegramMessage; -class PostDiscussionToTelegram extends Notification +final class PostDiscussionToTelegram extends Notification { use Queueable; @@ -18,9 +18,6 @@ public function __construct(public Discussion $discussion) { } - /** - * @return string[] - */ public function via(mixed $notifiable): array { return [TelegramChannel::class]; diff --git a/app/Notifications/PostThreadToSlack.php b/app/Notifications/PostThreadToSlack.php index 1dc30520..ccb28194 100644 --- a/app/Notifications/PostThreadToSlack.php +++ b/app/Notifications/PostThreadToSlack.php @@ -9,7 +9,7 @@ use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; -class PostThreadToSlack extends Notification +final class PostThreadToSlack extends Notification { use Queueable; @@ -20,9 +20,6 @@ public function __construct(Thread $thread) $this->thread = $thread->load('user'); } - /** - * @return string[] - */ public function via(mixed $notifiable): array { return ['slack']; diff --git a/app/Notifications/PostThreadToTelegram.php b/app/Notifications/PostThreadToTelegram.php index f84dd58a..e7501d2e 100644 --- a/app/Notifications/PostThreadToTelegram.php +++ b/app/Notifications/PostThreadToTelegram.php @@ -9,13 +9,10 @@ use NotificationChannels\Telegram\TelegramChannel; use NotificationChannels\Telegram\TelegramMessage; -class PostThreadToTelegram extends Notification +final class PostThreadToTelegram extends Notification { use Queueable; - /** - * @return string[] - */ public function via(mixed $notifiable): array { return [TelegramChannel::class]; diff --git a/app/Notifications/SendApprovedArticle.php b/app/Notifications/SendApprovedArticle.php index ef91bc6d..d460e3d9 100644 --- a/app/Notifications/SendApprovedArticle.php +++ b/app/Notifications/SendApprovedArticle.php @@ -10,7 +10,7 @@ use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -class SendApprovedArticle extends Notification implements ShouldQueue +final class SendApprovedArticle extends Notification implements ShouldQueue { use Queueable; @@ -18,9 +18,6 @@ public function __construct(public Article $article) { } - /** - * @return string[] - */ public function via(mixed $notifiable): array { return ['mail']; @@ -29,10 +26,10 @@ public function via(mixed $notifiable): array public function toMail(): MailMessage { return (new MailMessage()) - ->subject(__('Article Approuvé 🎉.')) - ->greeting(__('Article Approuvé 🎉.')) - ->line(__('Merci d\'avoir soumis votre article pour créer du contenu au sein de Laravel Cameroun.')) - ->action(__('Voir mon article'), route('articles.show', $this->article)) - ->line(__('Merci d\'avoir utilisé Laravel Cameroun.!')); + ->subject(__('Article Approuvé 🎉.')) + ->greeting(__('Article Approuvé 🎉.')) + ->line(__('Merci d\'avoir soumis votre article pour créer du contenu au sein de Laravel Cameroun.')) + ->action(__('Voir mon article'), route('articles.show', $this->article)) + ->line(__('Merci d\'avoir utilisé Laravel Cameroun.!')); } } diff --git a/app/Notifications/SendEMailToDeletedUser.php b/app/Notifications/SendEMailToDeletedUser.php index 0d11519d..c32d1442 100644 --- a/app/Notifications/SendEMailToDeletedUser.php +++ b/app/Notifications/SendEMailToDeletedUser.php @@ -9,13 +9,10 @@ use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -class SendEMailToDeletedUser extends Notification implements ShouldQueue +final class SendEMailToDeletedUser extends Notification implements ShouldQueue { use Queueable; - /** - * @return string[] - */ public function via(mixed $notifiable): array { return ['mail']; @@ -24,10 +21,10 @@ public function via(mixed $notifiable): array public function toMail(): MailMessage { return (new MailMessage()) - ->subject(__('Suppression de compte | Laravel Cameroun')) - ->line(__('Pour des raisons de validité et d\'authenticité de votre adresse email')) - ->line(__('Nous avons supprimé votre compte après 10 jours d\'inscription sans validation de votre adresse email.')) - ->line(__('Nous ne pouvons donc pas authentifier que cette adresse e-mail est belle et bien utilisée.')) - ->line(__('Merci d\'avoir utilisé Laravel Cameroun!')); + ->subject(__('Suppression de compte | Laravel Cameroun')) + ->line(__('Pour des raisons de validité et d\'authenticité de votre adresse email')) + ->line(__('Nous avons supprimé votre compte après 10 jours d\'inscription sans validation de votre adresse email.')) + ->line(__('Nous ne pouvons donc pas authentifier que cette adresse e-mail est belle et bien utilisée.')) + ->line(__('Merci d\'avoir utilisé Laravel Cameroun!')); } } diff --git a/app/Notifications/YouWereMentioned.php b/app/Notifications/YouWereMentioned.php index 44ab9c25..1b148555 100644 --- a/app/Notifications/YouWereMentioned.php +++ b/app/Notifications/YouWereMentioned.php @@ -11,7 +11,7 @@ use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; -class YouWereMentioned extends Notification implements ShouldQueue +final class YouWereMentioned extends Notification implements ShouldQueue { use Queueable; @@ -19,9 +19,6 @@ public function __construct(public readonly Reply $reply) { } - /** - * @return string[] - */ public function via(mixed $notifiable): array { return ['database', 'mail']; @@ -33,15 +30,12 @@ public function toMail(): MailMessage $thread = $this->reply->replyAble; return (new MailMessage()) - ->subject(__('Nouvelle mention: :subject', ['subject' => $thread->subject()])) - ->line(__(':name vous a mentionné dans le sujet :subject', ['name' => $this->reply->user?->name, 'subject' => $thread->subject()])) - ->action(__('Afficher'), url($thread->getPathUrl()."#reply-{$this->reply->id}")) - ->line(__('Merci d\'utiliser Laravel Cameroun!')); + ->subject(__('Nouvelle mention: :subject', ['subject' => $thread->subject()])) + ->line(__(':name vous a mentionné dans le sujet :subject', ['name' => $this->reply->user?->name, 'subject' => $thread->subject()])) + ->action(__('Afficher'), url($thread->getPathUrl()."#reply-{$this->reply->id}")) + ->line(__('Merci d\'utiliser Laravel Cameroun!')); } - /** - * @return array - */ public function toArray(): array { return [ diff --git a/app/Policies/ArticlePolicy.php b/app/Policies/ArticlePolicy.php index ff53d03f..c5a1efb0 100644 --- a/app/Policies/ArticlePolicy.php +++ b/app/Policies/ArticlePolicy.php @@ -7,7 +7,7 @@ use App\Models\Article; use App\Models\User; -class ArticlePolicy +final class ArticlePolicy { public const UPDATE = 'update'; diff --git a/app/Policies/DiscussionPolicy.php b/app/Policies/DiscussionPolicy.php index f1a35c60..4d120452 100644 --- a/app/Policies/DiscussionPolicy.php +++ b/app/Policies/DiscussionPolicy.php @@ -7,7 +7,7 @@ use App\Models\Discussion; use App\Models\User; -class DiscussionPolicy +final class DiscussionPolicy { public const UPDATE = 'update'; diff --git a/app/Policies/NotificationPolicy.php b/app/Policies/NotificationPolicy.php index a8d9e971..1ebaa09a 100644 --- a/app/Policies/NotificationPolicy.php +++ b/app/Policies/NotificationPolicy.php @@ -7,13 +7,10 @@ use App\Models\User; use Illuminate\Notifications\DatabaseNotification; -class NotificationPolicy +final class NotificationPolicy { public const MARK_AS_READ = 'markAsRead'; - /** - * Determine if the given notification can be marked as read by the user. - */ public function markAsRead(User $user, DatabaseNotification $notification): bool { return $notification->notifiable->is($user); diff --git a/app/Policies/ReplyPolicy.php b/app/Policies/ReplyPolicy.php index 3874153c..5b4521c7 100644 --- a/app/Policies/ReplyPolicy.php +++ b/app/Policies/ReplyPolicy.php @@ -7,7 +7,7 @@ use App\Models\Reply; use App\Models\User; -class ReplyPolicy +final class ReplyPolicy { public const CREATE = 'create'; @@ -15,25 +15,16 @@ class ReplyPolicy public const DELETE = 'delete'; - /** - * Determine if replies can be created by the user. - */ public function create(User $user): bool { return $user->hasVerifiedEmail(); } - /** - * Determine if the given reply can be updated by the user. - */ public function update(User $user, Reply $reply): bool { return $reply->isAuthoredBy($user) || $user->isModerator() || $user->isAdmin(); } - /** - * Determine if the given reply can be deleted by the user. - */ public function delete(User $user, Reply $reply): bool { return $reply->isAuthoredBy($user) || $user->isModerator() || $user->isAdmin(); diff --git a/app/Policies/ThreadPolicy.php b/app/Policies/ThreadPolicy.php index c9695fba..1e8d8894 100644 --- a/app/Policies/ThreadPolicy.php +++ b/app/Policies/ThreadPolicy.php @@ -7,7 +7,7 @@ use App\Models\Thread; use App\Models\User; -class ThreadPolicy +final class ThreadPolicy { public const UPDATE = 'update'; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 10561878..26aedc43 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -49,9 +49,9 @@ public function boot(): void public function registerBladeDirective(): void { - Blade::directive('title', fn ($expression) => ""); - Blade::directive('shareImage', fn ($expression) => ""); - Blade::directive('canonical', fn ($expression) => ""); + Blade::directive('title', fn ($expression) => ""); + Blade::directive('shareImage', fn ($expression) => ""); + Blade::directive('canonical', fn ($expression) => ""); } public function bootMacros(): void @@ -88,7 +88,7 @@ public function bootEloquentMorphs(): void public function bootFilament(): void { - Filament::serving(function () { + Filament::serving(function (): void { Filament::registerTheme( mix('css/filament.css'), ); diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.php index a46d7fee..ef49a264 100644 --- a/app/Providers/FortifyServiceProvider.php +++ b/app/Providers/FortifyServiceProvider.php @@ -34,12 +34,8 @@ public function boot(): void Fortify::updateUserPasswordsUsing(UpdateUserPassword::class); Fortify::resetUserPasswordsUsing(ResetUserPassword::class); - RateLimiter::for('login', function (Request $request) { - return Limit::perMinute(5)->by($request->email.$request->ip()); - }); + RateLimiter::for('login', fn (Request $request) => Limit::perMinute(5)->by($request->email.$request->ip())); - RateLimiter::for('two-factor', function (Request $request) { - return Limit::perMinute(5)->by($request->session()->get('login.id')); - }); + RateLimiter::for('two-factor', fn (Request $request) => Limit::perMinute(5)->by($request->session()->get('login.id'))); } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 8e0afe74..7abdbe13 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -21,7 +21,7 @@ public function boot(): void $this->routeBindings(); - $this->routes(function () { + $this->routes(function (): void { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) @@ -32,7 +32,7 @@ public function boot(): void ->group(base_path('routes/web.php')); }); - Route::macro('redirectMap', function (array $map, int $status = 302) { + Route::macro('redirectMap', function (array $map, int $status = 302): void { foreach ($map as $old => $new) { Route::redirect($old, $new, $status)->name($old); } diff --git a/app/Spotlight/Article.php b/app/Spotlight/Article.php index 5cc43c4c..ffa0980e 100644 --- a/app/Spotlight/Article.php +++ b/app/Spotlight/Article.php @@ -12,15 +12,12 @@ use LivewireUI\Spotlight\SpotlightCommandDependency; use LivewireUI\Spotlight\SpotlightSearchResult; -class Article extends SpotlightCommand +final class Article extends SpotlightCommand { protected string $name = 'Article'; protected string $description = 'rechercher un article spécifique'; - /** - * @var string[] - */ protected array $synonyms = []; public function dependencies(): ?SpotlightCommandDependencies @@ -36,7 +33,7 @@ public function searchArticle(string $query): Collection { return ArticleModel::published() ->with('user') - ->where('title', 'like', "%$query%") + ->where('title', 'like', "%{$query}%") ->get() ->map(fn (ArticleModel $article) => new SpotlightSearchResult( $article->slug(), diff --git a/app/Spotlight/Articles.php b/app/Spotlight/Articles.php index ab52c6bd..07c97c99 100644 --- a/app/Spotlight/Articles.php +++ b/app/Spotlight/Articles.php @@ -7,15 +7,12 @@ use LivewireUI\Spotlight\Spotlight; use LivewireUI\Spotlight\SpotlightCommand; -class Articles extends SpotlightCommand +final class Articles extends SpotlightCommand { protected string $name = 'Articles'; protected string $description = 'aller à la page des articles'; - /** - * @var string[] - */ protected array $synonyms = [ 'articles', 'article', diff --git a/app/Spotlight/Discussion.php b/app/Spotlight/Discussion.php index a2279f03..04879e59 100644 --- a/app/Spotlight/Discussion.php +++ b/app/Spotlight/Discussion.php @@ -12,15 +12,12 @@ use LivewireUI\Spotlight\SpotlightCommandDependency; use LivewireUI\Spotlight\SpotlightSearchResult; -class Discussion extends SpotlightCommand +final class Discussion extends SpotlightCommand { protected string $name = 'Discussion'; protected string $description = 'rechercher une discussion spécifique'; - /** - * @var string[] - */ protected array $synonyms = []; public function dependencies(): ?SpotlightCommandDependencies @@ -35,7 +32,7 @@ public function dependencies(): ?SpotlightCommandDependencies public function searchDiscussion(string $query): Collection { return DiscussionModel::with('user') - ->where('title', 'like', "%$query%") + ->where('title', 'like', "%{$query}%") ->get() ->map(fn (DiscussionModel $discussion) => new SpotlightSearchResult( $discussion->slug(), diff --git a/app/Spotlight/Discussions.php b/app/Spotlight/Discussions.php index 6778c979..ac9dfb1b 100644 --- a/app/Spotlight/Discussions.php +++ b/app/Spotlight/Discussions.php @@ -7,15 +7,12 @@ use LivewireUI\Spotlight\Spotlight; use LivewireUI\Spotlight\SpotlightCommand; -class Discussions extends SpotlightCommand +final class Discussions extends SpotlightCommand { protected string $name = 'Discussions'; protected string $description = 'aller à la page des discussions'; - /** - * @var string[] - */ protected array $synonyms = [ 'débat', 'conversation', diff --git a/app/Spotlight/FAQs.php b/app/Spotlight/FAQs.php index fee692fb..4089dfe3 100644 --- a/app/Spotlight/FAQs.php +++ b/app/Spotlight/FAQs.php @@ -7,15 +7,12 @@ use LivewireUI\Spotlight\Spotlight; use LivewireUI\Spotlight\SpotlightCommand; -class FAQs extends SpotlightCommand +final class FAQs extends SpotlightCommand { protected string $name = 'FAQs'; protected string $description = 'aller à la page des questions'; - /** - * @var string[] - */ protected array $synonyms = [ 'faq', 'question', diff --git a/app/Spotlight/Forum.php b/app/Spotlight/Forum.php index 78ab9310..a143a5e4 100644 --- a/app/Spotlight/Forum.php +++ b/app/Spotlight/Forum.php @@ -7,15 +7,12 @@ use LivewireUI\Spotlight\Spotlight; use LivewireUI\Spotlight\SpotlightCommand; -class Forum extends SpotlightCommand +final class Forum extends SpotlightCommand { protected string $name = 'Forum'; protected string $description = 'aller sur le forum'; - /** - * @var string[] - */ protected array $synonyms = [ 'question', 'thread', diff --git a/app/Spotlight/Guides.php b/app/Spotlight/Guides.php index 6119535b..894407a6 100644 --- a/app/Spotlight/Guides.php +++ b/app/Spotlight/Guides.php @@ -7,15 +7,12 @@ use LivewireUI\Spotlight\Spotlight; use LivewireUI\Spotlight\SpotlightCommand; -class Guides extends SpotlightCommand +final class Guides extends SpotlightCommand { protected string $name = 'Guides'; protected string $description = 'aller à la page du code de conduite'; - /** - * @var string[] - */ protected array $synonyms = [ 'code', 'conduite', diff --git a/app/Spotlight/Slack.php b/app/Spotlight/Slack.php index 2ba29115..d0855429 100644 --- a/app/Spotlight/Slack.php +++ b/app/Spotlight/Slack.php @@ -7,15 +7,12 @@ use LivewireUI\Spotlight\Spotlight; use LivewireUI\Spotlight\SpotlightCommand; -class Slack extends SpotlightCommand +final class Slack extends SpotlightCommand { protected string $name = 'Slack'; protected string $description = 'rejoindre le Slack de Laravel Cameroun'; - /** - * @var string[] - */ protected array $synonyms = [ 'community', 'join', diff --git a/app/Spotlight/Sujet.php b/app/Spotlight/Sujet.php index 78d28baf..6f33416f 100644 --- a/app/Spotlight/Sujet.php +++ b/app/Spotlight/Sujet.php @@ -12,15 +12,12 @@ use LivewireUI\Spotlight\SpotlightCommandDependency; use LivewireUI\Spotlight\SpotlightSearchResult; -class Sujet extends SpotlightCommand +final class Sujet extends SpotlightCommand { protected string $name = 'Sujet'; protected string $description = 'Rechercher un sujet dans le forum'; - /** - * @var string[] - */ protected array $synonyms = [ 'topic', 'sujet', @@ -40,7 +37,7 @@ public function dependencies(): ?SpotlightCommandDependencies public function searchThread(string $query): Collection { return Thread::with('user') - ->where('title', 'like', "%$query%") + ->where('title', 'like', "%{$query}%") ->get() ->map(fn (Thread $thread) => new SpotlightSearchResult( $thread->slug(), diff --git a/app/Spotlight/Telegram.php b/app/Spotlight/Telegram.php index 3d7e66bd..0916297c 100644 --- a/app/Spotlight/Telegram.php +++ b/app/Spotlight/Telegram.php @@ -7,15 +7,12 @@ use LivewireUI\Spotlight\Spotlight; use LivewireUI\Spotlight\SpotlightCommand; -class Telegram extends SpotlightCommand +final class Telegram extends SpotlightCommand { protected string $name = 'Telegram'; protected string $description = 'rejoindre le groupe sur Telegram'; - /** - * @var string[] - */ protected array $synonyms = [ 'channels', 'community', diff --git a/app/Spotlight/User.php b/app/Spotlight/User.php index 20fe9f77..454be24b 100644 --- a/app/Spotlight/User.php +++ b/app/Spotlight/User.php @@ -12,15 +12,12 @@ use LivewireUI\Spotlight\SpotlightCommandDependency; use LivewireUI\Spotlight\SpotlightSearchResult; -class User extends SpotlightCommand +final class User extends SpotlightCommand { protected string $name = 'User'; protected string $description = 'rechercher un utilisateur spécifique'; - /** - * @var string[] - */ protected array $synonyms = []; public function dependencies(): ?SpotlightCommandDependencies @@ -34,8 +31,8 @@ public function dependencies(): ?SpotlightCommandDependencies public function searchUser(string $query): Collection { - return UserModel::where('name', 'like', "%$query%") - ->orWhere('username', 'like', "%$query%") + return UserModel::where('name', 'like', "%{$query}%") + ->orWhere('username', 'like', "%{$query}%") ->get() ->map(fn (UserModel $user) => new SpotlightSearchResult( $user->id, diff --git a/app/Traits/HasProfilePhoto.php b/app/Traits/HasProfilePhoto.php index b26ec083..bdac46f7 100644 --- a/app/Traits/HasProfilePhoto.php +++ b/app/Traits/HasProfilePhoto.php @@ -10,11 +10,11 @@ trait HasProfilePhoto { public function getProfilePhotoUrlAttribute(): ?string { - if ($this->avatar_type === 'storage') { + if ('storage' === $this->avatar_type) { return $this->getFirstMediaUrl('avatar'); } - if (! in_array($this->avatar_type, ['avatar', 'storage'])) { + if ( ! in_array($this->avatar_type, ['avatar', 'storage'])) { /** @var SocialAccount $social_avatar */ $social_avatar = $this->providers->firstWhere('provider', $this->avatar_type); // @phpstan-ignore-next-line diff --git a/app/Traits/HasTags.php b/app/Traits/HasTags.php index cdc6664e..a82f3ac3 100644 --- a/app/Traits/HasTags.php +++ b/app/Traits/HasTags.php @@ -30,7 +30,7 @@ public function removeTags(): void public function scopeForTag(Builder $query, string $tag): Builder { - return $query->whereHas('tags', function ($query) use ($tag) { + return $query->whereHas('tags', function ($query) use ($tag): void { $query->where('tags.slug', $tag); }); } diff --git a/app/Traits/Reactable.php b/app/Traits/Reactable.php index 70e3914d..c95a9095 100644 --- a/app/Traits/Reactable.php +++ b/app/Traits/Reactable.php @@ -29,7 +29,7 @@ public function getReactionsSummary(): Collection public function reacted(User $responder = null): bool { - if (is_null($responder)) { + if (null === $responder) { /** @var User $responder */ $responder = auth()->user(); } diff --git a/app/Traits/Reacts.php b/app/Traits/Reacts.php index 9447299c..f155652b 100644 --- a/app/Traits/Reacts.php +++ b/app/Traits/Reacts.php @@ -27,7 +27,7 @@ public function reactTo(ReactableInterface $reactable, Reaction $reaction): ?Rea 'responder_id' => $this->getKey(), ])->first(); - if (! $reacted && ($currentReactedName !== $reaction->name)) { + if ( ! $reacted && ($currentReactedName !== $reaction->name)) { return $this->storeReaction($reactable, $reaction); } diff --git a/app/Traits/RecordsActivity.php b/app/Traits/RecordsActivity.php index 664b3a0f..12af2971 100644 --- a/app/Traits/RecordsActivity.php +++ b/app/Traits/RecordsActivity.php @@ -6,6 +6,7 @@ use App\Models\Activity; use Illuminate\Database\Eloquent\Relations\MorphMany; +use ReflectionClass; trait RecordsActivity { @@ -16,12 +17,12 @@ protected static function bootRecordsActivity(): void } foreach (static::getActivitiesToRecord() as $event) { - static::$event(function ($model) use ($event) { + static::$event(function ($model) use ($event): void { $model->recordActivity($event); }); } - static::deleting(function ($model) { + static::deleting(function ($model): void { $model->activity()->delete(); }); } @@ -56,7 +57,7 @@ public function activity(): MorphMany protected function getActivityType(string $event): string { - $type = strtolower((new \ReflectionClass($this))->getShortName()); + $type = mb_strtolower((new ReflectionClass($this))->getShortName()); return "{$event}_{$type}"; } diff --git a/app/Traits/WithChannelsAssociation.php b/app/Traits/WithChannelsAssociation.php index 12c56382..411c28a2 100644 --- a/app/Traits/WithChannelsAssociation.php +++ b/app/Traits/WithChannelsAssociation.php @@ -21,7 +21,7 @@ trait WithChannelsAssociation */ public function updatedChannelsSelected(array $choices): void { - if (! in_array($choices['value'], $this->associateChannels)) { + if ( ! in_array($choices['value'], $this->associateChannels)) { $this->associateChannels[] = (int) $choices['value']; } else { $key = array_search($choices['value'], $this->associateChannels); diff --git a/app/Traits/WithTagsAssociation.php b/app/Traits/WithTagsAssociation.php index 039ea7f2..63a021bd 100644 --- a/app/Traits/WithTagsAssociation.php +++ b/app/Traits/WithTagsAssociation.php @@ -21,7 +21,7 @@ trait WithTagsAssociation */ public function updatedTagsSelected(array $choices): void { - if (! in_array($choices['value'], $this->associateTags)) { + if ( ! in_array($choices['value'], $this->associateTags)) { $this->associateTags[] = (int) $choices['value']; } else { $key = array_search((int) $choices['value'], $this->associateTags); diff --git a/app/View/Components/SettingsLayout.php b/app/View/Components/SettingsLayout.php index 50939cc4..63c9393c 100644 --- a/app/View/Components/SettingsLayout.php +++ b/app/View/Components/SettingsLayout.php @@ -4,16 +4,12 @@ namespace App\View\Components; +use Illuminate\Contracts\View\View; use Illuminate\View\Component; -class SettingsLayout extends Component +final class SettingsLayout extends Component { - /** - * Get the view / contents that represent the component. - * - * @return \Illuminate\Contracts\View\View|\Closure|string - */ - public function render() + public function render(): View { return view('layouts.settings'); } diff --git a/app/View/Composers/InactiveDiscussionsComposer.php b/app/View/Composers/InactiveDiscussionsComposer.php index 14759f34..0853aadd 100644 --- a/app/View/Composers/InactiveDiscussionsComposer.php +++ b/app/View/Composers/InactiveDiscussionsComposer.php @@ -12,9 +12,7 @@ final class InactiveDiscussionsComposer { public function compose(View $view): void { - $discussions = Cache::remember('inactive_discussions', now()->addDays(3), function () { - return Discussion::noComments()->limit(5)->get(); - }); + $discussions = Cache::remember('inactive_discussions', now()->addDays(3), fn () => Discussion::noComments()->limit(5)->get()); $view->with('discussions', $discussions); } diff --git a/app/View/Composers/ModeratorsComposer.php b/app/View/Composers/ModeratorsComposer.php index a8ac073f..7e6d8c44 100644 --- a/app/View/Composers/ModeratorsComposer.php +++ b/app/View/Composers/ModeratorsComposer.php @@ -12,8 +12,6 @@ final class ModeratorsComposer { public function compose(View $view): void { - $view->with('moderators', Cache::remember('moderators', now()->addYear(), function () { - return User::moderators()->get(); - })); + $view->with('moderators', Cache::remember('moderators', now()->addYear(), fn () => User::moderators()->get())); } } diff --git a/app/View/Composers/ProfileUsersComposer.php b/app/View/Composers/ProfileUsersComposer.php index b2dbfc38..22de2fff 100644 --- a/app/View/Composers/ProfileUsersComposer.php +++ b/app/View/Composers/ProfileUsersComposer.php @@ -12,8 +12,6 @@ final class ProfileUsersComposer { public function compose(View $view): void { - $view->with('users', Cache::remember('avatar_users', now()->addWeek(), function () { - return User::verifiedUsers()->inRandomOrder()->take(10)->get(); - })); + $view->with('users', Cache::remember('avatar_users', now()->addWeek(), fn () => User::verifiedUsers()->inRandomOrder()->take(10)->get())); } } diff --git a/app/View/Composers/TopMembersComposer.php b/app/View/Composers/TopMembersComposer.php index a7c2057d..3f4572ec 100644 --- a/app/View/Composers/TopMembersComposer.php +++ b/app/View/Composers/TopMembersComposer.php @@ -12,8 +12,6 @@ final class TopMembersComposer { public function compose(View $view): void { - $view->with('topMembers', Cache::remember('topMembers', now()->addWeek(), function () { - return User::mostSolutionsInLastDays(365)->take(5)->get(); - })); + $view->with('topMembers', Cache::remember('topMembers', now()->addWeek(), fn () => User::mostSolutionsInLastDays(365)->take(5)->get())); } } diff --git a/app/Widgets/RecentNumbers.php b/app/Widgets/RecentNumbers.php index 69dd43bb..4b8f6a59 100644 --- a/app/Widgets/RecentNumbers.php +++ b/app/Widgets/RecentNumbers.php @@ -12,9 +12,6 @@ final class RecentNumbers extends AbstractWidget { - /** - * @var array - */ protected $config = []; /** diff --git a/app/helpers.php b/app/helpers.php index 9ce497a5..3e885f3b 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -6,7 +6,7 @@ use Illuminate\Support\Facades\Auth; use League\CommonMark\Output\RenderedContentInterface; -if (! function_exists('active')) { +if ( ! function_exists('active')) { /** * @param array $routes * @param string $activeClass @@ -20,7 +20,7 @@ function active(array $routes, string $activeClass = 'active', string $defaultCl } } -if (! function_exists('is_active')) { +if ( ! function_exists('is_active')) { /** * Determines if the given routes are active. */ @@ -30,14 +30,14 @@ function is_active(string ...$routes): bool } } -if (! function_exists('md_to_html')) { +if ( ! function_exists('md_to_html')) { function md_to_html(string $markdown): RenderedContentInterface { return Markdown::convert($markdown); } } -if (! function_exists('replace_links')) { +if ( ! function_exists('replace_links')) { function replace_links(string $markdown): string { return (new LinkFinder([ @@ -46,7 +46,7 @@ function replace_links(string $markdown): string } } -if (! function_exists('get_current_theme')) { +if ( ! function_exists('get_current_theme')) { function get_current_theme(): string { return Auth::user() ? @@ -55,7 +55,7 @@ function get_current_theme(): string } } -if (! function_exists('canonical')) { +if ( ! function_exists('canonical')) { /** * @param string $route * @param array $params @@ -64,7 +64,7 @@ function get_current_theme(): string function canonical(string $route, array $params = []): string { $page = app('request')->get('page'); - $params = array_merge($params, ['page' => $page != 1 ? $page : null]); + $params = array_merge($params, ['page' => 1 !== $page ? $page : null]); ksort($params); @@ -72,7 +72,7 @@ function canonical(string $route, array $params = []): string } } -if (! function_exists('getFilter')) { +if ( ! function_exists('getFilter')) { /** * @param string $key * @param array $filters @@ -87,7 +87,7 @@ function getFilter(string $key, array $filters = [], string $default = 'recent') } } -if (! function_exists('route_to_reply_able')) { +if ( ! function_exists('route_to_reply_able')) { /** * Returns the route for the replyAble. * diff --git a/composer.json b/composer.json index bfbb67c5..13dd68c5 100644 --- a/composer.json +++ b/composer.json @@ -134,6 +134,7 @@ } }, "prefer-stable": true, + "minimum-stability": "dev", "repositories": [ { "type": "vcs", diff --git a/config/blade-ui-kit.php b/config/blade-ui-kit.php index 8ee02b89..96b4be9d 100644 --- a/config/blade-ui-kit.php +++ b/config/blade-ui-kit.php @@ -57,7 +57,7 @@ */ 'livewire' => [ - // + ], /* diff --git a/config/telescope.php b/config/telescope.php index f287ae82..f26ea081 100644 --- a/config/telescope.php +++ b/config/telescope.php @@ -102,7 +102,7 @@ ], 'ignore_commands' => [ - // + ], /* diff --git a/database/factories/ActivityFactory.php b/database/factories/ActivityFactory.php index b394f9c6..3000df7d 100644 --- a/database/factories/ActivityFactory.php +++ b/database/factories/ActivityFactory.php @@ -10,19 +10,14 @@ /** * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Activity> */ -class ActivityFactory extends Factory +final class ActivityFactory extends Factory { protected $model = Activity::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition(): array { return [ - // + ]; } } diff --git a/database/factories/ArticleFactory.php b/database/factories/ArticleFactory.php index 7e5f379f..35f60bbd 100644 --- a/database/factories/ArticleFactory.php +++ b/database/factories/ArticleFactory.php @@ -8,20 +8,10 @@ use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; -class ArticleFactory extends Factory +final class ArticleFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string - */ protected $model = Article::class; - /** - * Define the model's default state. - * - * @return array - */ public function definition(): array { return [ diff --git a/database/factories/ChannelFactory.php b/database/factories/ChannelFactory.php index b120201b..e05e4064 100644 --- a/database/factories/ChannelFactory.php +++ b/database/factories/ChannelFactory.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Factories\Factory; -class ChannelFactory extends Factory +final class ChannelFactory extends Factory { public function definition(): array { diff --git a/database/factories/DiscussionFactory.php b/database/factories/DiscussionFactory.php index e1bc4afe..9f096400 100644 --- a/database/factories/DiscussionFactory.php +++ b/database/factories/DiscussionFactory.php @@ -7,13 +7,8 @@ use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; -class DiscussionFactory extends Factory +final class DiscussionFactory extends Factory { - /** - * Define the model's default state. - * - * @return array - */ public function definition(): array { return [ diff --git a/database/factories/EnterpriseFactory.php b/database/factories/EnterpriseFactory.php index c600653a..9ea02ac9 100644 --- a/database/factories/EnterpriseFactory.php +++ b/database/factories/EnterpriseFactory.php @@ -11,13 +11,8 @@ /** * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Enterprise> */ -class EnterpriseFactory extends Factory +final class EnterpriseFactory extends Factory { - /** - * Define the model's default state. - * - * @return array - */ public function definition(): array { return [ @@ -38,7 +33,7 @@ public function definition(): array public function configure(): self { - return $this->afterCreating(function (Enterprise $enterprise) { + return $this->afterCreating(function (Enterprise $enterprise): void { $enterprise->addMediaFromUrl("https://source.unsplash.com/random/800x800/?img={$enterprise->id}") ->toMediaCollection('logo'); }); diff --git a/database/factories/ReplyFactory.php b/database/factories/ReplyFactory.php index 377e99a1..b243a8d3 100644 --- a/database/factories/ReplyFactory.php +++ b/database/factories/ReplyFactory.php @@ -8,7 +8,7 @@ use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; -class ReplyFactory extends Factory +final class ReplyFactory extends Factory { public function definition(): array { diff --git a/database/factories/TagFactory.php b/database/factories/TagFactory.php index 2801b96c..fec88225 100644 --- a/database/factories/TagFactory.php +++ b/database/factories/TagFactory.php @@ -7,21 +7,11 @@ use App\Models\Tag; use Illuminate\Database\Eloquent\Factories\Factory; -class TagFactory extends Factory +final class TagFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string - */ protected $model = Tag::class; - /** - * Define the model's default state. - * - * @return array - */ - public function definition() + public function definition(): array { return [ 'name' => $this->faker->text(15), diff --git a/database/factories/ThreadFactory.php b/database/factories/ThreadFactory.php index 38f2423b..dbfaad8e 100644 --- a/database/factories/ThreadFactory.php +++ b/database/factories/ThreadFactory.php @@ -7,7 +7,7 @@ use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; -class ThreadFactory extends Factory +final class ThreadFactory extends Factory { public function definition(): array { diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 1b49242b..db31df50 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -8,21 +8,11 @@ use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; -class UserFactory extends Factory +final class UserFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string - */ protected $model = User::class; - /** - * Define the model's default state. - * - * @return array - */ - public function definition() + public function definition(): array { return [ 'name' => $this->faker->name(), @@ -34,12 +24,7 @@ public function definition() ]; } - /** - * Indicate that the model's email address should be unverified. - * - * @return \Illuminate\Database\Eloquent\Factories\Factory - */ - public function unverified() + public function unverified(): self { return $this->state(function (array $attributes) { return [ @@ -48,12 +33,7 @@ public function unverified() }); } - /** - * Indicate that the model's created_at should be last month. - * - * @return \Illuminate\Database\Eloquent\Factories\Factory - */ - public function lastMonth() + public function lastMonth(): self { return $this->state(function (array $attributes) { return [ diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 3c86977f..7b41e0b4 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateUsersTable extends Migration +final class CreateUsersTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('users', function (Blueprint $table) { + Schema::create('users', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->string('email')->unique()->index(); @@ -39,12 +34,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('users'); } diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 32958b12..d0a65406 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -6,28 +6,18 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreatePasswordResetsTable extends Migration +final class CreatePasswordResetsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('password_resets', function (Blueprint $table) { + Schema::create('password_resets', function (Blueprint $table): void { $table->string('email')->index(); $table->string('token'); $table->timestamp('created_at')->nullable(); }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('password_resets'); } diff --git a/database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php b/database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php index 4e2d0533..630614ed 100644 --- a/database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php +++ b/database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php @@ -6,34 +6,24 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class AddTwoFactorColumnsToUsersTable extends Migration +final class AddTwoFactorColumnsToUsersTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->text('two_factor_secret') - ->after('password') - ->nullable(); + ->after('password') + ->nullable(); $table->text('two_factor_recovery_codes') - ->after('two_factor_secret') - ->nullable(); + ->after('two_factor_secret') + ->nullable(); }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->dropColumn('two_factor_secret', 'two_factor_recovery_codes'); }); } diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index cb397212..22c7b044 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateFailedJobsTable extends Migration +final class CreateFailedJobsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('failed_jobs', function (Blueprint $table) { + Schema::create('failed_jobs', function (Blueprint $table): void { $table->id(); $table->string('uuid')->unique(); $table->text('connection'); @@ -26,12 +21,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('failed_jobs'); } diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php index 4b21be97..93ca2c87 100644 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -7,14 +7,9 @@ use Illuminate\Support\Facades\Schema; return new class () extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('personal_access_tokens', function (Blueprint $table) { + Schema::create('personal_access_tokens', function (Blueprint $table): void { $table->id(); $table->morphs('tokenable'); $table->string('name'); @@ -26,12 +21,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('personal_access_tokens'); } diff --git a/database/migrations/2021_06_05_182615_create_social_accounts_table.php b/database/migrations/2021_06_05_182615_create_social_accounts_table.php index 2c46894d..19a14ed6 100644 --- a/database/migrations/2021_06_05_182615_create_social_accounts_table.php +++ b/database/migrations/2021_06_05_182615_create_social_accounts_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateSocialAccountsTable extends Migration +final class CreateSocialAccountsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('social_accounts', function (Blueprint $table) { + Schema::create('social_accounts', function (Blueprint $table): void { $table->id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->string('provider', 32); @@ -26,12 +21,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('social_accounts'); } diff --git a/database/migrations/2021_07_29_164019_create_tags_table.php b/database/migrations/2021_07_29_164019_create_tags_table.php index 1136e4a0..e3545113 100644 --- a/database/migrations/2021_07_29_164019_create_tags_table.php +++ b/database/migrations/2021_07_29_164019_create_tags_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateTagsTable extends Migration +final class CreateTagsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('tags', function (Blueprint $table) { + Schema::create('tags', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->string('slug'); @@ -23,18 +18,13 @@ public function up() $table->json('concerns'); }); - Schema::create('taggables', function (Blueprint $table) { + Schema::create('taggables', function (Blueprint $table): void { $table->foreignId('tag_id'); $table->morphs('taggable'); }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('taggables'); Schema::dropIfExists('tags'); diff --git a/database/migrations/2021_08_18_115000_create_articles_table.php b/database/migrations/2021_08_18_115000_create_articles_table.php index 84857732..3def812e 100644 --- a/database/migrations/2021_08_18_115000_create_articles_table.php +++ b/database/migrations/2021_08_18_115000_create_articles_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateArticlesTable extends Migration +final class CreateArticlesTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('articles', function (Blueprint $table) { + Schema::create('articles', function (Blueprint $table): void { $table->id(); $table->string('title'); $table->text('body'); @@ -35,12 +30,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('articles'); } diff --git a/database/migrations/2021_09_14_172248_create_permission_tables.php b/database/migrations/2021_09_14_172248_create_permission_tables.php index 8dd85c34..47f05484 100644 --- a/database/migrations/2021_09_14_172248_create_permission_tables.php +++ b/database/migrations/2021_09_14_172248_create_permission_tables.php @@ -7,14 +7,9 @@ use Illuminate\Support\Facades\Schema; use Spatie\Permission\PermissionRegistrar; -class CreatePermissionTables extends Migration +final class CreatePermissionTables extends Migration { - /* - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { $tableNames = config('permission.table_names'); $columnNames = config('permission.column_names'); @@ -27,7 +22,7 @@ public function up() throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.'); } - Schema::create($tableNames['permissions'], function (Blueprint $table) { + Schema::create($tableNames['permissions'], function (Blueprint $table): void { $table->bigIncrements('id'); $table->string('name'); // For MySQL 8.0 use string('name', 125); $table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125); @@ -36,7 +31,7 @@ public function up() $table->unique(['name', 'guard_name']); }); - Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) { + Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames): void { $table->bigIncrements('id'); if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable(); @@ -52,7 +47,7 @@ public function up() } }); - Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { + Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams): void { $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); $table->string('model_type'); @@ -79,7 +74,7 @@ public function up() } }); - Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) { + Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams): void { $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); $table->string('model_type'); @@ -106,7 +101,7 @@ public function up() } }); - Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) { + Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames): void { $table->unsignedBigInteger(PermissionRegistrar::$pivotPermission); $table->unsignedBigInteger(PermissionRegistrar::$pivotRole); @@ -124,16 +119,11 @@ public function up() }); app('cache') - ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) + ->store('default' !== config('permission.cache.store') ? config('permission.cache.store') : null) ->forget(config('permission.cache.key')); } - /* - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { $tableNames = config('permission.table_names'); diff --git a/database/migrations/2021_10_02_062027_create_reactions_table.php b/database/migrations/2021_10_02_062027_create_reactions_table.php index 5650bcc7..0c1e5220 100644 --- a/database/migrations/2021_10_02_062027_create_reactions_table.php +++ b/database/migrations/2021_10_02_062027_create_reactions_table.php @@ -6,28 +6,18 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateReactionsTable extends Migration +final class CreateReactionsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('reactions', function (Blueprint $table) { + Schema::create('reactions', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->timestamps(); }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('reactions'); } diff --git a/database/migrations/2021_10_02_062115_create_reactables_table.php b/database/migrations/2021_10_02_062115_create_reactables_table.php index d4ec603a..4511b875 100644 --- a/database/migrations/2021_10_02_062115_create_reactables_table.php +++ b/database/migrations/2021_10_02_062115_create_reactables_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateReactablesTable extends Migration +final class CreateReactablesTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('reactables', function (Blueprint $table) { + Schema::create('reactables', function (Blueprint $table): void { $table->id(); $table->foreignId('reaction_id')->constrained(); $table->morphs('reactable'); @@ -23,12 +18,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('reactables'); } diff --git a/database/migrations/2021_10_15_184151_create_media_table.php b/database/migrations/2021_10_15_184151_create_media_table.php index a10748ef..5388c164 100644 --- a/database/migrations/2021_10_15_184151_create_media_table.php +++ b/database/migrations/2021_10_15_184151_create_media_table.php @@ -6,11 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateMediaTable extends Migration +final class CreateMediaTable extends Migration { - public function up() + public function up(): void { - Schema::create('media', function (Blueprint $table) { + Schema::create('media', function (Blueprint $table): void { $table->bigIncrements('id'); $table->morphs('model'); @@ -32,7 +32,7 @@ public function up() }); } - public function down() + public function down(): void { Schema::dropIfExists('media'); } diff --git a/database/migrations/2021_10_15_184203_create_temporary_uploads_table.php b/database/migrations/2021_10_15_184203_create_temporary_uploads_table.php index 6c1b5a97..1946b879 100644 --- a/database/migrations/2021_10_15_184203_create_temporary_uploads_table.php +++ b/database/migrations/2021_10_15_184203_create_temporary_uploads_table.php @@ -6,18 +6,18 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateTemporaryUploadsTable extends Migration +final class CreateTemporaryUploadsTable extends Migration { - public function up() + public function up(): void { - Schema::create('temporary_uploads', function (Blueprint $table) { + Schema::create('temporary_uploads', function (Blueprint $table): void { $table->increments('id'); $table->string('session_id'); $table->timestamps(); }); } - public function down() + public function down(): void { Schema::dropIfExists('temporary_uploads'); } diff --git a/database/migrations/2021_10_19_220042_create_sessions_table.php b/database/migrations/2021_10_19_220042_create_sessions_table.php index 105af611..c6a33aea 100644 --- a/database/migrations/2021_10_19_220042_create_sessions_table.php +++ b/database/migrations/2021_10_19_220042_create_sessions_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateSessionsTable extends Migration +final class CreateSessionsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('sessions', function (Blueprint $table) { + Schema::create('sessions', function (Blueprint $table): void { $table->string('id')->primary(); $table->foreignId('user_id')->nullable()->index(); $table->string('ip_address', 45)->nullable(); @@ -25,12 +20,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('sessions'); } diff --git a/database/migrations/2021_11_01_153134_create_activities_table.php b/database/migrations/2021_11_01_153134_create_activities_table.php index 29811be5..71bf22ce 100644 --- a/database/migrations/2021_11_01_153134_create_activities_table.php +++ b/database/migrations/2021_11_01_153134_create_activities_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateActivitiesTable extends Migration +final class CreateActivitiesTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('activities', function (Blueprint $table) { + Schema::create('activities', function (Blueprint $table): void { $table->id(); $table->morphs('subject'); $table->string('type', 50); @@ -25,12 +20,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('activities'); } diff --git a/database/migrations/2021_11_04_094343_create_views_table.php b/database/migrations/2021_11_04_094343_create_views_table.php index a439868c..5b9b9a88 100644 --- a/database/migrations/2021_11_04_094343_create_views_table.php +++ b/database/migrations/2021_11_04_094343_create_views_table.php @@ -6,7 +6,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateViewsTable extends Migration +final class CreateViewsTable extends Migration { /** * The database schema. @@ -20,13 +20,8 @@ class CreateViewsTable extends Migration * * @var string */ - protected $table; + protected string $table; - /** - * Create a new migration instance. - * - * @return void - */ public function __construct() { $this->schema = Schema::connection( @@ -36,14 +31,9 @@ public function __construct() $this->table = config('eloquent-viewable.models.view.table_name'); } - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - $this->schema->create($this->table, function (Blueprint $table) { + $this->schema->create($this->table, function (Blueprint $table): void { $table->bigIncrements('id'); $table->morphs('viewable'); $table->text('visitor')->nullable(); @@ -52,12 +42,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists($this->table); } diff --git a/database/migrations/2021_11_05_132241_create_channels_table.php b/database/migrations/2021_11_05_132241_create_channels_table.php index 81e03219..d4731f55 100644 --- a/database/migrations/2021_11_05_132241_create_channels_table.php +++ b/database/migrations/2021_11_05_132241_create_channels_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateChannelsTable extends Migration +final class CreateChannelsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('channels', function (Blueprint $table) { + Schema::create('channels', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->string('slug')->unique(); @@ -25,12 +20,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('channels'); } diff --git a/database/migrations/2021_11_06_062351_create_threads_table.php b/database/migrations/2021_11_06_062351_create_threads_table.php index cf21863b..7d6535a7 100644 --- a/database/migrations/2021_11_06_062351_create_threads_table.php +++ b/database/migrations/2021_11_06_062351_create_threads_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateThreadsTable extends Migration +final class CreateThreadsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('threads', function (Blueprint $table) { + Schema::create('threads', function (Blueprint $table): void { $table->id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->string('title'); @@ -28,18 +23,13 @@ public function up() $table->timestamps(); }); - Schema::create('channel_thread', function (Blueprint $table) { + Schema::create('channel_thread', function (Blueprint $table): void { $table->foreignId('channel_id')->constrained(); $table->foreignId('thread_id')->constrained(); }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('channel_thread'); Schema::dropIfExists('threads'); diff --git a/database/migrations/2021_11_06_073610_create_replies_table.php b/database/migrations/2021_11_06_073610_create_replies_table.php index 95988e0f..fcc9c597 100644 --- a/database/migrations/2021_11_06_073610_create_replies_table.php +++ b/database/migrations/2021_11_06_073610_create_replies_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateRepliesTable extends Migration +final class CreateRepliesTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('replies', function (Blueprint $table) { + Schema::create('replies', function (Blueprint $table): void { $table->id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->morphs('replyable'); @@ -24,12 +19,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('replies'); } diff --git a/database/migrations/2021_11_11_084729_create_subscribes_table.php b/database/migrations/2021_11_11_084729_create_subscribes_table.php index 596c8ce4..f5aed4c2 100644 --- a/database/migrations/2021_11_11_084729_create_subscribes_table.php +++ b/database/migrations/2021_11_11_084729_create_subscribes_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateSubscribesTable extends Migration +final class CreateSubscribesTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('subscribes', function (Blueprint $table) { + Schema::create('subscribes', function (Blueprint $table): void { $table->uuid('uuid')->index()->unique(); $table->primary('uuid'); $table->foreignId('user_id')->index()->constrained(); @@ -25,12 +20,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('subscribes'); } diff --git a/database/migrations/2021_11_11_103416_create_notifications_table.php b/database/migrations/2021_11_11_103416_create_notifications_table.php index d5a1ed5a..e7d96b65 100644 --- a/database/migrations/2021_11_11_103416_create_notifications_table.php +++ b/database/migrations/2021_11_11_103416_create_notifications_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateNotificationsTable extends Migration +final class CreateNotificationsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('notifications', function (Blueprint $table) { + Schema::create('notifications', function (Blueprint $table): void { $table->uuid('id')->primary(); $table->string('type'); $table->morphs('notifiable'); @@ -25,12 +20,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('notifications'); } diff --git a/database/migrations/2021_11_16_191729_create_discussions_table.php b/database/migrations/2021_11_16_191729_create_discussions_table.php index f6b1c9ca..ce65076e 100644 --- a/database/migrations/2021_11_16_191729_create_discussions_table.php +++ b/database/migrations/2021_11_16_191729_create_discussions_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateDiscussionsTable extends Migration +final class CreateDiscussionsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::create('discussions', function (Blueprint $table) { + Schema::create('discussions', function (Blueprint $table): void { $table->id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->string('title'); @@ -27,12 +22,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('discussions'); } diff --git a/database/migrations/2021_11_29_114833_add_linkedin_profile_column_to_users_table.php b/database/migrations/2021_11_29_114833_add_linkedin_profile_column_to_users_table.php index 81be3d3c..917a64e4 100644 --- a/database/migrations/2021_11_29_114833_add_linkedin_profile_column_to_users_table.php +++ b/database/migrations/2021_11_29_114833_add_linkedin_profile_column_to_users_table.php @@ -6,30 +6,20 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class AddLinkedinProfileColumnToUsersTable extends Migration +final class AddLinkedinProfileColumnToUsersTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->string('linkedin_profile') ->after('twitter_profile') ->nullable(); }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->dropColumn('linkedin_profile'); }); } diff --git a/database/migrations/2022_01_15_201921_add_reputation_field_on_user_table.php b/database/migrations/2022_01_15_201921_add_reputation_field_on_user_table.php index f1efafbc..e6988be0 100644 --- a/database/migrations/2022_01_15_201921_add_reputation_field_on_user_table.php +++ b/database/migrations/2022_01_15_201921_add_reputation_field_on_user_table.php @@ -6,16 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class AddReputationFieldOnUserTable extends Migration +final class AddReputationFieldOnUserTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ public function up(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->unsignedInteger('reputation') ->nullable() ->default(0) @@ -23,14 +18,9 @@ public function up(): void }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down(): void { - Schema::table('users', function (Blueprint $table) { + Schema::table('users', function (Blueprint $table): void { $table->dropColumn('reputation'); }); } diff --git a/database/migrations/2022_01_15_201921_create_gamify_tables.php b/database/migrations/2022_01_15_201921_create_gamify_tables.php index fe1c14da..d3dbb8b4 100644 --- a/database/migrations/2022_01_15_201921_create_gamify_tables.php +++ b/database/migrations/2022_01_15_201921_create_gamify_tables.php @@ -6,17 +6,11 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateGamifyTables extends Migration +final class CreateGamifyTables extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() + public function up(): void { - // reputations table - Schema::create('reputations', function (Blueprint $table) { + Schema::create('reputations', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->mediumInteger('point', false)->default(0); @@ -27,8 +21,7 @@ public function up() $table->timestamps(); }); - // badges table - Schema::create('badges', function (Blueprint $table) { + Schema::create('badges', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->string('description')->nullable(); @@ -38,7 +31,7 @@ public function up() }); // user_badges pivot - Schema::create('user_badges', function (Blueprint $table) { + Schema::create('user_badges', function (Blueprint $table): void { $table->primary(['user_id', 'badge_id']); $table->unsignedBigInteger('user_id'); $table->unsignedBigInteger('badge_id'); @@ -46,12 +39,7 @@ public function up() }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() + public function down(): void { Schema::dropIfExists('user_badges'); Schema::dropIfExists('badges'); diff --git a/database/migrations/2022_06_17_065116_add_published_at_columns_on_posts_table.php b/database/migrations/2022_06_17_065116_add_published_at_columns_on_posts_table.php index 3d867f64..e375f64c 100644 --- a/database/migrations/2022_06_17_065116_add_published_at_columns_on_posts_table.php +++ b/database/migrations/2022_06_17_065116_add_published_at_columns_on_posts_table.php @@ -7,18 +7,18 @@ use Illuminate\Support\Facades\Schema; return new class () extends Migration { - public function up() + public function up(): void { - Schema::table('articles', function (Blueprint $table) { - $table->after('user_id', function ($table) { + Schema::table('articles', function (Blueprint $table): void { + $table->after('user_id', function ($table): void { $table->timestamp('published_at')->nullable(); }); }); } - public function down() + public function down(): void { - Schema::table('articles', function (Blueprint $table) { + Schema::table('articles', function (Blueprint $table): void { $table->removeColumn('published_at'); }); } diff --git a/database/migrations/2022_07_29_010135_create_jobs_table.php b/database/migrations/2022_07_29_010135_create_jobs_table.php index 07b9c070..eacf1e4d 100644 --- a/database/migrations/2022_07_29_010135_create_jobs_table.php +++ b/database/migrations/2022_07_29_010135_create_jobs_table.php @@ -7,14 +7,9 @@ use Illuminate\Support\Facades\Schema; return new class () extends Migration { - /** - * Run the migrations. - * - * @return void - */ public function up(): void { - Schema::create('jobs', function (Blueprint $table) { + Schema::create('jobs', function (Blueprint $table): void { $table->bigIncrements('id'); $table->string('queue')->index(); $table->longText('payload'); @@ -25,11 +20,6 @@ public function up(): void }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down(): void { Schema::dropIfExists('jobs'); diff --git a/database/migrations/2022_12_17_171538_create_enterprises_table.php b/database/migrations/2022_12_17_171538_create_enterprises_table.php index 408182c4..e7b50055 100644 --- a/database/migrations/2022_12_17_171538_create_enterprises_table.php +++ b/database/migrations/2022_12_17_171538_create_enterprises_table.php @@ -2,6 +2,8 @@ declare(strict_types=1); +use App\Enums\EnterpriseSize; +use App\Models\User; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -9,7 +11,7 @@ return new class () extends Migration { public function up(): void { - Schema::create('enterprises', function (Blueprint $table) { + Schema::create('enterprises', function (Blueprint $table): void { $table->id(); $table->string('name'); $table->string('slug')->unique(); @@ -19,16 +21,16 @@ public function up(): void $table->longText('about')->nullable(); $table->year('founded_in')->nullable(); $table->string('ceo')->nullable(); - $table->foreignIdFor(\App\Models\User::class); + $table->foreignIdFor(User::class); $table->boolean('is_certified')->default(false); $table->boolean('is_featured')->default(false); $table->boolean('is_public')->default(true); - $table->string('size')->default(\App\Enums\EnterpriseSize::SEED); + $table->string('size')->default(EnterpriseSize::SEED->value); $table->json('settings')->nullable(); $table->timestamps(); }); - Schema::create('enterprise_has_relations', function (Blueprint $table) { + Schema::create('enterprise_has_relations', function (Blueprint $table): void { $table->unsignedBigInteger('enterprise_id')->index(); $table->foreign('enterprise_id') ->references('id') @@ -38,11 +40,6 @@ public function up(): void }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down(): void { Schema::dropIfExists('enterprise_has_relations'); diff --git a/database/migrations/2023_05_06_154839_create_transactions_table.php b/database/migrations/2023_05_06_154839_create_transactions_table.php index 35b20642..e84be7c3 100644 --- a/database/migrations/2023_05_06_154839_create_transactions_table.php +++ b/database/migrations/2023_05_06_154839_create_transactions_table.php @@ -12,7 +12,7 @@ return new class () extends Migration { public function up(): void { - Schema::create('transactions', function (Blueprint $table) { + Schema::create('transactions', function (Blueprint $table): void { $table->uuid('id')->primary(); $table->string('type') ->default(TransactionType::ONETIME->value) diff --git a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183646_create_plans_table.php b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183646_create_plans_table.php index 6fe0a5fa..04ee1d24 100644 --- a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183646_create_plans_table.php +++ b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183646_create_plans_table.php @@ -5,16 +5,11 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; -class CreatePlansTable extends Migration +final class CreatePlansTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ public function up(): void { - Schema::create(config('rinvex.subscriptions.tables.plans'), function (Blueprint $table) { + Schema::create(config('rinvex.subscriptions.tables.plans'), function (Blueprint $table): void { // Columns $table->increments('id'); $table->string('slug'); @@ -44,11 +39,6 @@ public function up(): void }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down(): void { Schema::dropIfExists(config('rinvex.subscriptions.tables.plans')); diff --git a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183647_create_plan_features_table.php b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183647_create_plan_features_table.php index 29e4cdca..6892eab5 100644 --- a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183647_create_plan_features_table.php +++ b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183647_create_plan_features_table.php @@ -5,16 +5,11 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; -class CreatePlanFeaturesTable extends Migration +final class CreatePlanFeaturesTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ public function up(): void { - Schema::create(config('rinvex.subscriptions.tables.plan_features'), function (Blueprint $table) { + Schema::create(config('rinvex.subscriptions.tables.plan_features'), function (Blueprint $table): void { // Columns $table->increments('id'); $table->integer('plan_id')->unsigned(); @@ -31,15 +26,10 @@ public function up(): void // Indexes $table->unique(['plan_id', 'slug']); $table->foreign('plan_id')->references('id')->on(config('rinvex.subscriptions.tables.plans')) - ->onDelete('cascade')->onUpdate('cascade'); + ->onDelete('cascade')->onUpdate('cascade'); }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down(): void { Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_features')); diff --git a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183648_create_plan_subscriptions_table.php b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183648_create_plan_subscriptions_table.php index fe97d61b..96bf87f7 100644 --- a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183648_create_plan_subscriptions_table.php +++ b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183648_create_plan_subscriptions_table.php @@ -5,16 +5,11 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; -class CreatePlanSubscriptionsTable extends Migration +final class CreatePlanSubscriptionsTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ public function up(): void { - Schema::create(config('rinvex.subscriptions.tables.plan_subscriptions'), function (Blueprint $table) { + Schema::create(config('rinvex.subscriptions.tables.plan_subscriptions'), function (Blueprint $table): void { $table->increments('id'); $table->morphs('subscriber'); $table->integer('plan_id')->unsigned(); @@ -33,15 +28,10 @@ public function up(): void // Indexes $table->unique('slug'); $table->foreign('plan_id')->references('id')->on(config('rinvex.subscriptions.tables.plans')) - ->onDelete('cascade')->onUpdate('cascade'); + ->onDelete('cascade')->onUpdate('cascade'); }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down(): void { Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_subscriptions')); diff --git a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183649_create_plan_subscription_usage_table.php b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183649_create_plan_subscription_usage_table.php index 833eacdc..7b474098 100644 --- a/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183649_create_plan_subscription_usage_table.php +++ b/database/migrations/rinvex/laravel-subscriptions/2022_10_15_183649_create_plan_subscription_usage_table.php @@ -5,16 +5,11 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; -class CreatePlanSubscriptionUsageTable extends Migration +final class CreatePlanSubscriptionUsageTable extends Migration { - /** - * Run the migrations. - * - * @return void - */ public function up(): void { - Schema::create(config('rinvex.subscriptions.tables.plan_subscription_usage'), function (Blueprint $table) { + Schema::create(config('rinvex.subscriptions.tables.plan_subscription_usage'), function (Blueprint $table): void { $table->increments('id'); $table->integer('subscription_id')->unsigned(); $table->integer('feature_id')->unsigned(); @@ -26,17 +21,12 @@ public function up(): void $table->unique(['subscription_id', 'feature_id']); $table->foreign('subscription_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_subscriptions')) - ->onDelete('cascade')->onUpdate('cascade'); + ->onDelete('cascade')->onUpdate('cascade'); $table->foreign('feature_id')->references('id')->on(config('rinvex.subscriptions.tables.plan_features')) - ->onDelete('cascade')->onUpdate('cascade'); + ->onDelete('cascade')->onUpdate('cascade'); }); } - /** - * Reverse the migrations. - * - * @return void - */ public function down(): void { Schema::dropIfExists(config('rinvex.subscriptions.tables.plan_subscription_usage')); diff --git a/database/seeders/AddEnterpriseRoleSeeder.php b/database/seeders/AddEnterpriseRoleSeeder.php index 18b655c3..e66f8b48 100644 --- a/database/seeders/AddEnterpriseRoleSeeder.php +++ b/database/seeders/AddEnterpriseRoleSeeder.php @@ -7,7 +7,7 @@ use Illuminate\Database\Seeder; use Spatie\Permission\Models\Role; -class AddEnterpriseRoleSeeder extends Seeder +final class AddEnterpriseRoleSeeder extends Seeder { public function run(): void { diff --git a/database/seeders/ChannelSeeder.php b/database/seeders/ChannelSeeder.php index 99f96f9e..b22fcb93 100644 --- a/database/seeders/ChannelSeeder.php +++ b/database/seeders/ChannelSeeder.php @@ -7,7 +7,7 @@ use App\Models\Channel; use Illuminate\Database\Seeder; -class ChannelSeeder extends Seeder +final class ChannelSeeder extends Seeder { public function run(): void { diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 423c29e5..7d6016b7 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -7,7 +7,7 @@ use Illuminate\Database\Seeder; use Illuminate\Support\Facades\App; -class DatabaseSeeder extends Seeder +final class DatabaseSeeder extends Seeder { public function run(): void { @@ -20,7 +20,7 @@ public function run(): void $this->call(WorldSeeder::class); $this->call(FeatureTableSeeder::class); - if (! App::environment('production')) { + if ( ! App::environment('production')) { $this->call(UserSeeder::class); } } diff --git a/database/seeders/DeveloperPremiumPlanSeeder.php b/database/seeders/DeveloperPremiumPlanSeeder.php index 870192e9..b71ac22a 100644 --- a/database/seeders/DeveloperPremiumPlanSeeder.php +++ b/database/seeders/DeveloperPremiumPlanSeeder.php @@ -4,18 +4,19 @@ namespace Database\Seeders; +use App\Enums\PlanType; use App\Models\Premium\Feature; use App\Models\Premium\Plan; use Illuminate\Database\Seeder; -class DeveloperPremiumPlanSeeder extends Seeder +final class DeveloperPremiumPlanSeeder extends Seeder { public function run(): void { $rookiePlan = Plan::create([ 'name' => 'Le Rookie', 'description' => 'Le Rookie plan', - 'type' => \App\Enums\PlanType::DEVELOPER, + 'type' => PlanType::DEVELOPER->value, 'price' => 2000, 'signup_fee' => 0, 'invoice_period' => 1, @@ -37,7 +38,7 @@ public function run(): void $proPlan = Plan::create([ 'name' => 'Le Pro', 'description' => 'Le Pro plan', - 'type' => \App\Enums\PlanType::DEVELOPER, + 'type' => PlanType::DEVELOPER->value, 'price' => 5000, 'signup_fee' => 0, 'invoice_period' => 1, diff --git a/database/seeders/DummyDatabaseSeeder.php b/database/seeders/DummyDatabaseSeeder.php index 4e40619f..268b4b7d 100644 --- a/database/seeders/DummyDatabaseSeeder.php +++ b/database/seeders/DummyDatabaseSeeder.php @@ -11,7 +11,7 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; -class DummyDatabaseSeeder extends Seeder +final class DummyDatabaseSeeder extends Seeder { use WithoutModelEvents; diff --git a/database/seeders/FeatureTableSeeder.php b/database/seeders/FeatureTableSeeder.php index 05667e8e..b8d3a43e 100644 --- a/database/seeders/FeatureTableSeeder.php +++ b/database/seeders/FeatureTableSeeder.php @@ -5,22 +5,23 @@ namespace Database\Seeders; use Illuminate\Database\Seeder; +use Feature; -class FeatureTableSeeder extends Seeder +final class FeatureTableSeeder extends Seeder { public function run(): void { - \Feature::add('premium', false); - \Feature::add('badges', false); - \Feature::add('podcasts', false); + Feature::add('premium', false); + Feature::add('badges', false); + Feature::add('podcasts', false); - \Feature::add('job_skills', false); - \Feature::add('job_profile', false); - \Feature::add('auth_login', false); - \Feature::add('auth_social_login', false); + Feature::add('job_skills', false); + Feature::add('job_profile', false); + Feature::add('auth_login', false); + Feature::add('auth_social_login', false); - \Feature::add('sponsorship', false); - \Feature::add('preview_feature', false); - \Feature::add('view_profile', false); + Feature::add('sponsorship', false); + Feature::add('preview_feature', false); + Feature::add('view_profile', false); } } diff --git a/database/seeders/Fixtures/ArticleTableSeeder.php b/database/seeders/Fixtures/ArticleTableSeeder.php index 44d45d0e..ac756bfd 100644 --- a/database/seeders/Fixtures/ArticleTableSeeder.php +++ b/database/seeders/Fixtures/ArticleTableSeeder.php @@ -11,7 +11,7 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; -class ArticleTableSeeder extends Seeder +final class ArticleTableSeeder extends Seeder { use WithoutModelEvents; diff --git a/database/seeders/Fixtures/DiscussionTableSeeder.php b/database/seeders/Fixtures/DiscussionTableSeeder.php index 1ec1e904..43270843 100644 --- a/database/seeders/Fixtures/DiscussionTableSeeder.php +++ b/database/seeders/Fixtures/DiscussionTableSeeder.php @@ -10,7 +10,7 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; -class DiscussionTableSeeder extends Seeder +final class DiscussionTableSeeder extends Seeder { use WithoutModelEvents; diff --git a/database/seeders/Fixtures/ThreadTableSeeder.php b/database/seeders/Fixtures/ThreadTableSeeder.php index c94b8341..d4613e4d 100644 --- a/database/seeders/Fixtures/ThreadTableSeeder.php +++ b/database/seeders/Fixtures/ThreadTableSeeder.php @@ -7,12 +7,11 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; -class ThreadTableSeeder extends Seeder +final class ThreadTableSeeder extends Seeder { use WithoutModelEvents; public function run(): void { - // } } diff --git a/database/seeders/Fixtures/UsersTableSeeder.php b/database/seeders/Fixtures/UsersTableSeeder.php index 02c1e292..a85fc182 100644 --- a/database/seeders/Fixtures/UsersTableSeeder.php +++ b/database/seeders/Fixtures/UsersTableSeeder.php @@ -8,7 +8,7 @@ use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; -class UsersTableSeeder extends Seeder +final class UsersTableSeeder extends Seeder { use WithoutModelEvents; diff --git a/database/seeders/ReactionSeeder.php b/database/seeders/ReactionSeeder.php index eb826e7b..6b20aab2 100644 --- a/database/seeders/ReactionSeeder.php +++ b/database/seeders/ReactionSeeder.php @@ -7,7 +7,7 @@ use App\Models\Reaction; use Illuminate\Database\Seeder; -class ReactionSeeder extends Seeder +final class ReactionSeeder extends Seeder { public function run(): void { diff --git a/database/seeders/RoleSeeder.php b/database/seeders/RoleSeeder.php index 3a63df70..4daa769e 100644 --- a/database/seeders/RoleSeeder.php +++ b/database/seeders/RoleSeeder.php @@ -7,7 +7,7 @@ use Illuminate\Database\Seeder; use Spatie\Permission\Models\Role; -class RoleSeeder extends Seeder +final class RoleSeeder extends Seeder { public function run(): void { diff --git a/database/seeders/TagSeeder.php b/database/seeders/TagSeeder.php index 3d73e0b6..e8f7bdf0 100644 --- a/database/seeders/TagSeeder.php +++ b/database/seeders/TagSeeder.php @@ -7,7 +7,7 @@ use App\Models\Tag; use Illuminate\Database\Seeder; -class TagSeeder extends Seeder +final class TagSeeder extends Seeder { public function run(): void { diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php index 306e3ae3..f0a2b342 100644 --- a/database/seeders/UserSeeder.php +++ b/database/seeders/UserSeeder.php @@ -7,7 +7,7 @@ use App\Models\User; use Illuminate\Database\Seeder; -class UserSeeder extends Seeder +final class UserSeeder extends Seeder { public function run(): void { diff --git a/database/seeders/WorldSeeder.php b/database/seeders/WorldSeeder.php index eaf89e67..a13924a0 100644 --- a/database/seeders/WorldSeeder.php +++ b/database/seeders/WorldSeeder.php @@ -7,12 +7,10 @@ use Illuminate\Database\Seeder; use Nnjeim\World\Actions\SeedAction; -class WorldSeeder extends Seeder +final class WorldSeeder extends Seeder { public function run(): void { - $this->call([ - SeedAction::class, - ]); + $this->call([SeedAction::class]); } } diff --git a/helpers/ModelHelper.php b/helpers/ModelHelper.php index 7527fc3a..3a47d4c1 100644 --- a/helpers/ModelHelper.php +++ b/helpers/ModelHelper.php @@ -39,7 +39,7 @@ * @method static \Illuminate\Database\Eloquent\Builder|Activity whereUserId($value) * @mixin \Eloquent */ - class IdeHelperActivity + final class IdeHelperActivity { } } @@ -121,7 +121,7 @@ class IdeHelperActivity * @method static \Illuminate\Database\Eloquent\Builder|Article withViewsCount(?\CyrildeWit\EloquentViewable\Support\Period $period = null, ?string $collection = null, bool $unique = false, string $as = 'views_count') * @mixin \Eloquent */ - class IdeHelperArticle + final class IdeHelperArticle { } } @@ -155,7 +155,7 @@ class IdeHelperArticle * @method static \Illuminate\Database\Eloquent\Builder|Channel whereUpdatedAt($value) * @mixin \Eloquent */ - class IdeHelperChannel + final class IdeHelperChannel { } } @@ -213,7 +213,7 @@ class IdeHelperChannel * @method static \Illuminate\Database\Eloquent\Builder|Discussion withViewsCount(?\CyrildeWit\EloquentViewable\Support\Period $period = null, ?string $collection = null, bool $unique = false, string $as = 'views_count') * @mixin \Eloquent */ - class IdeHelperDiscussion + final class IdeHelperDiscussion { } } @@ -269,7 +269,7 @@ class IdeHelperDiscussion * @method static \Illuminate\Database\Eloquent\Builder|Enterprise whereWebsite($value) * @mixin \Eloquent */ - class IdeHelperEnterprise + final class IdeHelperEnterprise { } } @@ -293,7 +293,7 @@ class IdeHelperEnterprise * @method static \Illuminate\Database\Eloquent\Builder|Feature whereUpdatedAt($value) * @mixin \Eloquent */ - class IdeHelperFeature + final class IdeHelperFeature { } } @@ -340,7 +340,7 @@ class IdeHelperFeature * @method static \Illuminate\Database\Eloquent\Builder|Feature withoutTrashed() * @mixin \Eloquent */ - class IdeHelperFeature + final class IdeHelperFeature { } } @@ -411,7 +411,7 @@ class IdeHelperFeature * @method static \Illuminate\Database\Eloquent\Builder|Plan withoutTrashed() * @mixin \Eloquent */ - class IdeHelperPlan + final class IdeHelperPlan { } } @@ -472,7 +472,7 @@ class IdeHelperPlan * @method static \Illuminate\Database\Eloquent\Builder|Subscription withoutTrashed() * @mixin \Eloquent */ - class IdeHelperSubscription + final class IdeHelperSubscription { } } @@ -510,7 +510,7 @@ class IdeHelperSubscription * @method static \Illuminate\Database\Eloquent\Builder|SubscriptionUsage withoutTrashed() * @mixin \Eloquent */ - class IdeHelperSubscriptionUsage + final class IdeHelperSubscriptionUsage { } } @@ -532,7 +532,7 @@ class IdeHelperSubscriptionUsage * @method static \Illuminate\Database\Eloquent\Builder|Reaction whereUpdatedAt($value) * @mixin \Eloquent */ - class IdeHelperReaction + final class IdeHelperReaction { } } @@ -574,7 +574,7 @@ class IdeHelperReaction * @method static \Illuminate\Database\Eloquent\Builder|Reply whereUserId($value) * @mixin \Eloquent */ - class IdeHelperReply + final class IdeHelperReply { } } @@ -604,7 +604,7 @@ class IdeHelperReply * @method static \Illuminate\Database\Eloquent\Builder|SocialAccount whereUserId($value) * @mixin \Eloquent */ - class IdeHelperSocialAccount + final class IdeHelperSocialAccount { } } @@ -632,7 +632,7 @@ class IdeHelperSocialAccount * @method static \Illuminate\Database\Eloquent\Builder|Subscribe whereUuid($value) * @mixin \Eloquent */ - class IdeHelperSubscribe + final class IdeHelperSubscribe { } } @@ -659,7 +659,7 @@ class IdeHelperSubscribe * @method static \Illuminate\Database\Eloquent\Builder|Tag whereSlug($value) * @mixin \Eloquent */ - class IdeHelperTag + final class IdeHelperTag { } } @@ -724,7 +724,7 @@ class IdeHelperTag * @method static \Illuminate\Database\Eloquent\Builder|Thread withViewsCount(?\CyrildeWit\EloquentViewable\Support\Period $period = null, ?string $collection = null, bool $unique = false, string $as = 'views_count') * @mixin \Eloquent */ - class IdeHelperThread + final class IdeHelperThread { } } @@ -760,7 +760,7 @@ class IdeHelperThread * @method static \Illuminate\Database\Eloquent\Builder|Transaction whereUserId($value) * @mixin \Eloquent */ - class IdeHelperTransaction + final class IdeHelperTransaction { } } @@ -876,7 +876,7 @@ class IdeHelperTransaction * @method static \Illuminate\Database\Eloquent\Builder|User withoutRole() * @mixin \Eloquent */ - class IdeHelperUser + final class IdeHelperUser { } } diff --git a/pint.json b/pint.json index 14f19e32..bd6ec48b 100644 --- a/pint.json +++ b/pint.json @@ -1,6 +1,42 @@ { "preset": "psr12", "rules": { - "declare_strict_types": true + "align_multiline_comment": true, + "array_indentation": true, + "array_syntax": true, + "blank_line_after_namespace": true, + "blank_line_after_opening_tag": true, + "combine_consecutive_issets": true, + "combine_consecutive_unsets": true, + "concat_space": true, + "declare_parentheses": true, + "declare_strict_types": true, + "explicit_string_variable": true, + "final_class": true, + "final_internal_class": false, + "fully_qualified_strict_types": true, + "global_namespace_import": { + "import_classes": true, + "import_constants": true, + "import_functions": true + }, + "is_null": true, + "lambda_not_used_import": true, + "logical_operators": true, + "mb_str_functions": true, + "method_chaining_indentation": true, + "modernize_strpos": true, + "new_with_braces": true, + "no_empty_comment": true, + "not_operator_with_space": true, + "ordered_traits": true, + "protected_to_private": true, + "simplified_if_return": true, + "strict_comparison": true, + "ternary_to_null_coalescing": true, + "trim_array_spaces": true, + "use_arrow_functions": true, + "void_return": true, + "yoda_style": true } } diff --git a/routes/api.php b/routes/api.php index 6baeb7ce..abaa8a36 100644 --- a/routes/api.php +++ b/routes/api.php @@ -19,35 +19,35 @@ Route::get('email/verify/{id}/{hash}', [VerifyEmailController::class, 'verify']) ->middleware(['signed', 'throttle:6,1']) ->name('verification.verify'); -Route::prefix('register')->group(function () { +Route::prefix('register')->group(function (): void { Route::post('/', [RegisterController::class, 'register']); Route::post('google', [RegisterController::class, 'googleAuthenticator']); }); -Route::prefix('password')->group(function () { +Route::prefix('password')->group(function (): void { Route::post('forgot', ForgotPasswordController::class); Route::post('reset', ResetPasswordController::class); }); /* Authenticated Routes */ -Route::middleware('auth:sanctum')->group(function () { +Route::middleware('auth:sanctum')->group(function (): void { Route::post('logout', [LoginController::class, 'logout']); Route::get('email/verify/resend', [VerifyEmailController::class, 'resend']) ->middleware('throttle:6,1') ->name('verification.send'); /** User Profile Api */ - Route::prefix('user')->group(function () { + Route::prefix('user')->group(function (): void { Route::get('me', [ProfileController::class, 'me']); Route::get('roles', [ProfileController::class, 'roles']); }); }); /** Public SPA Api */ -Route::prefix('enterprises')->group(function () { +Route::prefix('enterprises')->group(function (): void { Route::get('featured', [Enterprise\PublicController::class, 'featured']); Route::get('paginate', [Enterprise\PublicController::class, 'paginate']); - Route::middleware('auth:sanctum')->group(function () { + Route::middleware('auth:sanctum')->group(function (): void { Route::post('add', Enterprise\RegisterController::class); }); }); diff --git a/routes/channels.php b/routes/channels.php index 2b5e98a1..078ca2e3 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -2,19 +2,10 @@ declare(strict_types=1); +use App\Models\User; use Illuminate\Support\Facades\Broadcast; -/* -|-------------------------------------------------------------------------- -| Broadcast Channels -|-------------------------------------------------------------------------- -| -| Here you may register all of the event broadcasting channels that your -| application supports. The given channel authorization callbacks are -| used to check if an authenticated user can listen to the channel. -| -*/ - -Broadcast::channel('App.Models.User.{id}', function ($user, $id) { - return (int) $user->id === (int) $id; -}); +Broadcast::channel( + channel: 'App.Models.User.{id}', + callback: fn (User $user, int $id) => $user->id === $id +); diff --git a/routes/cpanel.php b/routes/cpanel.php index cd1fa28f..37ae4547 100644 --- a/routes/cpanel.php +++ b/routes/cpanel.php @@ -8,6 +8,6 @@ Route::redirect('/', 'cpanel/home'); Route::get('/home', Cpanel\DashboardController::class)->name('home'); Route::get('/analytics', Cpanel\AnalyticsController::class)->name('analytics'); -Route::prefix('users')->as('users.')->group(function () { +Route::prefix('users')->as('users.')->group(function (): void { Route::get('/', Cpanel\UserController::class)->name('browse'); }); diff --git a/routes/web.php b/routes/web.php index c719d41c..58de83c2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,17 +16,6 @@ use App\Http\Controllers\User; use Illuminate\Support\Facades\Route; -/* -|-------------------------------------------------------------------------- -| Web Routes -|-------------------------------------------------------------------------- -| -| Here is where you can register web routes for your application. These -| routes are loaded by the RouteServiceProvider within a group which -| contains the "web" middleware group. Now create something great! -| -*/ - Route::get('/', HomeController::class)->name('home'); // Static pages @@ -46,7 +35,7 @@ Route::get('auth/{provider}/callback', [OAuthController::class, 'handleProviderCallback']); // Articles -Route::prefix('articles')->group(function () { +Route::prefix('articles')->group(function (): void { Route::get('/', [ArticlesController::class, 'index'])->name('articles'); Route::get('/new', [ArticlesController::class, 'create'])->name('articles.new'); Route::get('/{article}', [ArticlesController::class, 'show'])->name('articles.show'); @@ -54,7 +43,7 @@ }); // Discussions -Route::prefix('discussions')->as('discussions.')->group(function () { +Route::prefix('discussions')->as('discussions.')->group(function (): void { Route::get('/', [DiscussionController::class, 'index'])->name('index'); Route::get('/new', [DiscussionController::class, 'create'])->name('new'); Route::get('/{discussion}', [DiscussionController::class, 'show'])->name('show'); @@ -62,7 +51,7 @@ }); // Forum -Route::prefix('forum')->as('forum.')->group(function () { +Route::prefix('forum')->as('forum.')->group(function (): void { Route::redirect('/channels', '/forum'); Route::get('/', [ThreadController::class, 'index'])->name('index'); Route::get('/channels/{channel}', [ThreadController::class, 'channel'])->name('channels'); @@ -80,7 +69,7 @@ Route::get('subscribeable/{id}/{type}', [SubscriptionController::class, 'redirect'])->name('subscriptions.redirect'); // Settings -Route::prefix('settings')->as('user.')->middleware('auth')->group(function () { +Route::prefix('settings')->as('user.')->middleware('auth')->group(function (): void { Route::get('/', [User\SettingController::class, 'profile'])->name('settings'); Route::put('/', [User\SettingController::class, 'update'])->name('settings.update'); Route::view('/customization', 'user.settings.customization')->name('customization')->middleware('verified'); @@ -90,7 +79,7 @@ }); // User -Route::prefix('dashboard')->middleware(['auth', 'verified'])->group(function () { +Route::prefix('dashboard')->middleware(['auth', 'verified'])->group(function (): void { Route::get('/', [User\DashboardController::class, 'dashboard'])->name('dashboard'); Route::get('/threads', [User\DashboardController::class, 'threads'])->name('threads.me'); Route::get('/discussions', [User\DashboardController::class, 'discussions'])->name('discussions.me'); diff --git a/server.php b/server.php index 2bd0085f..1ce12569 100644 --- a/server.php +++ b/server.php @@ -14,7 +14,7 @@ // This file allows us to emulate Apache's "mod_rewrite" functionality from the // built-in PHP web server. This provides a convenient way to test a Laravel // application without having installed a "real" web server software here. -if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { +if ('/' !== $uri && file_exists(__DIR__.'/public'.$uri)) { return false; } diff --git a/tests/Feature/Cleanup/DeleteOldUnverifiedUsersTest.php b/tests/Feature/Cleanup/DeleteOldUnverifiedUsersTest.php index b184d78c..4e823270 100644 --- a/tests/Feature/Cleanup/DeleteOldUnverifiedUsersTest.php +++ b/tests/Feature/Cleanup/DeleteOldUnverifiedUsersTest.php @@ -8,7 +8,7 @@ beforeEach(fn () => TestTime::freeze('Y-m-d H:i:s', '2021-05-01 00:00:01')); -it('will delete unverified users after some days', function () { +it('will delete unverified users after some days', function (): void { $user = User::factory()->create([ 'email_verified_at' => null, ]); @@ -24,7 +24,7 @@ $this->assertFalse($user->exists()); }); -it('will not delete verified users', function () { +it('will not delete verified users', function (): void { $user = User::factory()->create([ 'email_verified_at' => now(), ]); diff --git a/tests/Feature/UserActivitiesTest.php b/tests/Feature/UserActivitiesTest.php index 8ce9fd24..4d1c6cba 100644 --- a/tests/Feature/UserActivitiesTest.php +++ b/tests/Feature/UserActivitiesTest.php @@ -11,7 +11,7 @@ uses(RefreshDatabase::class); uses(DatabaseMigrations::class); -it('records activity when an article is created', function () { +it('records activity when an article is created', function (): void { $user = $this->createUser(); $article = Article::factory()->create(['user_id' => $user->id]); @@ -28,7 +28,7 @@ $this->assertEquals($activity->subject->id, $article->id); })->skip(); -it('get feed from any user', function () { +it('get feed from any user', function (): void { $user = $this->createUser(); Article::factory()->count(2)->create(['user_id' => $user->id]); diff --git a/tests/Integration/ChannelTest.php b/tests/Integration/ChannelTest.php index 4006c525..aa1de874 100644 --- a/tests/Integration/ChannelTest.php +++ b/tests/Integration/ChannelTest.php @@ -5,14 +5,14 @@ use App\Exceptions\CannotAddChannelToChild; use App\Models\Channel; -test('channel can have childs', function () { +test('channel can have childs', function (): void { $channel = Channel::factory()->create(); Channel::factory()->count(2)->create(['parent_id' => $channel->id]); expect($channel->items->count())->toEqual(2); }); -test('child channel can be a parent', function () { +test('child channel can be a parent', function (): void { $channel = Channel::factory()->create(); $child = Channel::factory()->create(['parent_id' => $channel->id]); diff --git a/tests/Integration/DiscussionTest.php b/tests/Integration/DiscussionTest.php index a2096f85..b9ec428e 100644 --- a/tests/Integration/DiscussionTest.php +++ b/tests/Integration/DiscussionTest.php @@ -11,25 +11,25 @@ uses(RefreshDatabase::class); uses(DatabaseMigrations::class); -it('can find by slug', function () { +it('can find by slug', function (): void { Discussion::factory()->create(['slug' => 'foo']); expect(Discussion::findBySlug('foo'))->toBeInstanceOf(Discussion::class); }); -it('can give an excerpt of its body', function () { +it('can give an excerpt of its body', function (): void { $discussion = Discussion::factory()->make(['body' => 'This is a pretty long text.']); expect($discussion->excerpt(7))->toEqual('This is...'); }); -test('html in excerpts is markdown converted', function () { +test('html in excerpts is markdown converted', function (): void { $discussion = Discussion::factory()->make(['body' => '### A propos de moi']); expect($discussion->excerpt())->toEqual("#A propos de moi\n"); }); -it('can have many tags', function () { +it('can have many tags', function (): void { $tags = Tag::factory()->count(3)->create(); $discussion = Discussion::factory()->create(); $discussion->syncTags($tags->modelKeys()); @@ -37,7 +37,7 @@ expect($discussion->tags->count())->toEqual(3); }); -it('records activity when a discussion is created', function () { +it('records activity when a discussion is created', function (): void { $user = $this->login(); $discussion = Discussion::factory()->create(['user_id' => $user->id]); @@ -56,20 +56,20 @@ $this->assertEquals($user->activities->count(), 1); })->skip(); -it('generates a slug when valid url characters provided', function () { +it('generates a slug when valid url characters provided', function (): void { $discussion = Discussion::factory()->make(['slug' => 'Help with eloquent']); expect($discussion->slug())->toEqual('help-with-eloquent'); }); -it('generates a unique slug when valid url characters provided', function () { +it('generates a unique slug when valid url characters provided', function (): void { $discussionOne = Discussion::factory()->create(['slug' => 'Help with eloquent']); $discussionTwo = Discussion::factory()->create(['slug' => 'Help with eloquent']); expect($discussionTwo->slug())->toEqual('help-with-eloquent-1'); }); -it('generates a slug when invalid url characters provided', function () { +it('generates a slug when invalid url characters provided', function (): void { $discussion = Discussion::factory()->make(['slug' => '한글 테스트']); // When providing a slug with invalid url characters, a random 5 character string is returned. diff --git a/tests/Integration/ReplyTest.php b/tests/Integration/ReplyTest.php index d37e4603..8e7a1d8f 100644 --- a/tests/Integration/ReplyTest.php +++ b/tests/Integration/ReplyTest.php @@ -6,7 +6,7 @@ use App\Models\Reply; use App\Models\Thread; -it('records activity when a reply is send', function () { +it('records activity when a reply is send', function (): void { $user = $this->login(); $thread = Thread::factory()->create(); diff --git a/tests/Integration/ThreadTest.php b/tests/Integration/ThreadTest.php index 1c839354..71a0c0cd 100644 --- a/tests/Integration/ThreadTest.php +++ b/tests/Integration/ThreadTest.php @@ -14,25 +14,25 @@ uses(RefreshDatabase::class); uses(DatabaseMigrations::class); -it('can find by slug', function () { +it('can find by slug', function (): void { Thread::factory()->create(['slug' => 'foo']); expect(Thread::findBySlug('foo'))->toBeInstanceOf(Thread::class); }); -it('can give an excerpt of its body', function () { +it('can give an excerpt of its body', function (): void { $thread = Thread::factory()->make(['body' => 'This is a pretty long text.']); expect($thread->excerpt(7))->toEqual('This is...'); }); -test('html in excerpts is markdown converted', function () { +test('html in excerpts is markdown converted', function (): void { $thread = Thread::factory()->make(['body' => '

Thread body

']); expect($thread->excerpt())->toEqual("Thread body\n"); }); -it('can have many channels', function () { +it('can have many channels', function (): void { $channels = Channel::factory()->count(3)->create(); $thread = Thread::factory()->create(); $thread->channels()->attach($channels->modelKeys()); @@ -40,7 +40,7 @@ expect($thread->channels->count())->toEqual(3); })->skip(); -it('records activity when a thread is created', function () { +it('records activity when a thread is created', function (): void { $user = $this->createUser(); $thread = Thread::factory()->create(['user_id' => $user->id]); @@ -59,7 +59,7 @@ $this->assertEquals($user->activities->count(), 1); })->skip(); -test('its conversation is old when the oldest reply was six months ago', function () { +test('its conversation is old when the oldest reply was six months ago', function (): void { $thread = Thread::factory()->create(); $thread->replies()->save(Reply::factory()->make(['created_at' => now()->subMonths(7)])); @@ -71,7 +71,7 @@ expect($thread->isConversationOld())->toBeFalse(); }); -test('its conversation is old when there are no replies but the creation date was six months ago', function () { +test('its conversation is old when there are no replies but the creation date was six months ago', function (): void { $thread = Thread::factory()->create(['created_at' => now()->subMonths(7)]); expect($thread->isConversationOld())->toBeTrue(); @@ -81,7 +81,7 @@ expect($thread->isConversationOld())->toBeFalse(); }); -test('we can mark and unmark a reply as the solution', function () { +test('we can mark and unmark a reply as the solution', function (): void { $thread = Thread::factory()->create(); $reply = Reply::factory()->create(['replyable_id' => $thread->id]); $user = $this->createUser(); @@ -100,7 +100,7 @@ expect($thread->fresh()->wasResolvedBy($user))->toBeFalse(); }); -it('can retrieve the latest threads in a correct order', function () { +it('can retrieve the latest threads in a correct order', function (): void { $threadUpdatedYesterday = createThreadFromYesterday(); $threadFromToday = createThreadFromToday(); $threadFromTwoDaysAgo = createThreadFromTwoDaysAgo(); @@ -112,7 +112,7 @@ $this->assertTrue($threadFromTwoDaysAgo->is($threads->last()), 'Last thread is incorrect'); }); -it('can retrieve only resolved threads', function () { +it('can retrieve only resolved threads', function (): void { createThreadFromToday(); $resolvedThread = createResolvedThread(); @@ -122,7 +122,7 @@ expect($resolvedThread->is($threads->first()))->toBeTrue(); }); -it('can retrieve only active threads', function () { +it('can retrieve only active threads', function (): void { createThreadFromToday(); $activeThread = createActiveThread(); @@ -132,20 +132,20 @@ expect($activeThread->is($threads->first()))->toBeTrue(); }); -it('generates a slug when valid url characters provided', function () { +it('generates a slug when valid url characters provided', function (): void { $thread = Thread::factory()->make(['slug' => 'Help with eloquent']); expect($thread->slug())->toEqual('help-with-eloquent'); }); -it('generates a unique slug when valid url characters provided', function () { +it('generates a unique slug when valid url characters provided', function (): void { $threadOne = Thread::factory()->create(['slug' => 'Help with eloquent']); $threadTwo = Thread::factory()->create(['slug' => 'Help with eloquent']); expect($threadTwo->slug())->toEqual('help-with-eloquent-1'); }); -it('generates a slug when invalid url characters provided', function () { +it('generates a slug when invalid url characters provided', function (): void { $thread = Thread::factory()->make(['slug' => '한글 테스트']); // When providing a slug with invalid url characters, a random 5 character string is returned. diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index ce99ebfe..17e2d602 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -2,6 +2,6 @@ declare(strict_types=1); -test('example test', function () { +test('example test', function (): void { $this->assertTrue(true); });