From 6ef6a8254db66ef352f74b70d72dd5ceb13b40fb Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Fri, 4 Oct 2024 17:03:04 +0200 Subject: [PATCH] fix: :wheelchair: add more details in some php prototypes --- app/Console/Kernel.php | 4 +- .../ActivityLogs/ActivityLogsEventEnum.php | 1 - app/Enums/Breedings/BreedingTypeEnum.php | 2 +- app/Http/Controllers/Bo/ProductController.php | 5 +- .../Bo/SurveysAnswerController.php | 6 +- .../Club/Auth/VerificationController.php | 4 +- app/Http/Controllers/Fo/BreederController.php | 19 ++---- app/Http/Controllers/Fo/ExportController.php | 1 - app/Http/Middleware/Authenticate.php | 3 +- app/Http/Middleware/HtmlSanitizer.php | 8 ++- .../Middleware/RedirectIfAuthenticated.php | 16 ++--- app/Http/Middleware/SecureHeaders.php | 13 ++-- .../Club/Bourse/CustomerCollectionRequest.php | 2 +- .../Bourse/SaveCustomerCollectionRequest.php | 2 +- .../SearchCustomerCollectionRequest.php | 2 +- .../Club/Customers/StoreCustomerRequest.php | 8 +-- .../Club/Customers/UpdateCustomerRequest.php | 2 +- .../Club/Customers/UpdatePasswordRequest.php | 6 +- .../Club/Messages/BlockCustomerRequest.php | 4 +- .../Club/Messages/DeleteMessagesRequest.php | 4 +- .../Club/Messages/SendMessageRequest.php | 4 +- .../Club/Surveys/StoreSurveyAnswerRequest.php | 6 +- app/Jobs/FetchDigitalRecruiterOffers.php | 1 - app/Lib/Definitions/MenuNode.php | 6 +- app/Lib/Helpers/CollectionHelper.php | 30 +++++---- app/Lib/Helpers/ExceptionsHelper.php | 15 +++-- app/Lib/Helpers/ToolboxHelper.php | 49 ++++++++------- app/Lib/Link.php | 24 ++----- app/Lib/Utils.php | 6 +- app/Listeners/CreateNotification.php | 2 +- app/Listeners/PasswordHasReset.php | 2 +- app/Models/ActivityLog.php | 1 - app/Models/BrandAdvantage.php | 2 +- app/Models/ConsumptionMoment.php | 2 +- app/Models/Customer.php | 47 +++++++------- app/Models/DemarcheSlide.php | 2 +- app/Models/DepartaimantsCollection.php | 46 +++++++------- app/Models/GeneralSetting.php | 14 ++--- app/Models/HistoricalMilestone.php | 2 +- app/Models/KeyNumber.php | 2 +- app/Models/MainSlide.php | 6 +- app/Models/Meat.php | 6 +- app/Models/MenuNodeData.php | 2 +- app/Models/Message.php | 10 +-- app/Models/News.php | 2 +- app/Models/NewsBreeding.php | 8 +-- app/Models/NewsCategory.php | 4 +- app/Models/NewsClub.php | 2 +- app/Models/NewsCorporate.php | 12 ++-- app/Models/Product.php | 4 +- app/Models/ProductType.php | 2 +- app/Models/Range.php | 6 +- app/Models/Recipe.php | 6 +- app/Models/StaticPage.php | 10 +-- app/Models/Submeat.php | 2 +- app/Models/Subrange.php | 2 +- app/Models/Testimonial.php | 4 +- app/Models/Video.php | 2 +- .../Customer/DestroyCustomer.php | 10 +-- .../Customer/DestroyedCustomer.php | 14 +---- app/Notifications/Customer/ResetPassword.php | 2 +- app/Notifications/Customer/UpdateEmail.php | 10 +-- app/Notifications/Customer/UpdatePassword.php | 10 +-- app/Notifications/Customer/VerifyEmail.php | 2 +- app/Policies/SellItemPolicy.php | 1 + app/Providers/CrmApiServiceProvider.php | 2 +- app/Providers/EventServiceProvider.php | 2 +- app/Providers/MesBrApiServiceProvider.php | 2 +- app/Providers/RouteServiceProvider.php | 2 +- app/Providers/ViewServiceProvider.php | 62 +++++-------------- app/Rules/Hex.php | 2 +- app/Rules/IsValidVimeoId.php | 2 +- app/Rules/IsValidYoutubeId.php | 2 +- .../Controllers/UpdateModelPublished.php | 2 +- app/Traits/Models/IsCachedAsCollection.php | 10 +-- app/Traits/Models/MiniCrudModel.php | 16 ++--- app/Traits/Requests/HasPicture.php | 14 ++--- .../Fo/Story/HistoricalMilestoneComponent.php | 7 +-- app/View/Components/Fo/Story/WhoWeAre.php | 3 +- 79 files changed, 280 insertions(+), 362 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index a888e4bf..10562210 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -16,7 +16,7 @@ class Kernel extends ConsoleKernel * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ - protected function schedule(Schedule $schedule) + protected function schedule(Schedule $schedule): void { $schedule->job(FetchDigitalRecruiterOffers::class)->daily(); $schedule->job(DeleteOldMessages::class)->dailyAt('14:15'); @@ -28,7 +28,7 @@ class Kernel extends ConsoleKernel * * @return void */ - protected function commands() + protected function commands(): void { $this->load(__DIR__ . '/Commands'); diff --git a/app/Enums/ActivityLogs/ActivityLogsEventEnum.php b/app/Enums/ActivityLogs/ActivityLogsEventEnum.php index df947592..864edaec 100644 --- a/app/Enums/ActivityLogs/ActivityLogsEventEnum.php +++ b/app/Enums/ActivityLogs/ActivityLogsEventEnum.php @@ -25,7 +25,6 @@ enum ActivityLogsEventEnum: int self::deleted->name => 'Suppression', ]; - /** * Custom added classes definition */ diff --git a/app/Enums/Breedings/BreedingTypeEnum.php b/app/Enums/Breedings/BreedingTypeEnum.php index b618d269..f6b4933b 100644 --- a/app/Enums/Breedings/BreedingTypeEnum.php +++ b/app/Enums/Breedings/BreedingTypeEnum.php @@ -25,7 +25,7 @@ enum BreedingTypeEnum: int self::breedingHealth->name => 'La santé des volailles', ]; - /** + /** * Get all breeding pages. * * @return array diff --git a/app/Http/Controllers/Bo/ProductController.php b/app/Http/Controllers/Bo/ProductController.php index ac311278..86a4e882 100644 --- a/app/Http/Controllers/Bo/ProductController.php +++ b/app/Http/Controllers/Bo/ProductController.php @@ -185,7 +185,10 @@ class ProductController extends Controller public function update(UpdateProductRequest $request, Product $product): \Illuminate\Http\RedirectResponse { return DB::transaction(function () use ($request, $product) { - $product->fill(Arr::except($request->validated(), ['labels', 'productTypes', 'claims', 'nutritionnal_values'])); + $product->fill(Arr::except( + $request->validated(), + ['labels', 'productTypes', 'claims', 'nutritionnal_values'] + )); $product->labels()->sync(collect($request->validated()['labels'] ?? [])->pluck('id')); $product->productTypes()->sync(collect($request->validated()['productTypes'] ?? [])->pluck('id')); $product->claims()->sync(collect($request->validated()['claims'] ?? [])->pluck('id')); diff --git a/app/Http/Controllers/Bo/SurveysAnswerController.php b/app/Http/Controllers/Bo/SurveysAnswerController.php index c2f6b3bf..ddf27f9b 100644 --- a/app/Http/Controllers/Bo/SurveysAnswerController.php +++ b/app/Http/Controllers/Bo/SurveysAnswerController.php @@ -242,10 +242,12 @@ class SurveysAnswerController extends Controller return back()->with('error', trans('crud.messages.order_not_changed')); } return DB::transaction(function () use ($request, $className, $model) { + /** @var \App\Models\NewsClub $newsClubModel */ + $newsClubModel = request()->route()->parameter('news_club'); /** @var \Illuminate\Database\Eloquent\Model|null */ $tmp = $className::query() - ->when(request()->route()->parameter('news_club'), function (Builder $q) { - $q->where('news_club_id', request()->route()->parameter('news_club')->getKey()); + ->when($newsClubModel, function (Builder $q) use ($newsClubModel) { + $q->where('news_club_id', $newsClubModel->getKey()); }) ->where('order', $request->direction ? '<' : '>', $model->getOriginal('order')) ->orderBy('order', $request->direction ? 'DESC' : 'ASC') diff --git a/app/Http/Controllers/Club/Auth/VerificationController.php b/app/Http/Controllers/Club/Auth/VerificationController.php index 9812b429..a8ee8ad8 100644 --- a/app/Http/Controllers/Club/Auth/VerificationController.php +++ b/app/Http/Controllers/Club/Auth/VerificationController.php @@ -104,7 +104,7 @@ class VerificationController extends Controller } /** - * Get the post register / login redirect path. + * Get the post register/login redirect path. * * @return string */ @@ -114,7 +114,7 @@ class VerificationController extends Controller } /** - * Set Crm Customer active + * Set crm customer active. * * @param \App\Models\Customer $customer * @return void diff --git a/app/Http/Controllers/Fo/BreederController.php b/app/Http/Controllers/Fo/BreederController.php index c91654e2..29b4bf8c 100644 --- a/app/Http/Controllers/Fo/BreederController.php +++ b/app/Http/Controllers/Fo/BreederController.php @@ -26,10 +26,7 @@ class BreederController extends Controller return File::json(base_path('/public/departments.geojson')); } ); - - return response()->json( - [$departmentGeoJson] - ); + return response()->json([$departmentGeoJson]); } /** @@ -39,7 +36,7 @@ class BreederController extends Controller */ public function getBreederCountPerDepartment(): \Illuminate\Http\JsonResponse { - // TODO: mettre à jour le cache lors de l'édition/ajout/suppression d'un éleveur + // TODO: mettre à jour le cache lors de l'édition/ajout/suppression d'un éleveur. $breederCountPerDepartment = Cache::rememberForever( 'breederCountPerDepartment', function () { @@ -50,10 +47,7 @@ class BreederController extends Controller ->get()->toArray(); } ); - - return response()->json( - $breederCountPerDepartment - ); + return response()->json($breederCountPerDepartment); } /** @@ -65,7 +59,7 @@ class BreederController extends Controller public function getDepartmentBreeders(Request $request): \Illuminate\Http\JsonResponse { // TODO: checker si le departement existe. - // TODO: mettre à jour le cache lors de l'édition/ajout/suppression d'un éleveur + // TODO: mettre à jour le cache lors de l'édition/ajout/suppression d'un éleveur. $breeders = Cache::rememberForever( sprintf('departmentBreeders%s', $request->DEPARTMENT), function () use ($request) { @@ -76,10 +70,7 @@ class BreederController extends Controller ->get()->toArray(); } ); - - return response()->json( - $breeders - ); + return response()->json($breeders); } /** diff --git a/app/Http/Controllers/Fo/ExportController.php b/app/Http/Controllers/Fo/ExportController.php index ab2495c2..4a37b67f 100644 --- a/app/Http/Controllers/Fo/ExportController.php +++ b/app/Http/Controllers/Fo/ExportController.php @@ -9,7 +9,6 @@ class ExportController extends Controller /** * Contact page. * - * @param \App\Models\StaticPage $staticPageModel * @return \Illuminate\Contracts\View\View */ public function nl(): \Illuminate\Contracts\View\View diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 74bb08ff..74241783 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -18,7 +18,7 @@ class Authenticate extends Middleware { $logins = [ 'backend' => route('bo.login'), - 'club' => route('club.login') + 'club' => route('club.login') ]; if (!$request->expectsJson()) { // * Notify must login @@ -34,7 +34,6 @@ class Authenticate extends Middleware } return route('login'); } - return null; } } diff --git a/app/Http/Middleware/HtmlSanitizer.php b/app/Http/Middleware/HtmlSanitizer.php index 857ca84f..c7324fd5 100644 --- a/app/Http/Middleware/HtmlSanitizer.php +++ b/app/Http/Middleware/HtmlSanitizer.php @@ -4,7 +4,6 @@ namespace App\Http\Middleware; use App\Lib\Helpers\ToolboxHelper; use Illuminate\Http\Request; -use Symfony\Component\HttpFoundation\Response; class HtmlSanitizer { @@ -16,8 +15,11 @@ class HtmlSanitizer * @param string|array ...$params * @return \Symfony\Component\HttpFoundation\Response */ - public function handle(Request $request, \Closure $next, string|array ...$params): Response - { + public function handle( + Request $request, + \Closure $next, + string|array ...$params + ): \Symfony\Component\HttpFoundation\Response { $inputs = $request->all(); /** @var callable|null */ $cleanInput = null; diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 864e8e64..697c2a91 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -3,25 +3,26 @@ namespace App\Http\Middleware; use Illuminate\Http\Request; -use Symfony\Component\HttpFoundation\Response; class RedirectIfAuthenticated { /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next - * @param string|null ...$guards + * @param \Illuminate\Http\Request $request + * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next + * @param string|null ...$guards * @return \Symfony\Component\HttpFoundation\Response * @throws \RuntimeException If guard is unhandled. * @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint */ - public function handle(Request $request, \Closure $next, ...$guards): Response - { + public function handle( + Request $request, + \Closure $next, + string|null ...$guards + ): \Symfony\Component\HttpFoundation\Response { // phpcs:enable phpcs:disable $guards = empty($guards) ? [null] : $guards; - foreach ($guards as $guard) { if (auth($guard)->check()) { switch ($guard) { @@ -37,7 +38,6 @@ class RedirectIfAuthenticated } } } - return $next($request); } } diff --git a/app/Http/Middleware/SecureHeaders.php b/app/Http/Middleware/SecureHeaders.php index e2f3e887..4fc3de4a 100644 --- a/app/Http/Middleware/SecureHeaders.php +++ b/app/Http/Middleware/SecureHeaders.php @@ -2,12 +2,10 @@ namespace App\Http\Middleware; -use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\Vite; -use Symfony\Component\HttpFoundation\Response; class SecureHeaders { @@ -26,14 +24,12 @@ class SecureHeaders /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next + * @param \Illuminate\Http\Request $request + * @param \Closure $next * @return \Symfony\Component\HttpFoundation\Response - * @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint */ - public function handle(Request $request, Closure $next): Response + public function handle(Request $request, \Closure $next): \Symfony\Component\HttpFoundation\Response { - // phpcs:enable // * For Vite DEV $host = \parse_url(\config('app.url'), \PHP_URL_HOST); View::share('nonce', $nonce = Vite::useCspNonce()); @@ -105,7 +101,6 @@ class SecureHeaders config('app.debug') ? "https://{$host}:4443" : '', ]) . ';' ]; - $response->headers->set( 'Content-Security-Policy', implode(' ', $cspPolicies) . $reportUri @@ -115,7 +110,7 @@ class SecureHeaders } /** - * Remove unwanted headers + * Remove unwanted headers. * * @param array $headerList * @return void diff --git a/app/Http/Requests/Club/Bourse/CustomerCollectionRequest.php b/app/Http/Requests/Club/Bourse/CustomerCollectionRequest.php index c03252dd..228419a1 100644 --- a/app/Http/Requests/Club/Bourse/CustomerCollectionRequest.php +++ b/app/Http/Requests/Club/Bourse/CustomerCollectionRequest.php @@ -49,7 +49,7 @@ abstract class CustomerCollectionRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'state' => [ diff --git a/app/Http/Requests/Club/Bourse/SaveCustomerCollectionRequest.php b/app/Http/Requests/Club/Bourse/SaveCustomerCollectionRequest.php index 2dccbbb7..9a0a676b 100644 --- a/app/Http/Requests/Club/Bourse/SaveCustomerCollectionRequest.php +++ b/app/Http/Requests/Club/Bourse/SaveCustomerCollectionRequest.php @@ -12,7 +12,7 @@ class SaveCustomerCollectionRequest extends CustomerCollectionRequest * * @return array */ - public function rules() + public function rules(): array { $idEnumRule = ''; return array_merge( diff --git a/app/Http/Requests/Club/Bourse/SearchCustomerCollectionRequest.php b/app/Http/Requests/Club/Bourse/SearchCustomerCollectionRequest.php index 28fba909..c8f7f351 100644 --- a/app/Http/Requests/Club/Bourse/SearchCustomerCollectionRequest.php +++ b/app/Http/Requests/Club/Bourse/SearchCustomerCollectionRequest.php @@ -23,7 +23,7 @@ class SearchCustomerCollectionRequest extends CustomerCollectionRequest * * @return array */ - public function rules() + public function rules(): array { return array_merge( parent::rules(), diff --git a/app/Http/Requests/Club/Customers/StoreCustomerRequest.php b/app/Http/Requests/Club/Customers/StoreCustomerRequest.php index 4db8ec96..a167a761 100644 --- a/app/Http/Requests/Club/Customers/StoreCustomerRequest.php +++ b/app/Http/Requests/Club/Customers/StoreCustomerRequest.php @@ -23,7 +23,7 @@ class StoreCustomerRequest extends FormRequest * * @return boolean */ - public function authorize() + public function authorize(): bool { return Auth::guard('club')->check(); } @@ -33,7 +33,7 @@ class StoreCustomerRequest extends FormRequest * * @return void */ - public function prepareForValidation() + public function prepareForValidation(): void { try { $this->currentCountry = Country::make(\intval($this->country)); @@ -52,7 +52,7 @@ class StoreCustomerRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { $countryList = implode(',', Country::getValidIsoAplha2Codes()); return [ @@ -97,7 +97,7 @@ class StoreCustomerRequest extends FormRequest * * @return array */ - public function attributes() + public function attributes(): array { return [ 'lastname' => trans('validation.attributes.first_name'), diff --git a/app/Http/Requests/Club/Customers/UpdateCustomerRequest.php b/app/Http/Requests/Club/Customers/UpdateCustomerRequest.php index 09eb211b..3ca3382b 100644 --- a/app/Http/Requests/Club/Customers/UpdateCustomerRequest.php +++ b/app/Http/Requests/Club/Customers/UpdateCustomerRequest.php @@ -23,7 +23,7 @@ class UpdateCustomerRequest extends StoreCustomerRequest * * @return void */ - public function prepareForValidation() + public function prepareForValidation(): void { parent::prepareForValidation(); $this->merge([ diff --git a/app/Http/Requests/Club/Customers/UpdatePasswordRequest.php b/app/Http/Requests/Club/Customers/UpdatePasswordRequest.php index 9b8abdfb..33304fa6 100644 --- a/app/Http/Requests/Club/Customers/UpdatePasswordRequest.php +++ b/app/Http/Requests/Club/Customers/UpdatePasswordRequest.php @@ -13,7 +13,7 @@ class UpdatePasswordRequest extends FormRequest * * @return boolean */ - public function authorize() + public function authorize(): bool { return auth('club')->check(); } @@ -23,7 +23,7 @@ class UpdatePasswordRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { /** @var \LDC\LDCCRM\Models\Customer $crmCustomer */ $crmCustomer = \auth('club')->user()->api_data; @@ -44,7 +44,7 @@ class UpdatePasswordRequest extends FormRequest * * @return array */ - public function attributes() + public function attributes(): array { return [ 'old_password' => trans('validation.custom.old_password'), diff --git a/app/Http/Requests/Club/Messages/BlockCustomerRequest.php b/app/Http/Requests/Club/Messages/BlockCustomerRequest.php index e5ded674..33bff942 100644 --- a/app/Http/Requests/Club/Messages/BlockCustomerRequest.php +++ b/app/Http/Requests/Club/Messages/BlockCustomerRequest.php @@ -12,7 +12,7 @@ class BlockCustomerRequest extends FormRequest * * @return boolean */ - public function authorize() + public function authorize(): bool { return Auth::guard('club')->check(); } @@ -22,7 +22,7 @@ class BlockCustomerRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'username' => 'required|exists:customers,username' diff --git a/app/Http/Requests/Club/Messages/DeleteMessagesRequest.php b/app/Http/Requests/Club/Messages/DeleteMessagesRequest.php index 76b35d6a..bd949b2e 100644 --- a/app/Http/Requests/Club/Messages/DeleteMessagesRequest.php +++ b/app/Http/Requests/Club/Messages/DeleteMessagesRequest.php @@ -14,7 +14,7 @@ class DeleteMessagesRequest extends FormRequest * * @return boolean */ - public function authorize() + public function authorize(): bool { return Auth::guard('club')->check(); } @@ -24,7 +24,7 @@ class DeleteMessagesRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'message' => [ diff --git a/app/Http/Requests/Club/Messages/SendMessageRequest.php b/app/Http/Requests/Club/Messages/SendMessageRequest.php index c872640c..4fe2e09c 100644 --- a/app/Http/Requests/Club/Messages/SendMessageRequest.php +++ b/app/Http/Requests/Club/Messages/SendMessageRequest.php @@ -16,7 +16,7 @@ class SendMessageRequest extends FormRequest * * @return boolean */ - public function authorize() + public function authorize(): bool { return Auth::guard('club')->check(); } @@ -26,7 +26,7 @@ class SendMessageRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'message' => 'required|string|max:255|min:5', diff --git a/app/Http/Requests/Club/Surveys/StoreSurveyAnswerRequest.php b/app/Http/Requests/Club/Surveys/StoreSurveyAnswerRequest.php index fea23481..35943106 100644 --- a/app/Http/Requests/Club/Surveys/StoreSurveyAnswerRequest.php +++ b/app/Http/Requests/Club/Surveys/StoreSurveyAnswerRequest.php @@ -13,7 +13,7 @@ class StoreSurveyAnswerRequest extends FormRequest * * @return boolean */ - public function authorize() + public function authorize(): bool { return Auth::guard('club')->check(); } @@ -38,7 +38,7 @@ class StoreSurveyAnswerRequest extends FormRequest * * @return array */ - public function rules() + public function rules(): array { return [ 'news_club_id' => 'required|integer|exists:news_clubs,id', @@ -64,7 +64,7 @@ class StoreSurveyAnswerRequest extends FormRequest * * @return array */ - public function attributes() + public function attributes(): array { return [ 'news_club_id' => trans_choice('models.classes.news_club', 1), diff --git a/app/Jobs/FetchDigitalRecruiterOffers.php b/app/Jobs/FetchDigitalRecruiterOffers.php index 9903f216..b30a7119 100644 --- a/app/Jobs/FetchDigitalRecruiterOffers.php +++ b/app/Jobs/FetchDigitalRecruiterOffers.php @@ -37,7 +37,6 @@ class FetchDigitalRecruiterOffers config('services.digital_recruiter.url') )); } - $this->parseDigitalRecruiterOffers(\collect($response->object()->ads)); } diff --git a/app/Lib/Definitions/MenuNode.php b/app/Lib/Definitions/MenuNode.php index 7c21ea55..6d7e85db 100644 --- a/app/Lib/Definitions/MenuNode.php +++ b/app/Lib/Definitions/MenuNode.php @@ -15,13 +15,13 @@ use App\Lib\Link; class MenuNode extends \stdClass { /** - * Get property + * Get property. * * @param string $name * @return mixed * @throws \TypeError If prop is undefined. */ - public function __get(string $name) + public function __get(string $name): mixed { if (in_array($name, ['type', 'title', 'link', 'published'])) { return $this->{$name}; @@ -62,7 +62,7 @@ class MenuNode extends \stdClass * @return void * @throws \RuntimeException If $type is wrong. */ - public static function assertTypeIsCorrect(int $type) + public static function assertTypeIsCorrect(int $type): void { try { $type = MenuNodeType::make($type); diff --git a/app/Lib/Helpers/CollectionHelper.php b/app/Lib/Helpers/CollectionHelper.php index b9e9ecda..bbb51aba 100644 --- a/app/Lib/Helpers/CollectionHelper.php +++ b/app/Lib/Helpers/CollectionHelper.php @@ -10,13 +10,13 @@ use Illuminate\Support\Collection; class CollectionHelper { /** - * Paginate a collection + * Paginate a collection. * * @param \Illuminate\Support\Collection $results * @param integer $pageSize * @return \Illuminate\Pagination\LengthAwarePaginator */ - public static function paginate(Collection $results, int $pageSize): LengthAwarePaginator + public static function paginate(Collection $results, int $pageSize): \Illuminate\Pagination\LengthAwarePaginator { $page = Paginator::resolveCurrentPage('page'); @@ -24,15 +24,18 @@ class CollectionHelper } /** - * Paginate a collection + * Paginate a collection. * * @param \Illuminate\Support\Collection $results * @param integer $pageSize * @param integer $page * @return \Illuminate\Pagination\LengthAwarePaginator */ - public static function paginateManually(Collection $results, int $pageSize, int $page = 1): LengthAwarePaginator - { + public static function paginateManually( + Collection $results, + int $pageSize, + int $page = 1 + ): \Illuminate\Pagination\LengthAwarePaginator { $total = $results->count(); return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [ @@ -51,14 +54,19 @@ class CollectionHelper * @param array $options * @return \Illuminate\Pagination\LengthAwarePaginator */ - protected static function paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options) - { + protected static function paginator( + Collection $items, + int $total, + int $perPage, + int $currentPage, + array $options + ): \Illuminate\Pagination\LengthAwarePaginator { return Container::getInstance()->makeWith(LengthAwarePaginator::class, [ - 'items' => $items, - 'total' => $total, - 'perPage' => $perPage, + 'items' => $items, + 'total' => $total, + 'perPage' => $perPage, 'currentPage' => $currentPage, - 'options' => $options + 'options' => $options ]); } } diff --git a/app/Lib/Helpers/ExceptionsHelper.php b/app/Lib/Helpers/ExceptionsHelper.php index 30deb548..3c46130c 100644 --- a/app/Lib/Helpers/ExceptionsHelper.php +++ b/app/Lib/Helpers/ExceptionsHelper.php @@ -5,7 +5,7 @@ namespace App\Lib\Helpers; class ExceptionsHelper { /** - * Handle sentry event + * Handle sentry event. * * @param \Sentry\Event $event * @return null|\Sentry\Event @@ -26,7 +26,7 @@ class ExceptionsHelper } /** - * Anonimize Sentry Exception bag + * Anonimize Sentry Exception bag. * * @param \Sentry\ExceptionDataBag $exceptionDataBag * @return \Sentry\ExceptionDataBag @@ -42,7 +42,7 @@ class ExceptionsHelper } /** - * Anonymise sentry stacktrace + * Anonymise sentry stacktrace. * * @param \Sentry\Stacktrace $stackTrace * @return \Sentry\Stacktrace @@ -70,7 +70,7 @@ class ExceptionsHelper } /** - * Get anonymized sentry params + * Get anonymized sentry params. * * @param mixed[] $params * @return string[] @@ -103,9 +103,8 @@ class ExceptionsHelper return $params; } - /** - * Anonymize at least Sql queries + * Anonymize at least Sql queries. * * @param string $message * @return string @@ -120,7 +119,7 @@ class ExceptionsHelper } /** - * Anonymize stack trace + * Anonymize stack trace. * * @param \Throwable $e * @return string @@ -159,7 +158,7 @@ class ExceptionsHelper } /** - * Handle Args + * Handle Args. * * @param array $stack * @return string diff --git a/app/Lib/Helpers/ToolboxHelper.php b/app/Lib/Helpers/ToolboxHelper.php index eb2c9e7e..562e4517 100644 --- a/app/Lib/Helpers/ToolboxHelper.php +++ b/app/Lib/Helpers/ToolboxHelper.php @@ -22,7 +22,7 @@ use Symfony\Component\Finder\SplFileInfo; class ToolboxHelper { /** - * Censor string + * Censor string. * * @param string $string * @return string @@ -38,8 +38,9 @@ class ToolboxHelper } return $censor->censorString($string, true)['clean']; } + /** - * Run a terminal command and gives the output + * Run a terminal command and gives the output. * * @param array|string $command The command to execute on terminal. * @param boolean $throw Wether to throw en esception on failure or not. @@ -53,7 +54,7 @@ class ToolboxHelper * @throws \LogicException * @throws \RuntimeException If the command fails. */ - public static function runConsoleCommand(array|string $command, bool $throw = true): string | false + public static function runConsoleCommand(array|string $command, bool $throw = true): string|false { // phpcs:enable $process = \Illuminate\Support\Facades\Process::command($command)->run(); @@ -69,6 +70,8 @@ class ToolboxHelper } /** + * Return array merge recursive distinct. + * * @param array $array1 * @param array $array2 * @@ -89,13 +92,13 @@ class ToolboxHelper } /** - * Validate recaptcha + * Validate recaptcha. * * @param \Illuminate\Http\Request $request * @param boolean $isV3 * @return void */ - public static function validateRecaptcha(Request $request, bool $isV3 = true) + public static function validateRecaptcha(Request $request, bool $isV3 = true): void { Validator::validate($request->all(), [ 'g-recaptcha-response' => [ @@ -147,7 +150,7 @@ class ToolboxHelper * Only embed allowed are for MP4 self hosted videos right now * * https is force by ckeditor MediaElements which natively supports - * only cloud hosted medias (youtube, spotify etc..) + * only cloud hosted medias (youtube, spotify etc..). * * @param string $input * @return string @@ -159,7 +162,7 @@ class ToolboxHelper } /** - * Assert That no Back Office url is present on txt + * Assert That no Back Office url is present on txt. * * @param string $field * @param string $text @@ -202,7 +205,7 @@ class ToolboxHelper } /** - * Assert That only external url is present on txt + * Assert That only external url is present on txt. * * @param string $field * @param string $text @@ -245,7 +248,7 @@ class ToolboxHelper } /** - * Mutltibyte string replace + * Mutltibyte string replace. * * @param array|string $search * @param array|string $replace @@ -289,7 +292,7 @@ class ToolboxHelper } /** - * Asserts that the field is unique + * Asserts that the field is unique. * * @param string $table * @param string $field @@ -305,7 +308,7 @@ class ToolboxHelper string|int|float|bool|null|array $value, ?int $id = null, ?callable $query = null - ) { + ): void { if (!$query) { Validator::make([$field => $value], [ self::mbReplace('.', '\.', $field) => Rule::unique($table, $field)->ignore($id), @@ -326,7 +329,7 @@ class ToolboxHelper } /** - * Get original polyfill with autotranslate behavior + * Get original polyfill with autotranslate behavior. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $attribute @@ -352,7 +355,7 @@ class ToolboxHelper } /** - * Dynamic model query + * Dynamic model query. * * @param string $defaultLocale * @param \Illuminate\Contracts\Database\Eloquent\Builder $q @@ -365,7 +368,7 @@ class ToolboxHelper Builder $q, string $column, string $value - ): Builder { + ): \Illuminate\Contracts\Database\Eloquent\Builder { $currentLocale = app()->currentLocale(); $locales = collect(config('app.locales')) ->mapWithKeys(fn (string $locale) => [$locale => $locale]); @@ -393,7 +396,7 @@ class ToolboxHelper } /** - * Generates an array from a dot separated string + * Generates an array from a dot separated string. * * @param string $path * @param mixed $value @@ -412,7 +415,7 @@ class ToolboxHelper } /** - * Convert deeply an object to array + * Convert deeply an object to array. * * @param mixed $input * @return array @@ -434,7 +437,7 @@ class ToolboxHelper } /** - * Convert deeply an array to object + * Convert deeply an array to object. * * @param mixed $input * @return object @@ -456,7 +459,7 @@ class ToolboxHelper } /** - * Validate picture + * Validate picture. * * @param string $attribute * @param string|null $value @@ -513,7 +516,7 @@ class ToolboxHelper } /** - * Get the file full path + * Get the file full path. * * @param string $value * @param boolean $useStorage @@ -527,19 +530,19 @@ class ToolboxHelper } /** - * Get the file mimetype + * Get the file mimetype. * * @param string $value * @param boolean $useStorage * @return string|false */ - private static function getUploadedFileMimeType(string $value, bool $useStorage) + private static function getUploadedFileMimeType(string $value, bool $useStorage): string|false { return !$useStorage ? File::mimeType($value) : Storage::mimeType($value); } /** - * Fetch class list from a specific namespace + * Fetch class list from a specific namespace. * * @param string $namespace * @return array An array of classe namespaces @@ -553,7 +556,7 @@ class ToolboxHelper } /** - * Get all classes from a specific namespace that implement a specific interface + * Get all classes from a specific namespace that implement a specific interface. * * @param string $namespace * @param string $interface diff --git a/app/Lib/Link.php b/app/Lib/Link.php index a8526313..6f0d255e 100644 --- a/app/Lib/Link.php +++ b/app/Lib/Link.php @@ -11,10 +11,10 @@ use Stringable; * * @package App\Lib */ -class Link implements Jsonable, Arrayable, \JsonSerializable, Stringable +class Link implements Jsonable, Arrayable, Stringable { /** - * Link + * Link. * * @param null|string $url A valid url. * @param null|string $routeName A valid route name. @@ -77,9 +77,9 @@ class Link implements Jsonable, Arrayable, \JsonSerializable, Stringable /** * Get the instance as an array. * - * @return array<'url'|'routeName',string|null> + * @return array<'url'|'routeName', string|null> */ - public function toArray() + public function toArray(): array { return ['url' => $this->url, 'routeName' => $this->routeName]; } @@ -91,26 +91,14 @@ class Link implements Jsonable, Arrayable, \JsonSerializable, Stringable * @return string * @phpcs:disable Squiz.Commenting.FunctionComment.ScalarTypeHintMissing */ - public function toJson($options = 0) + public function toJson($options = 0): string { // phpcs:enable - return \json_encode($this->jsonSerialize(), $options); - } - - /** - * Convert the object into something JSON serializable. - * - * @return array - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return $this->toArray(); + return \json_encode($this->toArray(), $options); } /** * @return string - * * @throws \RuntimeException If the link cannot be converted to string. */ public function __toString() diff --git a/app/Lib/Utils.php b/app/Lib/Utils.php index 54e2de77..4dcf94b0 100644 --- a/app/Lib/Utils.php +++ b/app/Lib/Utils.php @@ -6,7 +6,7 @@ use App\Models\Customer; use Illuminate\Support\Str; /** - * Some utilities methods + * Some utilities methods. */ // phpcs:disable Generic.Files.LineLength.TooLong class Utils @@ -111,7 +111,7 @@ class Utils } /** - * Multibyte strtr + * Multibyte strtr. * * @param string $str * @param string|array $from @@ -131,7 +131,7 @@ class Utils } /** - * Generate an unique pseudo + * Generate an unique pseudo. * * @param string $firstname * @param string $lastname diff --git a/app/Listeners/CreateNotification.php b/app/Listeners/CreateNotification.php index 78de64a7..3862b6d9 100644 --- a/app/Listeners/CreateNotification.php +++ b/app/Listeners/CreateNotification.php @@ -12,7 +12,7 @@ class CreateNotification * @param \App\Events\NewNotification $event * @return void */ - public function handle(NewNotification $event) + public function handle(NewNotification $event): void { $event->model->notifiable()->create([ 'type' => $event->type, diff --git a/app/Listeners/PasswordHasReset.php b/app/Listeners/PasswordHasReset.php index ef397fd4..acd848bc 100644 --- a/app/Listeners/PasswordHasReset.php +++ b/app/Listeners/PasswordHasReset.php @@ -15,7 +15,7 @@ class PasswordHasReset * @param \Illuminate\Auth\Events\PasswordReset $event * @return void */ - public function handle(PasswordReset $event) + public function handle(PasswordReset $event): void { /** @var \App\Models\Customer */ $customer = $event->user; diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index b7eb30e6..8932a01f 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -117,7 +117,6 @@ class ActivityLog extends Model }; } - /** * Get a value type as a string * ! Use this for display purpose only diff --git a/app/Models/BrandAdvantage.php b/app/Models/BrandAdvantage.php index dcda11ef..db1e6a92 100644 --- a/app/Models/BrandAdvantage.php +++ b/app/Models/BrandAdvantage.php @@ -136,7 +136,7 @@ class BrandAdvantage extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedBrandAdvantagesOrderedByOrder'); self::getPublishedOrdered(); diff --git a/app/Models/ConsumptionMoment.php b/app/Models/ConsumptionMoment.php index 72e77091..8b7594cc 100644 --- a/app/Models/ConsumptionMoment.php +++ b/app/Models/ConsumptionMoment.php @@ -91,7 +91,7 @@ class ConsumptionMoment extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('consumptionMomentsOrderedBySlug'); self::getOrderedBySlug(); diff --git a/app/Models/Customer.php b/app/Models/Customer.php index a1e54c27..361a3144 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -100,7 +100,7 @@ class Customer extends Authenticatable implements MustVerifyEmail // * METHODS /** - * Asserts using validation that the email is unique + * Asserts using validation that the email is unique. * * @param mixed $id * @param mixed $email @@ -113,7 +113,7 @@ class Customer extends Authenticatable implements MustVerifyEmail } /** - * Asserts that the field is unique + * Asserts that the field is unique. * * @param mixed $id * @param string $field @@ -134,7 +134,7 @@ class Customer extends Authenticatable implements MustVerifyEmail } /** - * Get conversations with messages sorted by time + * Get conversations with messages sorted by time. * * @return array */ @@ -218,7 +218,7 @@ class Customer extends Authenticatable implements MustVerifyEmail * * @return void */ - public function sendEmailVerificationNotification() + public function sendEmailVerificationNotification(): void { $this->deleteIfDoesNotExistsInCrm(); $this->notify(new VerifyEmail()); @@ -230,7 +230,7 @@ class Customer extends Authenticatable implements MustVerifyEmail * @param mixed $token * @return void */ - public function sendPasswordResetNotification(mixed $token) + public function sendPasswordResetNotification(mixed $token): void { $this->deleteIfDoesNotExistsInCrm(); /** @var string $token */ @@ -296,7 +296,7 @@ class Customer extends Authenticatable implements MustVerifyEmail } /** - * Get api_data attribute, the crm Data of a customer + * Get api_data attribute, the crm Data of a customer. * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ @@ -348,7 +348,7 @@ class Customer extends Authenticatable implements MustVerifyEmail // * CRM CACHE /** - * Clear cached apiData + * Clear cached apiData. * * @return void */ @@ -360,24 +360,21 @@ class Customer extends Authenticatable implements MustVerifyEmail } /** - * Put customer crm part in cache + * Put customer crm part in cache. * - * @template T - * @param string $uuid The customer uuid. - * @param string $part_name The part name for the cache path. - * @param \Closure(void):T $part The part to cache. - * @param integer $ttl Time to live in seconds for the cache part. - * @return T - * @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint + * @param string $uuid The customer uuid. + * @param string $part_name The part name for the cache path. + * @param \Closure $part The part to cache. + * @param integer $ttl Time to live in seconds for the cache part. + * @return mixed */ - public static function cacheCrm(string $uuid, string $part_name, \Closure $part, int $ttl = 60 * 60) + public static function cacheCrm(string $uuid, string $part_name, \Closure $part, int $ttl = 60 * 60): mixed { - // phpcs:enable return Cache::remember("customers.{$uuid}.{$part_name}", $ttl, $part); } /** - * Clear customer crm cache part or totally + * Clear customer crm cache part or totally. * * @param string $uuid * @param string $part_name @@ -395,11 +392,11 @@ class Customer extends Authenticatable implements MustVerifyEmail /** * This mutate Customer attributes to array * including only non critical properties and crm values - * (One that can be send to front office without security breach) + * (One that can be send to front office without security breach). * * @return array */ - public function toArray() + public function toArray(): array { if ($this->hashcode) { return collect(array_merge( @@ -427,7 +424,7 @@ class Customer extends Authenticatable implements MustVerifyEmail // * RELATIONSHIPS /** - * Get all of the departaimant collections for the Customer + * Get all of the departaimant collections for the Customer. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -437,7 +434,7 @@ class Customer extends Authenticatable implements MustVerifyEmail } /** - * The notifications that belong to the Customer + * The notifications that belong to the Customer. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -447,7 +444,7 @@ class Customer extends Authenticatable implements MustVerifyEmail } /** - * The read notifications that belong to the Customer + * The read notifications that belong to the Customer. * * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ @@ -457,7 +454,7 @@ class Customer extends Authenticatable implements MustVerifyEmail } /** - * Get all of the messages for the Customer + * Get all of the messages for the Customer. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ @@ -467,7 +464,7 @@ class Customer extends Authenticatable implements MustVerifyEmail } /** - * Get all of the sentMessages for the Customer + * Get all of the sentMessages for the Customer. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ diff --git a/app/Models/DemarcheSlide.php b/app/Models/DemarcheSlide.php index 32f4f451..1fd86251 100644 --- a/app/Models/DemarcheSlide.php +++ b/app/Models/DemarcheSlide.php @@ -189,7 +189,7 @@ class DemarcheSlide extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedDemarcheSlidesOrderedByOrder'); self::getPublishedOrdered(); diff --git a/app/Models/DepartaimantsCollection.php b/app/Models/DepartaimantsCollection.php index f4580221..d8833eb0 100644 --- a/app/Models/DepartaimantsCollection.php +++ b/app/Models/DepartaimantsCollection.php @@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Model; /** * Departaimants Model - * Has functions to store departaimants on multiple statuses + * Has functions to store departaimants on multiple statuses. * * @property \App\Enums\Departaimants\DepartaimantCollectionType $type * @property integer $customer_id @@ -66,21 +66,21 @@ class DepartaimantsCollection extends Model ]; /** - * Columns prefix + * Columns prefix. * * @var string */ private static $columnTableNamePrefix = 'col'; /** - * Le prefix d'un table departaimant + * Le prefix d'un table departaimant. * * @var integer */ private static $tableFields = 4; /** - * Le nombre de colonnes des departaimants + * Le nombre de colonnes des departaimants. * * * La largeur en bits d'un départaimant * * to be set in construct @@ -130,7 +130,7 @@ class DepartaimantsCollection extends Model // * RELATIONSHIPS /** - * Get the customer that owns the DepartaimantsCollection + * Get the customer that owns the DepartaimantsCollection. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -142,7 +142,7 @@ class DepartaimantsCollection extends Model // * METHODS /** - * Add a Departaiment to this collection + * Add a Departaiment to this collection. * * @param \App\Enums\Departaimants\IDepartaimant $departaimant * @return void @@ -153,7 +153,7 @@ class DepartaimantsCollection extends Model } /** - * Removes a Departaime from this collection + * Removes a Departaime from this collection. * * @param \App\Enums\Departaimants\IDepartaimant $departaimant * @return void @@ -164,7 +164,7 @@ class DepartaimantsCollection extends Model } /** - * Checks if this collection has a Departaimant + * Checks if this collection has a Departaimant. * * @param \App\Enums\Departaimants\IDepartaimant $departaimant * @return boolean @@ -175,7 +175,7 @@ class DepartaimantsCollection extends Model } /** - * Set the Departaimant to a specific status + * Set the Departaimant to a specific status. * * @param \App\Enums\Departaimants\IDepartaimant $departaimant * @param \App\Enums\Departaimants\DepartaimantStatus $status @@ -191,7 +191,7 @@ class DepartaimantsCollection extends Model } /** - * Test the Departaimant status + * Test the Departaimant status. * * @param \App\Enums\Departaimants\IDepartaimant $departaimant * @param \App\Enums\Departaimants\DepartaimantStatus $status @@ -212,7 +212,7 @@ class DepartaimantsCollection extends Model } /** - * Get all Customer which has their departaimant with a status + * Get all Customer which has their departaimant with a status. * * @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype * @param \App\Enums\Departaimants\IDepartaimant $departaimant @@ -240,7 +240,7 @@ class DepartaimantsCollection extends Model } /** - * Get all Customer which has their departaimant with a status + * Get all Customer which has their departaimant with a status. * * @param array $departaimants * @param \App\Enums\Departaimants\DepartaimantStatus $status @@ -278,7 +278,7 @@ class DepartaimantsCollection extends Model } /** - * Get the Departaimant status + * Get the Departaimant status. * * @param \App\Enums\Departaimants\IDepartaimant $departaimant * @return \App\Enums\Departaimants\DepartaimantStatus @@ -298,7 +298,7 @@ class DepartaimantsCollection extends Model } /** - * Get a list of all the departaimants and their status + * Get a list of all the departaimants and their status. * * @uses \App\Enums\Departaimants\IDepartaimant * @uses \App\Enums\Departaimants\DepartaimantStatus @@ -322,7 +322,7 @@ class DepartaimantsCollection extends Model } /** - * Get a list of all the departaimants and their status + * Get a list of all the departaimants and their status. * * @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype * @param \App\Enums\Departaimants\DepartaimantStatus $status @@ -352,7 +352,7 @@ class DepartaimantsCollection extends Model } /** - * Set the Departaimant column to 0 + * Set the Departaimant column to 0. * * @param \App\Enums\Departaimants\IDepartaimant $departaimant * @return void @@ -367,7 +367,7 @@ class DepartaimantsCollection extends Model /** * Donne la 'table' (colonne SQL) dans laquelle se trouve - * le département + * le département. * * @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype * @param \App\Enums\Departaimants\IDepartaimant $dep @@ -386,7 +386,7 @@ class DepartaimantsCollection extends Model /** * Donne la colonne (binaire) dans laquelle se trouve le département - * Dans sa 'table' (colonne SQL) + * Dans sa 'table' (colonne SQL). * * @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype * @param \App\Enums\Departaimants\IDepartaimant $dep @@ -407,7 +407,7 @@ class DepartaimantsCollection extends Model } /** - * Donne la valeur (masque binaire) d'un département + * Donne la valeur (masque binaire) d'un département. * * @param \App\Enums\Departaimants\IDepartaimant $dep * @return integer @@ -418,7 +418,7 @@ class DepartaimantsCollection extends Model } /** - * Genère la liste des departements avec leur masques + * Genère la liste des departements avec leur masques. * * @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype * @return array @@ -439,7 +439,7 @@ class DepartaimantsCollection extends Model /** * Get the with in bit length for a column - * that can be used to store data + * that can be used to store data. * * @return float */ @@ -450,7 +450,7 @@ class DepartaimantsCollection extends Model } /** - * Get departaimant enum values + * Get departaimant enum values. * * @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype * @return array @@ -462,7 +462,7 @@ class DepartaimantsCollection extends Model } /** - * Get a departaiment enum from a collection type + * Get a departaiment enum from a collection type. * * @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype * @return string diff --git a/app/Models/GeneralSetting.php b/app/Models/GeneralSetting.php index bca9e942..a3c4f2dc 100644 --- a/app/Models/GeneralSetting.php +++ b/app/Models/GeneralSetting.php @@ -93,7 +93,7 @@ class GeneralSetting extends Model * * @return mixed */ - public function getRouteKey() + public function getRouteKey(): mixed { /** @var \App\Enums\StaticPageType */ $enum = $this->getAttribute($this->getRouteKeyName()); @@ -115,11 +115,11 @@ class GeneralSetting extends Model // * GETTERS /** - * Mutator for 'value' attribute + * Mutator for 'value' attribute. * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ - public function value(): Attribute + public function value(): \Illuminate\Database\Eloquent\Casts\Attribute { return Attribute::make( get: fn($value): array => self::valueFromJson($this->type, $value), @@ -170,7 +170,7 @@ class GeneralSetting extends Model } /** - * Unserialize setting value + * Unserialize setting value. * * @param \App\Enums\Settings\SettingsType $type * @param string $json @@ -197,7 +197,7 @@ class GeneralSetting extends Model * @param \App\Enums\Settings\SettingsType $type * @return void */ - private static function resetCache(SettingsType $type) + private static function resetCache(SettingsType $type): void { Cache::forget(sprintf('%sGeneralSetting', $type->name)); self::getCachedGeneralSetting($type); @@ -207,9 +207,9 @@ class GeneralSetting extends Model * Get cached general setting associated to a given type. * * @param \App\Enums\Settings\SettingsType $type - * @return \App\Models\StaticPage + * @return mixed */ - public static function getCachedGeneralSetting(SettingsType $type) + public static function getCachedGeneralSetting(SettingsType $type): mixed { return Cache::rememberForever( sprintf('%sGeneralSetting', $type->name), diff --git a/app/Models/HistoricalMilestone.php b/app/Models/HistoricalMilestone.php index e860d75c..3c0109c6 100644 --- a/app/Models/HistoricalMilestone.php +++ b/app/Models/HistoricalMilestone.php @@ -117,7 +117,7 @@ class HistoricalMilestone extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedHistoricalMilestonesOrdered'); self::getPublishedOrdered(); diff --git a/app/Models/KeyNumber.php b/app/Models/KeyNumber.php index fa619bd5..4eb9fe09 100644 --- a/app/Models/KeyNumber.php +++ b/app/Models/KeyNumber.php @@ -84,7 +84,7 @@ class KeyNumber extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('5publishedKeyNumbersOrderedByOrder'); self::get5PublishedOrdered(); diff --git a/app/Models/MainSlide.php b/app/Models/MainSlide.php index 6bb9325e..0c5e440f 100644 --- a/app/Models/MainSlide.php +++ b/app/Models/MainSlide.php @@ -177,7 +177,7 @@ class MainSlide extends Model } /** - * Adjusts mainSlide status using current status and publish dates + * Adjusts mainSlide status using current status and publish dates. * * @param self $mainSlide * @return void @@ -201,7 +201,7 @@ class MainSlide extends Model } /** - * Getter the current status following planification dates planificated_status + * Getter the current status following planification dates planificated_status. * * @return boolean */ @@ -239,7 +239,7 @@ class MainSlide extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedMainSlidesOrderedByOrderWithApproaches'); self::getPublishedOrderedWithApproaches(); diff --git a/app/Models/Meat.php b/app/Models/Meat.php index b70cd7bf..8d6bff60 100644 --- a/app/Models/Meat.php +++ b/app/Models/Meat.php @@ -127,14 +127,14 @@ class Meat extends Model } /** - * Asserts using validation that the label is unique + * Asserts using validation that the label is unique. * * @param string|null $label * @param integer|null $id * @return void * @throws \Illuminate\Validation\ValidationException If a meat label already exists. */ - private static function assertLabelIsUnique(string|null $label, ?int $id = null) + private static function assertLabelIsUnique(string|null $label, ?int $id = null): void { $table = (new self())->getTable(); ToolboxHelper::assertFieldIsUnique($table, 'label', $label, $id); @@ -157,7 +157,7 @@ class Meat extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedMeatsOrderedByOrder'); self::getPublishedOrdered(); diff --git a/app/Models/MenuNodeData.php b/app/Models/MenuNodeData.php index 6c538179..3063114d 100644 --- a/app/Models/MenuNodeData.php +++ b/app/Models/MenuNodeData.php @@ -116,7 +116,7 @@ class MenuNodeData extends Model // * METHODS /** - * Deny Handling some of the MenuNodeData + * Deny Handling some of the MenuNodeData. * * @param self $model * @return void diff --git a/app/Models/Message.php b/app/Models/Message.php index c2d89390..fc058649 100644 --- a/app/Models/Message.php +++ b/app/Models/Message.php @@ -32,7 +32,7 @@ class Message extends Model implements INotifiable // * RELATIONSHIPS /** - * BelongsTo customer relation + * BelongsTo customer relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -42,7 +42,7 @@ class Message extends Model implements INotifiable } /** - * BelongsTo customer relation + * BelongsTo customer relation. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ @@ -52,7 +52,7 @@ class Message extends Model implements INotifiable } /** - * MorphOne notification relation + * MorphOne notification relation. * * @return \Illuminate\Database\Eloquent\Relations\MorphOne */ @@ -64,7 +64,7 @@ class Message extends Model implements INotifiable // * METHODS /** - * created_at_nice_date attribute + * created_at_nice_date attribute. * * @return \Illuminate\Database\Eloquent\Casts\Attribute */ @@ -76,7 +76,7 @@ class Message extends Model implements INotifiable } /** - * Get MessagesOlderThan attribute + * Get MessagesOlderThan attribute. * * @param integer $days * @return \Illuminate\Contracts\Database\Eloquent\Builder diff --git a/app/Models/News.php b/app/Models/News.php index 4e6d3f81..7629bfdc 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -222,7 +222,7 @@ class News extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedNewsWithCategories'); self::getPublishedWithNewsCategory(); diff --git a/app/Models/NewsBreeding.php b/app/Models/NewsBreeding.php index 0666082a..d023cb57 100644 --- a/app/Models/NewsBreeding.php +++ b/app/Models/NewsBreeding.php @@ -121,7 +121,7 @@ class NewsBreeding extends Model } /** - * Adjusts breedingNews status using current status and publish dates + * Adjusts breedingNews status using current status and publish dates. * * @param self $model * @return void @@ -145,7 +145,7 @@ class NewsBreeding extends Model } /** - * Asserts using validation that the title is unique + * Asserts using validation that the title is unique. * * @param string|null $title * @param integer|null $id @@ -161,7 +161,7 @@ class NewsBreeding extends Model /** - * Getter the current status following planification dates planificated_status + * Getter the current status following planification dates planificated_status. * * @return boolean */ @@ -189,7 +189,7 @@ class NewsBreeding extends Model * @param \App\Enums\StaticPageType $type * @return void */ - private static function resetCache(StaticPageType $type) + private static function resetCache(StaticPageType $type): void { Cache::forget(sprintf('%sPublishedNewsBreedingOrderedByOrder', $type->name)); self::getPublishedOrderedForType($type); diff --git a/app/Models/NewsCategory.php b/app/Models/NewsCategory.php index 8802345c..07dd9366 100644 --- a/app/Models/NewsCategory.php +++ b/app/Models/NewsCategory.php @@ -101,7 +101,7 @@ class NewsCategory extends Model } /** - * Asserts using validation that the title is unique + * Asserts using validation that the title is unique. * * @param string|null $title * @param integer|null $id @@ -120,7 +120,7 @@ class NewsCategory extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedNewsCategoriesOrderedByOrder'); self::getPublishedOrdered(); diff --git a/app/Models/NewsClub.php b/app/Models/NewsClub.php index bd77f949..a06c874c 100644 --- a/app/Models/NewsClub.php +++ b/app/Models/NewsClub.php @@ -96,7 +96,7 @@ class NewsClub extends Model } /** - * Asserts using validation that the title is unique + * Asserts using validation that the title is unique. * * @param string|null $title * @param integer|null $id diff --git a/app/Models/NewsCorporate.php b/app/Models/NewsCorporate.php index ac4e8510..6e47129f 100644 --- a/app/Models/NewsCorporate.php +++ b/app/Models/NewsCorporate.php @@ -85,7 +85,7 @@ class NewsCorporate extends Model // * METHODS /** - * Adjusts newsCorporate status using current status and publish dates + * Adjusts newsCorporate status using current status and publish dates. * * @param self $newsCorporate * @return void @@ -109,7 +109,7 @@ class NewsCorporate extends Model } /** - * Getter the current status following planification dates planificated_status + * Getter the current status following planification dates planificated_status. * * @return boolean */ @@ -136,7 +136,7 @@ class NewsCorporate extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('9publishedNewsCorporateOrderedByUpdatedAt'); self::get9PublishedOrderedByUpdatedAt(); @@ -150,11 +150,7 @@ class NewsCorporate extends Model public static function get9PublishedOrderedByUpdatedAt(): \Illuminate\Database\Eloquent\Collection { return Cache::rememberForever('9publishedNewsCorporateOrderedByUpdatedAt', function () { - return self::query() - ->where('published', true) - ->orderByDesc('updated_at') - ->limit(9) - ->get(); + return self::query()->where('published', true)->orderByDesc('updated_at')->limit(9)->get(); }); } } diff --git a/app/Models/Product.php b/app/Models/Product.php index cf892ff4..e2c8d909 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -150,7 +150,7 @@ class Product extends Model implements SeoInterface * @return void * @throws \Illuminate\Validation\ValidationException If a range label already exists. */ - private static function assertLabelIsUnique(string|null $label, ?int $id = null) + private static function assertLabelIsUnique(string|null $label, ?int $id = null): void { $table = (new self())->getTable(); ToolboxHelper::assertFieldIsUnique($table, 'label', $label, $id); @@ -200,7 +200,7 @@ class Product extends Model implements SeoInterface * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedDiscoveredProducts'); self::getPublishedDiscovered(); diff --git a/app/Models/ProductType.php b/app/Models/ProductType.php index f0e1a808..71ce48e1 100644 --- a/app/Models/ProductType.php +++ b/app/Models/ProductType.php @@ -79,7 +79,7 @@ class ProductType extends Model // * METHODS /** - * Asserts using validation that the label is unique + * Asserts using validation that the label is unique. * * @param string|null $label * @param integer|null $id diff --git a/app/Models/Range.php b/app/Models/Range.php index bc4dc913..5e6c0206 100644 --- a/app/Models/Range.php +++ b/app/Models/Range.php @@ -132,14 +132,14 @@ class Range extends Model } /** - * Asserts using validation that the label is unique + * Asserts using validation that the label is unique. * * @param string|null $label * @param integer|null $id * @return void * @throws \Illuminate\Validation\ValidationException If a range label already exists. */ - private static function assertLabelIsUnique(string|null $label, ?int $id = null) + private static function assertLabelIsUnique(string|null $label, ?int $id = null): void { $table = (new self())->getTable(); ToolboxHelper::assertFieldIsUnique($table, 'label', $label, $id); @@ -162,7 +162,7 @@ class Range extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedRangesOrderedByOrder'); self::getPublishedOrdered(); diff --git a/app/Models/Recipe.php b/app/Models/Recipe.php index 60806c9d..8100ab8c 100644 --- a/app/Models/Recipe.php +++ b/app/Models/Recipe.php @@ -127,14 +127,14 @@ class Recipe extends Model implements SeoInterface } /** - * Asserts using validation that the label is unique + * Asserts using validation that the label is unique. * * @param string|null $title * @param integer|null $id * @return void * @throws \Illuminate\Validation\ValidationException If a range title already exists. */ - private static function assertTitleIsUnique(string|null $title, ?int $id = null) + private static function assertTitleIsUnique(string|null $title, ?int $id = null): void { $table = (new self())->getTable(); ToolboxHelper::assertFieldIsUnique($table, 'title', $title, $id); @@ -198,7 +198,7 @@ class Recipe extends Model implements SeoInterface * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedFirstHighlightedRecipe'); self::getFirstHighlighted(); diff --git a/app/Models/StaticPage.php b/app/Models/StaticPage.php index 88934219..95935263 100644 --- a/app/Models/StaticPage.php +++ b/app/Models/StaticPage.php @@ -96,7 +96,7 @@ class StaticPage extends Model * * @return mixed */ - public function getRouteKey() + public function getRouteKey(): mixed { /** @var \App\Enums\StaticPageType */ $enum = $this->getAttribute($this->getRouteKeyName()); @@ -137,7 +137,7 @@ class StaticPage extends Model /** * Asserts using validation that the title is unique * - * @param string|null $seo_title + * @param string|null $title * @param integer|null $id * @return void * @throws \Illuminate\Validation\ValidationException If an actu seo_title already exists. @@ -157,7 +157,7 @@ class StaticPage extends Model * @param \App\Enums\StaticPageType $type * @return void */ - private static function resetCache(StaticPageType $type) + private static function resetCache(StaticPageType $type): void { Cache::forget(sprintf('%sStaticPage', $type->name)); self::getCachedStaticPage($type); @@ -173,7 +173,7 @@ class StaticPage extends Model * @param \App\Enums\StaticPageType $type * @return \App\Models\StaticPage */ - public static function getCachedStaticPage(StaticPageType $type) + public static function getCachedStaticPage(StaticPageType $type): \App\Models\StaticPage { return Cache::rememberForever( sprintf('%sStaticPage', $type->name), @@ -186,7 +186,7 @@ class StaticPage extends Model * * @return \Illuminate\Database\Eloquent\Collection */ - public static function getCachedBreedingStaticPages() + public static function getCachedBreedingStaticPages(): \Illuminate\Database\Eloquent\Collection { return Cache::rememberForever( 'breedingStaticPages', diff --git a/app/Models/Submeat.php b/app/Models/Submeat.php index 9662b818..8c003cce 100644 --- a/app/Models/Submeat.php +++ b/app/Models/Submeat.php @@ -133,7 +133,7 @@ class Submeat extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedSubmeatsOrderedByOrder'); self::getPublishedOrdered(); diff --git a/app/Models/Subrange.php b/app/Models/Subrange.php index a9558e05..e37f92fc 100644 --- a/app/Models/Subrange.php +++ b/app/Models/Subrange.php @@ -132,7 +132,7 @@ class Subrange extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedSubrangesOrderedByOrder'); self::getPublishedOrdered(); diff --git a/app/Models/Testimonial.php b/app/Models/Testimonial.php index 79b787ec..4e09f2cf 100644 --- a/app/Models/Testimonial.php +++ b/app/Models/Testimonial.php @@ -115,7 +115,7 @@ class Testimonial extends Model * @param integer $max * @return void */ - private static function checkPublishedCount(self $model, int $max) + private static function checkPublishedCount(self $model, int $max): void { Validator::make(['published' => $model->published], [ 'published' => Rule::prohibitedIf( @@ -137,7 +137,7 @@ class Testimonial extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('publishedTestimonialsOrderedByOrder'); self::getPublishedOrdered(); diff --git a/app/Models/Video.php b/app/Models/Video.php index eb637122..223b9511 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -87,7 +87,7 @@ class Video extends Model * * @return void */ - private static function resetCache() + private static function resetCache(): void { Cache::forget('9publishedHomeVideosOrderedByOrderWithProducts'); self::get9PublishedHomeVideosOrderedWithProducts(); diff --git a/app/Notifications/Customer/DestroyCustomer.php b/app/Notifications/Customer/DestroyCustomer.php index db830229..95799ca7 100644 --- a/app/Notifications/Customer/DestroyCustomer.php +++ b/app/Notifications/Customer/DestroyCustomer.php @@ -10,13 +10,10 @@ class DestroyCustomer extends Notification /** * Get the notification's delivery channels. * - * @param object $notifiable * @return array - * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - public function via(object $notifiable): array + public function via(): array { - // phpcs:enable return ['mail']; } @@ -28,15 +25,12 @@ class DestroyCustomer extends Notification */ public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage { - /** @var string $firstname */ - $firstname = $notifiable->username; - return (new MailMessage()) ->template('notifications::email-club') ->subject(trans('Supression du compte - :site_name', [ 'site_name' => config('app.name') ])) - ->greeting(trans('Bonjour :name', ['name' => $firstname])) + ->greeting(trans('Bonjour :name', ['name' => $notifiable->username])) ->line(trans( "Votre compte :site_name a été marqué pour suppression, il sera définitivement effacé au bout de 1 semaine. diff --git a/app/Notifications/Customer/DestroyedCustomer.php b/app/Notifications/Customer/DestroyedCustomer.php index 5a4eec54..50e43778 100644 --- a/app/Notifications/Customer/DestroyedCustomer.php +++ b/app/Notifications/Customer/DestroyedCustomer.php @@ -10,26 +10,20 @@ class DestroyedCustomer extends Notification /** * Get the notification's delivery channels. * - * @param object $notifiable * @return array - * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - public function via(object $notifiable): array + public function via(): array { - // phpcs:enable return ['mail']; } /** * Build the mail representation of the notification. * - * @param object $notifiable * @return \Illuminate\Notifications\Messages\MailMessage - * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage + public function toMail(): \Illuminate\Notifications\Messages\MailMessage { - // phpcs:enable return (new MailMessage()) ->template('notifications::email-club') ->subject(trans('Votre compte est suprimé - :site_name', [ @@ -40,9 +34,7 @@ class DestroyedCustomer extends Notification "Votre compte :site_name a été définitivement supprimé ainsi ques les données associés, si vous aviez effectué une commande elle sera bien sûr toujours honorée. Les commandes associés a votre compte continueront d'exister mais les données de votre compte ont bien été supprimées.", - [ - 'site_name' => config('app.name') - ] + ['site_name' => config('app.name')] )); } } diff --git a/app/Notifications/Customer/ResetPassword.php b/app/Notifications/Customer/ResetPassword.php index dc25a310..14ed5bee 100644 --- a/app/Notifications/Customer/ResetPassword.php +++ b/app/Notifications/Customer/ResetPassword.php @@ -9,7 +9,7 @@ use Illuminate\Support\Facades\URL; class ResetPassword extends NotificationsResetPassword { /** - * ResetPassword + * Reset password. * * @param string $token * @return void diff --git a/app/Notifications/Customer/UpdateEmail.php b/app/Notifications/Customer/UpdateEmail.php index 01ec44a9..31864fdd 100644 --- a/app/Notifications/Customer/UpdateEmail.php +++ b/app/Notifications/Customer/UpdateEmail.php @@ -10,13 +10,10 @@ class UpdateEmail extends Notification /** * Get the notification's delivery channels. * - * @param object $notifiable * @return array - * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - public function via(object $notifiable): array + public function via(): array { - // phpcs:enable return ['mail']; } @@ -28,15 +25,12 @@ class UpdateEmail extends Notification */ public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage { - /** @var string $firstname */ - $firstname = $notifiable->username; - return (new MailMessage()) ->template('notifications::email-club') ->subject(trans("Mise à jour de l'email - :site_name", [ 'site_name' => config('app.name') ])) - ->greeting(trans('Bonjour :name', ['name' => $firstname])) + ->greeting(trans('Bonjour :name', ['name' => $notifiable->username])) ->line(trans("L'email associé à votre compte :site_name vient d'être modifié.", [ 'site_name' => config('app.name') ])); diff --git a/app/Notifications/Customer/UpdatePassword.php b/app/Notifications/Customer/UpdatePassword.php index 5dc6b402..a3d0d7e2 100644 --- a/app/Notifications/Customer/UpdatePassword.php +++ b/app/Notifications/Customer/UpdatePassword.php @@ -10,13 +10,10 @@ class UpdatePassword extends Notification /** * Get the notification's delivery channels. * - * @param object $notifiable * @return array - * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass */ - public function via(object $notifiable): array + public function via(): array { - // phpcs:enable return ['mail']; } @@ -28,15 +25,12 @@ class UpdatePassword extends Notification */ public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage { - /** @var string $firstname */ - $firstname = $notifiable->username; - return (new MailMessage()) ->template('notifications::email-club') ->subject(trans("Mise à jour du mot de passe - :site_name", [ 'site_name' => config('app.name') ])) - ->greeting(trans('Bonjour :name', ['name' => $firstname])) + ->greeting(trans('Bonjour :name', ['name' => $notifiable->username])) ->line(trans("Le mot de passe associé à votre compte :site_name vient d'être modifié.", [ 'site_name' => config('app.name') ])); diff --git a/app/Notifications/Customer/VerifyEmail.php b/app/Notifications/Customer/VerifyEmail.php index 870079da..15135f98 100644 --- a/app/Notifications/Customer/VerifyEmail.php +++ b/app/Notifications/Customer/VerifyEmail.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\URL; class VerifyEmail extends NotificationsVerifyEmail { /** - * VerifyEmail + * Verify email. * * @return void */ diff --git a/app/Policies/SellItemPolicy.php b/app/Policies/SellItemPolicy.php index ed6299ea..ed08159a 100644 --- a/app/Policies/SellItemPolicy.php +++ b/app/Policies/SellItemPolicy.php @@ -11,6 +11,7 @@ class SellItemPolicy /** * Determine whether the user can view any models. * + * @param \App\Models\User $authUser * @return boolean */ public function viewAny(User $authUser): bool diff --git a/app/Providers/CrmApiServiceProvider.php b/app/Providers/CrmApiServiceProvider.php index 20732fce..5c161492 100644 --- a/app/Providers/CrmApiServiceProvider.php +++ b/app/Providers/CrmApiServiceProvider.php @@ -13,7 +13,7 @@ class CrmApiServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { App::singleton('crmAPI', function () { return new CrmApiV4( diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index c4eee026..71a08fab 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -50,7 +50,7 @@ class EventServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { Event::listen('Slides\Saml2\Events\SignedIn', function (SignedIn $event) { $messageId = $event->getAuth()->getLastMessageId(); diff --git a/app/Providers/MesBrApiServiceProvider.php b/app/Providers/MesBrApiServiceProvider.php index 6a9a0564..c0abe219 100644 --- a/app/Providers/MesBrApiServiceProvider.php +++ b/app/Providers/MesBrApiServiceProvider.php @@ -13,7 +13,7 @@ class MesBrApiServiceProvider extends ServiceProvider * * @return void */ - public function boot() + public function boot(): void { App::singleton('mesBrAPI', function () { return new MesBr( diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 7cc7e92d..23dc8497 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -144,7 +144,7 @@ class RouteServiceProvider extends ServiceProvider * * @return void */ - private function cspReportRoute() + private function cspReportRoute(): void { // * CSP REPORT URI, Please add /csp-report to VerifyCsrfToken $except middleware Route::post('/csp-report', function () { diff --git a/app/Providers/ViewServiceProvider.php b/app/Providers/ViewServiceProvider.php index 6de03d6c..d7818efc 100644 --- a/app/Providers/ViewServiceProvider.php +++ b/app/Providers/ViewServiceProvider.php @@ -96,6 +96,7 @@ class ViewServiceProvider extends ServiceProvider }); // * Inject some data for the bo menu. + // @phpcs:disable Generic.Files.LineLength.TooLong collect([ ['name' => 'customerModelsCount', 'value' => Customer::query()->count()], ['name' => 'firstMeat', 'value' => Meat::query()->first()], @@ -104,62 +105,27 @@ class ViewServiceProvider extends ServiceProvider ['name' => 'mainMenuMeatModels', 'value' => Meat::getPublishedOrdered()], ['name' => 'homeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::home)], ['name' => 'storyStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::story)], - [ - 'name' => 'recruitmentStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::recruitment) - ], + ['name' => 'recruitmentStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recruitment)], ['name' => 'sagaStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::saga)], - [ - 'name' => 'recipesStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipes) - ], - [ - 'name' => 'recipeStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipe) - ], - [ - 'name' => 'productsStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::products) - ], + ['name' => 'recipesStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipes)], + ['name' => 'recipeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipe)], + ['name' => 'productsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::products)], ['name' => 'legalsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::legals)], - [ - 'name' => 'confidentialityStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::confidentiality) - ], - [ - 'name' => 'sellingStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::selling) - ], - [ - 'name' => 'accessibilityStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::accessibility) - ], - [ - 'name' => 'productStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::product) - ], - [ - 'name' => 'breedingPoultryStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingPoultry) - ], - [ - 'name' => 'breedingJobStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingJob) - ], - [ - 'name' => 'breedingFoodStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingFood) - ], - [ - 'name' => 'breedingHealthStaticPageModel', - 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingHealth) - ], + ['name' => 'confidentialityStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::confidentiality)], + ['name' => 'sellingStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::selling)], + ['name' => 'accessibilityStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::accessibility)], + ['name' => 'productStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::product)], + ['name' => 'breedingPoultryStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingPoultry)], + ['name' => 'breedingJobStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingJob)], + ['name' => 'breedingFoodStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingFood)], + ['name' => 'breedingHealthStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingHealth)], ['name' => 'newsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::news)], ])->map(function ($array) { View::share($array['name'], (function () use ($array) { return $array['value'] ?: null; })()); }); + // phpcs:enable } //end if } } diff --git a/app/Rules/Hex.php b/app/Rules/Hex.php index 3ad3239a..199be1a8 100755 --- a/app/Rules/Hex.php +++ b/app/Rules/Hex.php @@ -69,7 +69,7 @@ class Hex implements ValidationRule * * @return string */ - public function message() + public function message(): string { return 'The hex code is not valid'; } diff --git a/app/Rules/IsValidVimeoId.php b/app/Rules/IsValidVimeoId.php index 4a91da6e..6cf03f67 100644 --- a/app/Rules/IsValidVimeoId.php +++ b/app/Rules/IsValidVimeoId.php @@ -31,7 +31,7 @@ class IsValidVimeoId implements ValidationRule } /** - * Validate a value + * Validate a value. * * @param mixed $value * @return boolean diff --git a/app/Rules/IsValidYoutubeId.php b/app/Rules/IsValidYoutubeId.php index 1a410091..b4c3634b 100644 --- a/app/Rules/IsValidYoutubeId.php +++ b/app/Rules/IsValidYoutubeId.php @@ -32,7 +32,7 @@ class IsValidYoutubeId implements ValidationRule } /** - * Validate a value + * Validate a value. * * @param mixed $value * @return boolean diff --git a/app/Traits/Controllers/UpdateModelPublished.php b/app/Traits/Controllers/UpdateModelPublished.php index ae43ef88..7b0c9e33 100644 --- a/app/Traits/Controllers/UpdateModelPublished.php +++ b/app/Traits/Controllers/UpdateModelPublished.php @@ -17,7 +17,7 @@ trait UpdateModelPublished * @param \Illuminate\Database\Eloquent\Model $model * @return \Illuminate\Http\RedirectResponse */ - public function changePublished(Model $model) + public function changePublished(Model $model): \Illuminate\Http\RedirectResponse { $model->update(['published' => !$model->getOriginal('published')]); return redirect()->back()->with('success', trans('crud.messages.publish_status_saved')); diff --git a/app/Traits/Models/IsCachedAsCollection.php b/app/Traits/Models/IsCachedAsCollection.php index 4bbb536c..aec7e468 100644 --- a/app/Traits/Models/IsCachedAsCollection.php +++ b/app/Traits/Models/IsCachedAsCollection.php @@ -36,7 +36,7 @@ trait IsCachedAsCollection } /** - * Remove cached elements + * Remove cached elements. * * @return void */ @@ -63,7 +63,7 @@ trait IsCachedAsCollection } /** - * Change query for cached elements + * Change query for cached elements. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder @@ -74,7 +74,7 @@ trait IsCachedAsCollection } /** - * Change query for cached elements + * Change query for cached elements. * * @param \Illuminate\Support\Collection $results * @return \Illuminate\Support\Collection @@ -85,7 +85,7 @@ trait IsCachedAsCollection } /** - * Get the class basename + * Get the class basename. * * @return string */ @@ -95,7 +95,7 @@ trait IsCachedAsCollection } /** - * Get the class basename + * Get the class basename. * * @return string */ diff --git a/app/Traits/Models/MiniCrudModel.php b/app/Traits/Models/MiniCrudModel.php index e73fefa6..2593f830 100644 --- a/app/Traits/Models/MiniCrudModel.php +++ b/app/Traits/Models/MiniCrudModel.php @@ -27,7 +27,7 @@ trait MiniCrudModel } /** - * Apply function on data typed text while on save event + * Apply function on data typed text while on save event. * * @return void */ @@ -47,7 +47,7 @@ trait MiniCrudModel } /** - * Apply function on data typed text while on update event + * Apply function on data typed text while on update event. * * @return void */ @@ -57,7 +57,7 @@ trait MiniCrudModel } /** - * Apply function on data typed text while on updated event + * Apply function on data typed text while on updated event. * * @return void */ @@ -78,7 +78,7 @@ trait MiniCrudModel } /** - * Apply function on data typed text while on deleted event + * Apply function on data typed text while on deleted event. * * @return void */ @@ -95,7 +95,7 @@ trait MiniCrudModel } /** - * Set a specific prop + * Set a specific prop. * * @param array $data * @return void @@ -110,7 +110,7 @@ trait MiniCrudModel } /** - * Set a specific prop + * Set a specific prop. * * @param array $value * @return void @@ -124,7 +124,7 @@ trait MiniCrudModel } /** - * Set a specific prop + * Set a specific prop. * * @param string|null $data * @return array @@ -135,7 +135,7 @@ trait MiniCrudModel } /** - * Serialize properties + * Serialize properties. * * @param array $data * @return array diff --git a/app/Traits/Requests/HasPicture.php b/app/Traits/Requests/HasPicture.php index aa72cad8..23a6bf34 100644 --- a/app/Traits/Requests/HasPicture.php +++ b/app/Traits/Requests/HasPicture.php @@ -38,7 +38,7 @@ trait HasPicture private $maxHeight = 1800; /** - * Image rules + * Image rules. * * @param string $name * @param integer|null $minWidth @@ -85,7 +85,7 @@ trait HasPicture } /** - * Images rules + * Images rules. * * @param string $name * @param integer|null $minWidth @@ -108,9 +108,9 @@ trait HasPicture bool $nullable = false ): array { $sizes = (object)[ - 'minWidth' => $minWidth ?? $this->minWidth, + 'minWidth' => $minWidth ?? $this->minWidth, 'minHeight' => $minHeight ?? $this->minHeight, - 'maxWidth' => $maxWidth ?? $this->maxWidth, + 'maxWidth' => $maxWidth ?? $this->maxWidth, 'maxHeight' => $maxHeight ?? $this->maxHeight, ]; return [ @@ -126,7 +126,7 @@ trait HasPicture } /** - * Merges products pictures fields with request data + * Merges products pictures fields with request data. * * @param string $name * @return void @@ -153,7 +153,7 @@ trait HasPicture $this->merge([ $name => $changedPicture ]); -// le else if sert a gerer le cas ou l'image de la bannière produit est nulle + // FIXME: patch because of component return. } elseif (is_null($picturePath)) { $this->merge([$name => null]); return; @@ -161,7 +161,7 @@ trait HasPicture } /** - * Merges products pictures fields with request data + * Merges products pictures fields with request data. * * @param string $name * @return void diff --git a/app/View/Components/Fo/Story/HistoricalMilestoneComponent.php b/app/View/Components/Fo/Story/HistoricalMilestoneComponent.php index cb27e729..ae383f80 100644 --- a/app/View/Components/Fo/Story/HistoricalMilestoneComponent.php +++ b/app/View/Components/Fo/Story/HistoricalMilestoneComponent.php @@ -3,7 +3,6 @@ namespace App\View\Components\Fo\Story; use Closure; -use Illuminate\Contracts\View\View; use Illuminate\View\Component; use App\Models\StaticPage; use App\Enums\StaticPageType; @@ -23,7 +22,7 @@ class HistoricalMilestoneComponent extends Component public function __construct() { $this->staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::story); - $this->historicalMilestoneModels = HistoricalMilestone::getPublishedOrderedByYear(); + $this->historicalMilestoneModels = HistoricalMilestone::getPublishedOrdered(); } /** @@ -31,10 +30,10 @@ class HistoricalMilestoneComponent extends Component * * @return \Illuminate\Contracts\View\View */ - public function render(): View|Closure|string + public function render(): \Illuminate\Contracts\View\View|Closure|string { return view('components.fo.story.historical-milestone-component', [ - 'staticPageModel' => $this->staticPageModel, + 'staticPageModel' => $this->staticPageModel, 'historicalMilestoneModels' => $this->historicalMilestoneModels ]); } diff --git a/app/View/Components/Fo/Story/WhoWeAre.php b/app/View/Components/Fo/Story/WhoWeAre.php index 7dd717a8..33e6e0e1 100644 --- a/app/View/Components/Fo/Story/WhoWeAre.php +++ b/app/View/Components/Fo/Story/WhoWeAre.php @@ -3,7 +3,6 @@ namespace App\View\Components\Fo\Story; use Closure; -use Illuminate\Contracts\View\View; use Illuminate\View\Component; use App\Models\StaticPage; use App\Enums\StaticPageType; @@ -32,7 +31,7 @@ class WhoWeAre extends Component * * @return \Illuminate\Contracts\View\View */ - public function render(): View|Closure|string + public function render(): \Illuminate\Contracts\View\View|Closure|string { return view('components.fo.story.who-we-are', [ 'staticPageModel' => $this->staticPageModel,