diff --git a/app/Models/News.php b/app/Models/News.php index 89a10b89..8463c99a 100644 --- a/app/Models/News.php +++ b/app/Models/News.php @@ -434,7 +434,6 @@ class News extends Model implements TranslatableModel, LocalizedUrlRoutable * Get all published news by category. * * @param string $category - * * @return \Illuminate\Database\Eloquent\Collection */ public static function getPublishedNewsByCategoryInCurrentLocale(string $category) diff --git a/app/Traits/Models/HasCache.php b/app/Traits/Models/HasCache.php index 86040e9a..fd06c0a3 100644 --- a/app/Traits/Models/HasCache.php +++ b/app/Traits/Models/HasCache.php @@ -28,6 +28,7 @@ trait HasCache static::deleted(function () { self::resetCache(); }); + /** @phpstan-ignore-next-line */ if (method_exists(static::class, 'initializeSoftDeletes')) { static::restored(function () { self::resetCache(); diff --git a/app/Traits/Models/HasUwilImages.php b/app/Traits/Models/HasUwilImages.php index 593843ab..eaadb519 100644 --- a/app/Traits/Models/HasUwilImages.php +++ b/app/Traits/Models/HasUwilImages.php @@ -42,9 +42,11 @@ trait HasUwilImages */ protected static function bootHasUwilImages(): void { + /** @phpstan-ignore-next-line */ $hadSoftDelete = method_exists(static::class, 'initializeSoftDeletes'); if ($hadSoftDelete) { + /** @phpstan-ignore-next-line */ static::forceDeleted(function (self $model) { self::initLoop($model, self::FORCE_DELETE_ACTION); }); @@ -134,9 +136,8 @@ trait HasUwilImages continue; } //end if - // PAS TESTE. + // TODO pas testé if (is_array($originalValue) && is_array($currentValue)) { - dd('juste array'); static::traverseAndManage( $model, $originalValue, @@ -168,7 +169,7 @@ trait HasUwilImages $forceDeleteImage = $eventType === self::FORCE_DELETE_ACTION; $imagesFields = self::getImageFields($model); $wysiwygFields = self::getWysiwygFields($model); - $isTranslatable = method_exists($model, 'getTranslations') ?? false; + $isTranslatable = method_exists($model, 'getTranslations'); $locale = config('app.locale'); $availableLocales = array_keys(config('laravellocalization.supportedLocales', ['fr' => "Frenchouz"])); @@ -230,7 +231,6 @@ trait HasUwilImages $path = $isList ? "$fieldPath.$key" : (is_int($key) ? $fieldPath : "$fieldPath.$key"); // TODO cette récursivité n'a pas encore été testé. if (is_array($oldValue) || is_array($newValue)) { - dd('pas testé'); static::traverseAndManage( $model, (array) $oldValue, diff --git a/app/Traits/Requests/HasInertiaPicture.php b/app/Traits/Requests/HasInertiaPicture.php index 22761c06..7371b9af 100644 --- a/app/Traits/Requests/HasInertiaPicture.php +++ b/app/Traits/Requests/HasInertiaPicture.php @@ -13,7 +13,7 @@ trait HasInertiaPicture */ protected function mergeInertiaPicture(): void { - if (empty($this->convertedFiles) || !is_array($this->convertedFiles)) { + if (empty($this->convertedFiles)) { return; } $original = $this->all(); @@ -47,7 +47,7 @@ trait HasInertiaPicture * Set picture rules (UploadedFile or string path). * * @param string $rules - * @return array + * @return array */ protected function pictureRules(string $rules): array { diff --git a/app/View/Components/Front/News/NewsNextEventComponent.php b/app/View/Components/Front/News/NewsNextEventComponent.php index ae85b805..dee69932 100644 --- a/app/View/Components/Front/News/NewsNextEventComponent.php +++ b/app/View/Components/Front/News/NewsNextEventComponent.php @@ -9,7 +9,7 @@ use Illuminate\View\Component; class NewsNextEventComponent extends Component { - /** @var array<\App\Models\News> $nextEvents List of published news. */ + /** @var \Illuminate\Support\Collection $nextEvents List of published news. */ public $nextEvents; /** @@ -17,20 +17,26 @@ class NewsNextEventComponent extends Component */ public function __construct() { + /** @var \App\Models\NewsCategory|null $newsCategory */ $newsCategory = NewsCategory::getModelsCached() ->filter(fn($category) => $category->getTranslation('slug', 'fr') === "actualites") ->first(); + /** @var \App\Models\NewsTag|null $eventTag */ $eventTag = NewsTag::getTagsByCategoryInCurrentLocale($newsCategory->slug) - ->filter(fn($tag) => $tag->getTranslation('slug', 'fr') === "evenement") + ->filter( + fn(\Illuminate\Database\Eloquent\Model $tag) => + $tag instanceof \App\Models\NewsTag && $tag->getTranslation('slug', 'fr') === "evenement" + ) ->first(); $eventTagId = $eventTag ? $eventTag->id : null; + /** @var \Illuminate\Support\Collection $nextEvents */ $this->nextEvents = News::getPublishedNewsByCategoryInCurrentLocale($newsCategory->slug) ->filter(function ($news) use ($eventTagId) { return $news->tags->contains( - fn ($tag) => $eventTagId === $tag->id + fn($tag) => $tag instanceof \App\Models\NewsTag && $eventTagId === $tag->id ); }) ->sortByDesc('published_at') diff --git a/app/View/Components/Front/Pages/KnowUs/OurImplantations.php b/app/View/Components/Front/Pages/KnowUs/OurImplantations.php index d2b43285..f6ee402d 100644 --- a/app/View/Components/Front/Pages/KnowUs/OurImplantations.php +++ b/app/View/Components/Front/Pages/KnowUs/OurImplantations.php @@ -11,13 +11,13 @@ class OurImplantations extends Component /** @var string $id Identification of the section. */ public string $id; - /** @var $implantations Content section. */ + /** @var array Content section. */ public $implantations; - /** @var array<\App\Models\Company> $companyModels List of published companies. */ + /** @var \Illuminate\Database\Eloquent\Collection $companyModels List of published companies. */ public $companyModels; - /** @var array<\App\Models\CompanyActivity> $companyActivityModels List of published company activities. */ + /** @var \Illuminate\Database\Eloquent\Collection $companyActivityModels List of published company activities. */ public $companyActivityModels; /**