Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix call to an undefined method Role::getRoleClass #2411

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
parameters:
ignoreErrors:
-
# PHPStan can't understand what's going on in context of Role class using Builder `when`
message: "#^Call to an undefined method Spatie\\\\Permission\\\\Models\\\\Role::getRoleClass\\(\\).$#"
count: 1
path: src\Traits\HasPermissions.php
2 changes: 1 addition & 1 deletion src/Traits/HasPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function scopePermission(Builder $query, $permissions): Builder

$permissionClass = $this->getPermissionClass();
$permissionKey = (new $permissionClass())->getKeyName();
$roleClass = $this->getRoleClass();
$roleClass = is_a($this, Role::class) ? static::class : $this->getRoleClass();
$roleKey = (new $roleClass())->getKeyName();

$rolesWithPermissions = is_a($this, Role::class) ? [] : array_unique(
Expand Down