Skip to content

Commit

Permalink
Fix psalm errors about groupExists return type
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Apr 27, 2023
1 parent 5149f1c commit 3e399f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
12 changes: 4 additions & 8 deletions apps/user_ldap/lib/Group_Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,10 @@ public function groupExists($gid) {
* {@inheritdoc}
*/
public function groupsExists(array $gids): array {
$existingGroups = [];
foreach ($gids as $gid) {
$exists = $this->handleRequest($gid, 'groupExists', [$gid]);
if ($exists) {
$existingGroups[$gid] = $gid;
}
}
return $existingGroups;
return array_values(array_filter(
$gids,
fn (string $gid): bool => $this->handleRequest($gid, 'groupExists', [$gid]),
));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function isSingleBackend(): bool {
* @param string $method string, the method of the user backend that shall be called
* @param array $parameters an array of parameters to be passed
* @param bool $passOnWhen
* @return mixed, the result of the specified method
* @return mixed the result of the specified method
*/
protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
if (!$this->isSingleBackend()) {
Expand Down
12 changes: 4 additions & 8 deletions lib/public/Group/Backend/ABackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ public function implementsActions($actions): bool {
* @since 26.0.0
*/
public function groupsExists(array $gids): array {
$existingGroups = [];
foreach ($gids as $gid) {
$exists = $this->groupExists($gid);
if ($exists) {
$existingGroups[$gid] = $gid;
}
}
return $existingGroups;
return array_values(array_filter(
$gids,
fn (string $gid): bool => $this->groupExists($gid),
));
}

/**
Expand Down

0 comments on commit 3e399f5

Please sign in to comment.