Fix phpstan error courtesy of the laravel 11 upgrade (changed signatures and return types)

This commit is contained in:
James Cole
2024-04-02 15:40:33 +02:00
parent 87911c2438
commit a17bc7258f
73 changed files with 2772 additions and 2827 deletions

View File

@@ -242,6 +242,30 @@ class UserRepository implements UserRepositoryInterface
return false;
}
#[\Override]
public function getUserGroups(User $user): Collection
{
$memberships = $user->groupMemberships()->get();
$set = [];
$collection = new Collection();
/** @var GroupMembership $membership */
foreach ($memberships as $membership) {
/** @var null|UserGroup $group */
$group = $membership->userGroup()->first();
if (null !== $group) {
$groupId = $group->id;
if (in_array($groupId, array_keys($set), true)) {
continue;
}
$set[$groupId] = $group;
}
}
$collection->push(...$set);
return $collection;
}
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser
{
$now = today(config('app.timezone'));
@@ -392,28 +416,4 @@ class UserRepository implements UserRepositoryInterface
return null !== $invitee;
}
#[\Override]
public function getUserGroups(User $user): Collection
{
$memberships = $user->groupMemberships()->get();
$set = [];
$collection = new Collection();
/** @var GroupMembership $membership */
foreach ($memberships as $membership) {
/** @var null|UserGroup $group */
$group = $membership->userGroup()->first();
if (null !== $group) {
$groupId = (int)$group->id;
if (in_array($groupId, $set, true)) {
continue;
}
$set[$groupId] = $group;
}
}
$collection->push(...$set);
return $collection;
}
}

View File

@@ -59,8 +59,6 @@ interface UserRepositoryInterface
public function changeStatus(User $user, bool $isBlocked, string $code): bool;
public function getUserGroups(User $user): Collection;
/**
* Returns a count of all users.
*/
@@ -96,6 +94,8 @@ interface UserRepositoryInterface
*/
public function getUserData(User $user): array;
public function getUserGroups(User $user): Collection;
public function hasRole(null|Authenticatable|User $user, string $role): bool;
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser;