Skip to content

Commit

Permalink
fix(optional-policies): calm down some PHPStan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaucau committed Dec 4, 2024
1 parent 5539e46 commit 1ffbb18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Repositories/PolicyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ public function clearCache()
$this->cache->forget(self::CACHE_KEY);
}

/**
* @param string $id
*
* @return Policy
*/
public function findOrFail(string $id): Policy
{
/** @phpstan-ignore-next-line Method FoF\Terms\Repositories\PolicyRepository::findOrFail() should return FoF\Terms\Policy but returns Illuminate\Database\Eloquent\Model. */
return $this->policy->newQuery()->findOrFail($id);
}

Expand All @@ -82,10 +78,14 @@ public function state(User $user)
$this->rememberState = [];

foreach ($this->all() as $policy) {
/** @phpstan-ignore-next-line Access to an undefined property FoF\Terms\Policy::$pivot */
$accepted_at = $userPolicies->has($policy->id) ? Carbon::parse($userPolicies->get($policy->id)->pivot->accepted_at) : null;
$has_update = !$accepted_at || (($policy->terms_updated_at !== null) && $policy->terms_updated_at->gt($accepted_at));
$optional = $policy->optional;
/** @var bool $is_accepted */
/**
* @var bool $is_accepted
* @phpstan-ignore-next-line Access to an undefined property FoF\Terms\Policy::$pivot
*/
$is_accepted = $userPolicies->has($policy->id) ? $userPolicies->get($policy->id)->pivot->is_accepted : false;

$this->rememberState[$policy->id] = [
Expand Down

0 comments on commit 1ffbb18

Please sign in to comment.