From 1e25a5d10257b5c65e5d204276819243634c43b5 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sat, 25 Dec 2021 09:45:31 -0500 Subject: [PATCH] fix: ignore phpstan errors due to inferring wrong --- app/Models/ServiceRecord.php | 3 ++- database/factories/ServiceRecordFactory.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Models/ServiceRecord.php b/app/Models/ServiceRecord.php index 1bb961ea..fda04175 100644 --- a/app/Models/ServiceRecord.php +++ b/app/Models/ServiceRecord.php @@ -166,6 +166,7 @@ public function getHydratedMedalsAttribute(): Collection $medal['count'] = $medals[$medal->id] ?? 0; return $medal; })->reject(function (Medal $medal) { + // @phpstan-ignore-next-line return $medal->count === 0; })->sortByDesc('count')->chunk(5); } @@ -217,7 +218,7 @@ public static function fromHaloDotApi(array $payload): ?self return [ $medal['id'] => $medal['count'] ]; - }); + })->toArray(); // If we get no time played or score. We are going to assume account is private. if ($serviceRecord->total_seconds_played === 0 && $serviceRecord->total_score === 0) { diff --git a/database/factories/ServiceRecordFactory.php b/database/factories/ServiceRecordFactory.php index 0950b38a..a78107c7 100644 --- a/database/factories/ServiceRecordFactory.php +++ b/database/factories/ServiceRecordFactory.php @@ -61,6 +61,7 @@ public function withMedals(): self $medals = Medal::factory()->count(2)->create(); return [ + // @phpstan-ignore-next-line 'medals' => $medals->mapWithKeys(function (Medal $medal) { return [ $medal->id => $this->faker->numberBetween(1, 25)