Skip to content

Commit

Permalink
Fix phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Jun 21, 2024
1 parent 41977f3 commit 792362d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
paths:
- '**.php'
- 'phpstan.neon.dist'
pull_request:
paths:
- '**.php'
- 'phpstan.neon.dist'

jobs:
phpstan:
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ parameters:
- database/migrations/add_teams_fields.php.stub
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkMissingIterableValueType: false

ignoreErrors:
- '#Unsafe usage of new static#'
Expand Down
10 changes: 6 additions & 4 deletions src/Traits/HasRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@ public function hasRole($roles, ?string $guard = null): bool

return $this->roles
->when($guard, fn ($q) => $q->where('guard_name', $guard))
->contains(function ($role) use ($roles) {
if ($role->name instanceof \BackedEnum) {
return $role->name->value == $roles;
->pluck('name')
->contains(function ($name) use ($roles) {
/** @var string|\BackedEnum $name */
if ($name instanceof \BackedEnum) {
return $name->value == $roles;
}

return $role->name == $roles;
return $name == $roles;
});
}

Expand Down

0 comments on commit 792362d

Please sign in to comment.