diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2023-05-23 19:00:38 +0200 |
---|---|---|
committer | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2023-09-06 11:58:09 +0200 |
commit | 312dd8ac6dce96353ac1f6e6c89e0e7d7840d03c (patch) | |
tree | 82f326e1015ca1d0e12ebe89aa5fb94a62968f4b /lib/private | |
parent | 00c0813ce6209e8910b60b48172743fc13bb1a15 (diff) | |
download | nextcloud-server-312dd8ac6dce96353ac1f6e6c89e0e7d7840d03c.tar.gz nextcloud-server-312dd8ac6dce96353ac1f6e6c89e0e7d7840d03c.zip |
feat(ocp): Add types and strict typing to \OCP\Group\IGroup
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Group/Group.php | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php index 441ee64604d..97521d54ba6 100644 --- a/lib/private/Group/Group.php +++ b/lib/private/Group/Group.php @@ -85,11 +85,11 @@ class Group implements IGroup { $this->displayName = $displayName; } - public function getGID() { + public function getGID(): string { return $this->gid; } - public function getDisplayName() { + public function getDisplayName(): string { if (is_null($this->displayName)) { foreach ($this->backends as $backend) { if ($backend instanceof IGetDisplayNameBackend) { @@ -126,7 +126,7 @@ class Group implements IGroup { * * @return \OC\User\User[] */ - public function getUsers() { + public function getUsers(): array { if ($this->usersLoaded) { return $this->users; } @@ -153,7 +153,7 @@ class Group implements IGroup { * @param IUser $user * @return bool */ - public function inGroup(IUser $user) { + public function inGroup(IUser $user): bool { if (isset($this->users[$user->getUID()])) { return true; } @@ -171,7 +171,7 @@ class Group implements IGroup { * * @param IUser $user */ - public function addUser(IUser $user) { + public function addUser(IUser $user): void { if ($this->inGroup($user)) { return; } @@ -200,10 +200,8 @@ class Group implements IGroup { /** * remove a user from the group - * - * @param \OC\User\User $user */ - public function removeUser($user) { + public function removeUser(IUser $user): void { $result = false; $this->dispatcher->dispatchTyped(new BeforeUserRemovedEvent($this, $user)); if ($this->emitter) { @@ -262,7 +260,7 @@ class Group implements IGroup { * @param string $search * @return int|bool */ - public function count($search = '') { + public function count($search = ''): int|bool { $users = false; foreach ($this->backends as $backend) { if ($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) { @@ -282,7 +280,7 @@ class Group implements IGroup { * * @return int|bool */ - public function countDisabled() { + public function countDisabled(): int|bool { $users = false; foreach ($this->backends as $backend) { if ($backend instanceof ICountDisabledInGroup) { @@ -306,7 +304,7 @@ class Group implements IGroup { * @return IUser[] * @deprecated 27.0.0 Use searchUsers instead (same implementation) */ - public function searchDisplayName($search, $limit = null, $offset = null) { + public function searchDisplayName(string $search, int $limit = null, int $offset = null): array { return $this->searchUsers($search, $limit, $offset); } @@ -315,7 +313,7 @@ class Group implements IGroup { * * @return string[] */ - public function getBackendNames() { + public function getBackendNames(): array { $backends = []; foreach ($this->backends as $backend) { if ($backend instanceof INamedBackend) { @@ -329,11 +327,11 @@ class Group implements IGroup { } /** - * delete the group + * Delete the group * * @return bool */ - public function delete() { + public function delete(): bool { // Prevent users from deleting group admin if ($this->getGID() === 'admin') { return false; @@ -378,7 +376,7 @@ class Group implements IGroup { * @return bool * @since 14.0.0 */ - public function canRemoveUser() { + public function canRemoveUser(): bool { foreach ($this->backends as $backend) { if ($backend->implementsActions(GroupInterface::REMOVE_FROM_GOUP)) { return true; @@ -391,7 +389,7 @@ class Group implements IGroup { * @return bool * @since 14.0.0 */ - public function canAddUser() { + public function canAddUser(): bool { foreach ($this->backends as $backend) { if ($backend->implementsActions(GroupInterface::ADD_TO_GROUP)) { return true; |