diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 609d55a6..43a144af 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -5,6 +5,10 @@ on: paths: - '**.php' - 'phpstan.neon.dist' + pull_request: + paths: + - '**.php' + - 'phpstan.neon.dist' jobs: phpstan: diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3a451a16..02287840 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -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#' diff --git a/src/Traits/HasRoles.php b/src/Traits/HasRoles.php index 88013e85..fa537725 100644 --- a/src/Traits/HasRoles.php +++ b/src/Traits/HasRoles.php @@ -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; }); }