Skip to content

Commit 3597cd0

Browse files
committed
fix: psalm
1 parent 3c494fb commit 3597cd0

3 files changed

Lines changed: 72 additions & 21 deletions

File tree

lib/AppConfigOverwrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function setOverwrite(array $overwrite): void {
1919
$this->overWrite = $overwrite;
2020
}
2121

22-
public function getValue($app, $key, string $default = ''): string {
22+
public function getValue($app, $key, $default = ''): string {
2323
if (isset($this->overWrite[$app]) && isset($this->overWrite[$app][$key])) {
2424
return $this->overWrite[$app][$key];
2525
}

lib/GroupBackend.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,29 @@ private function getMembers(): array {
4444
}
4545

4646
/**
47-
* Checks whether the user is member of a group or not.
47+
* is user in group?
4848
*
49+
* @param string $uid uid of the user
50+
* @param string $gid gid of the group
4951
* @since 4.5.0
52+
*
53+
* Checks whether the user is member of a group or not.
5054
*/
51-
public function inGroup(string $uid, string $gid): bool {
55+
public function inGroup($uid, $gid): bool {
5256
return $gid === $this->groupName && $this->guestManager->isGuest($uid);
5357
}
5458

5559
/**
56-
* This function fetches all groups a user belongs to. It does not check
57-
* if the user exists at all.
60+
* Get all groups a user belongs to
5861
*
62+
* @param string $uid Name of the user
63+
* @return list<string> an array of group names
5964
* @since 4.5.0
65+
*
66+
* This function fetches all groups a user belongs to. It does not check
67+
* if the user exists at all.
6068
*/
61-
public function getUserGroups(string $uid): array {
69+
public function getUserGroups($uid): array {
6270
if ($this->guestManager->isGuest($uid)) {
6371
return [$this->groupName];
6472
}
@@ -67,30 +75,40 @@ public function getUserGroups(string $uid): array {
6775
}
6876

6977
/**
70-
* Returns a list with all groups
78+
* get a list of all groups
7179
*
80+
* @param string $search
81+
* @param int $limit
82+
* @param int $offset
7283
* @since 4.5.0
84+
*
85+
* Returns a list with all groups
7386
*/
74-
public function getGroups(string $search = '', int $limit = -1, int $offset = 0): array {
87+
public function getGroups($search = '', $limit = -1, $offset = 0): array {
7588
return $offset == 0 ? [$this->groupName] : [];
7689
}
7790

7891
/**
7992
* check if a group exists
8093
*
94+
* @param string $gid
8195
* @since 4.5.0
8296
*/
83-
public function groupExists(string $gid): bool {
97+
public function groupExists($gid): bool {
8498
return $gid === $this->groupName;
8599
}
86100

87101
/**
88102
* get a list of all users in a group
89103
*
104+
* @param string $gid
105+
* @param string $search
106+
* @param int $limit
107+
* @param int $offset
90108
* @return array<int, string> an array of user ids
91109
* @since 4.5.0
92110
*/
93-
public function usersInGroup(string $gid, string $search = '', int $limit = -1, int $offset = 0): array {
111+
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0): array {
94112
if ($gid === $this->groupName) {
95113
if ($this->guestManager->isGuest() && $this->config->hideOtherUsers()) {
96114
return [$this->userSession->getUser()->getUID()];

lib/UserBackend.php

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ public function createUser(string $uid, string $password): bool {
8282
}
8383

8484
/**
85+
* Deletes a user
86+
*
87+
* @param string $uid The username of the user to delete
88+
*
8589
* Deletes a user
8690
*/
87-
public function deleteUser(string $uid): bool {
91+
public function deleteUser($uid): bool {
8892
// Delete user-group-relation
8993
$query = $this->dbConn->getQueryBuilder();
9094
$query->delete('guests_users')
@@ -168,18 +172,23 @@ public function setDisplayName(string $uid, string $displayName): bool {
168172

169173
/**
170174
* Get display name of the user
175+
*
176+
* @param string $uid user ID of the user
171177
*/
172-
public function getDisplayName(string $uid): string {
178+
public function getDisplayName($uid): string {
173179
$this->loadUser($uid);
174180
return empty($this->cache[$uid]['displayname']) ? $uid : $this->cache[$uid]['displayname'];
175181
}
176182

177183
/**
178184
* Get a list of all display names and user ids.
179185
*
186+
* @param string $search
187+
* @param int|null $limit
188+
* @param int|null $offset
180189
* @return array an array of all displayNames (value) and the corresponding uids (key)
181190
*/
182-
public function getDisplayNames(string $search = '', ?int $limit = null, ?int $offset = null): array {
191+
public function getDisplayNames($search = '', $limit = null, $offset = null): array {
183192
if (!$this->allowListing) {
184193
return [];
185194
} else {
@@ -221,8 +230,11 @@ public function getDisplayNames(string $search = '', ?int $limit = null, ?int $o
221230

222231
/**
223232
* Check if the password is correct without logging in the user
233+
* returns the user id or false
234+
*
235+
* @return string|false
224236
*/
225-
public function checkPassword(string|false $loginName, string $password): string|false {
237+
public function checkPassword(string $loginName, string $password) {
226238
if (strpos($loginName, '@') === false) {
227239
return false;
228240
}
@@ -255,8 +267,10 @@ public function checkPassword(string|false $loginName, string $password): string
255267

256268
/**
257269
* Load an user in the cache
270+
*
271+
* @param string $uid the username
258272
*/
259-
private function loadUser(string $uid): bool {
273+
private function loadUser($uid): bool {
260274
// guests $uid could be NULL or ''
261275
// or is not an email anyway
262276
if (strpos($uid, '@') === false) {
@@ -294,8 +308,13 @@ private function loadUser(string $uid): bool {
294308

295309
/**
296310
* Get a list of all users
311+
*
312+
* @param string $search
313+
* @param null|int $limit
314+
* @param null|int $offset
315+
* @return string[] an array of all uids
297316
*/
298-
public function getUsers(string $search = '', ?int $limit = null, ?int $offset = null): array {
317+
public function getUsers($search = '', $limit = null, $offset = null): array {
299318
$users = $this->getDisplayNames($search, $limit, $offset);
300319
$userIds = array_map(function ($uid) {
301320
return (string)$uid;
@@ -305,32 +324,41 @@ public function getUsers(string $search = '', ?int $limit = null, ?int $offset =
305324
}
306325

307326
/**
308-
* Check if user exists
327+
* Check if a user exists
328+
*
329+
* @param string $uid the username
309330
*/
310-
public function userExists(string $uid): bool {
331+
public function userExists($uid): bool {
311332
$this->loadUser($uid);
312333
return $this->cache[$uid] !== false;
313334
}
314335

315336
/**
316337
* Get the user's home directory
338+
*
339+
* @return string|false
317340
*/
318-
public function getHome(string $uid): string|false {
341+
public function getHome(string $uid) {
319342
if ($this->userExists($uid)) {
320343
return $this->config->getHome($uid);
321344
}
322345

323346
return false;
324347
}
325348

349+
/**
350+
* @return bool
351+
*/
326352
public function hasUserListings(): bool {
327353
return true;
328354
}
329355

330356
/**
331357
* Counts the users in the database
358+
*
359+
* @return int|false
332360
*/
333-
public function countUsers(): int|false {
361+
public function countUsers() {
334362
$query = $this->dbConn->getQueryBuilder();
335363
$query->select($query->func()->count('uid'))
336364
->from('guests_users');
@@ -341,8 +369,11 @@ public function countUsers(): int|false {
341369

342370
/**
343371
* Returns the username for the given login name in the correct casing
372+
*
373+
* @param string $loginName
374+
* @return string|false
344375
*/
345-
public function loginName2UserName(string $loginName): string|false {
376+
public function loginName2UserName($loginName) {
346377
if ($this->userExists($loginName)) {
347378
return $this->cache[$loginName]['uid'];
348379
}
@@ -352,6 +383,8 @@ public function loginName2UserName(string $loginName): string|false {
352383

353384
/**
354385
* Backend name to be shown in user management
386+
*
387+
* @return string the name of the backend to be shown
355388
*/
356389
public function getBackendName(): string {
357390
return 'Guests';

0 commit comments

Comments
 (0)