diff --git a/lib/Controller/GroupController.php b/lib/Controller/GroupController.php index 63d339216..735301d73 100644 --- a/lib/Controller/GroupController.php +++ b/lib/Controller/GroupController.php @@ -171,7 +171,7 @@ public function rename(string $newGroupName, $groups); if (!empty($groups) - && in_array($newGroupName, $groupsNameSearched)) { + && in_array($newGroupName, $groupsNameSearched, true)) { return new JSONResponse( 'This group already exists. Please, use another name', Http::STATUS_CONFLICT @@ -486,7 +486,7 @@ public function search(string $pattern, ?bool $ignoreSpaces = null, array $group }); } - $groups = array_filter($groups, fn ($group) => !in_array($group->getGID(), $groupsPresents)); + $groups = array_filter($groups, fn ($group) => !in_array($group->getGID(), $groupsPresents, true)); $groupsFormatted = GroupFormatter::formatGroups($groups); diff --git a/lib/Controller/WorkspaceApiOcsController.php b/lib/Controller/WorkspaceApiOcsController.php index 25f03457b..64c05903a 100644 --- a/lib/Controller/WorkspaceApiOcsController.php +++ b/lib/Controller/WorkspaceApiOcsController.php @@ -519,7 +519,7 @@ public function removeUsersFromGroup(int $id, string $gid, array $uids): DataRes $gids = array_keys($space['groups']); $spacename = $space['name']; - if (!in_array($gid, $gids)) { + if (!in_array($gid, $gids, true)) { throw new OCSException("Group {$gid} does not belongs to the {$spacename} workspace."); } @@ -599,7 +599,7 @@ public function addUsersToGroup(int $id, string $gid, array $uids): Response { $gids = array_keys($workspace['groups']); $spacename = $workspace['name']; - if (!in_array($gid, $gids)) { + if (!in_array($gid, $gids, true)) { throw new OCSForbiddenException("Group {$gid} does not belongs to the {$spacename} workspace."); } diff --git a/lib/Group/SubGroups/SubGroup.php b/lib/Group/SubGroups/SubGroup.php index 9aa16f179..10e4bc508 100644 --- a/lib/Group/SubGroups/SubGroup.php +++ b/lib/Group/SubGroups/SubGroup.php @@ -73,7 +73,7 @@ public function create(string $groupname, int $id, string $spacename): IGroup { $groupnames = array_map(fn ($group) => $group->getDisplayName(), $groupsSearched); if (!is_null($group)) { - if (in_array($displayName, $groupnames)) { + if (in_array($displayName, $groupnames, true)) { throw new GroupException("Group with display name $displayName already exists.", Http::STATUS_CONFLICT); } } diff --git a/lib/Service/Group/ConnectedGroupsService.php b/lib/Service/Group/ConnectedGroupsService.php index f8050f06d..5b60b5bea 100644 --- a/lib/Service/Group/ConnectedGroupsService.php +++ b/lib/Service/Group/ConnectedGroupsService.php @@ -59,7 +59,7 @@ public function getSpacesByGroups(array $gids): array { $linkedSpaceGroupsByUserGroups = []; $linkedSpaceGroupsByUserGroups = array_filter($linkedSpaceGroups, function ($spaceGid) use ($gids, $linkedSpaceGroups) { foreach ($gids as $gid) { - if (isset($linkedSpaceGroups[$spaceGid]) && in_array($gid, $linkedSpaceGroups[$spaceGid])) { + if (isset($linkedSpaceGroups[$spaceGid]) && in_array($gid, $linkedSpaceGroups[$spaceGid], true)) { return true; } } @@ -100,7 +100,7 @@ public function isConnectedToWorkspace(string $gid, array $spaceGids) : bool { foreach ($spaceGids as $spaceGid) { if (isset($linkedSpaceGroups[$spaceGid])) { - return in_array($gid, $linkedSpaceGroups[$spaceGid]); + return in_array($gid, $linkedSpaceGroups[$spaceGid], true); } } return false; @@ -156,7 +156,7 @@ public function hasConnectedGroups(string $gid, ?string $gidUserGroup = null) : if (!is_null($gidUserGroup)) { $values = $linkedSpaceGroups[$gidUserGroup]; if (!is_null($values)) { - return in_array($gid, $values); + return in_array($gid, $values, true); } return false; } @@ -183,10 +183,10 @@ public function add(IGroup $group, Space $space): bool { * @param string $uid user UID * @param string $spaceUserGid space-u group */ - public function isStrictSpaceUser(string $uid, string $spaceUserGid) { + public function isStrictSpaceUser(string $uid, string $spaceUserGid): bool { if (!isset($this->strictSpaceUsers[$spaceUserGid])) { $this->strictSpaceUsers[$spaceUserGid] = $this->mapper->getStrictSpaceUserIds($spaceUserGid); } - return in_array($uid, $this->strictSpaceUsers[$spaceUserGid]); + return in_array($uid, $this->strictSpaceUsers[$spaceUserGid], true); } } diff --git a/lib/Service/Group/GroupsWorkspaceService.php b/lib/Service/Group/GroupsWorkspaceService.php index 9c100dfc5..515a48615 100644 --- a/lib/Service/Group/GroupsWorkspaceService.php +++ b/lib/Service/Group/GroupsWorkspaceService.php @@ -78,8 +78,8 @@ public function getGroupsUserFromGroupfolder(IUser $user, array $groupfolder, st $groups = []; foreach ($this->groupManager->getUserGroups($user) as $group) { if ( - in_array($group->getGID(), array_keys($groupfolder['groups'])) - || in_array($group->getGID(), $groupsWorkspace) + in_array($group->getGID(), array_keys($groupfolder['groups']), true) + || in_array($group->getGID(), $groupsWorkspace, true) ) { array_push($groups, $group->getGID()); } diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index ba092cf0f..ef8f6008c 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -83,7 +83,7 @@ public function formatUser(IUser $user, array $space, string $role): ?array { } foreach ($this->groupManager->getUserGroups($user) as $group) { - if (in_array($group->getGID(), array_keys($space['groups'])) || $this->connectedGroups->isConnectedToWorkspace($group->getGID(), array_keys($space['groups']))) { + if (in_array($group->getGID(), array_keys($space['groups']), true) || $this->connectedGroups->isConnectedToWorkspace($group->getGID(), array_keys($space['groups']))) { array_push($groups, $group->getGID()); } } diff --git a/lib/Share/Group/ShareMembersOnlyFilter.php b/lib/Share/Group/ShareMembersOnlyFilter.php index 09e6d56ee..22dd6c7fc 100644 --- a/lib/Share/Group/ShareMembersOnlyFilter.php +++ b/lib/Share/Group/ShareMembersOnlyFilter.php @@ -62,7 +62,7 @@ public function filterUsersGroupOnly(array $users): array { $users, function ($user) use ($usersInTheSameGroup) { $usernames = array_values(array_map(fn ($user) => $user->getUID(), $usersInTheSameGroup)); - return in_array($user->getUID(), $usernames); + return in_array($user->getUID(), $usernames, true); }); return $usersInTheSameGroup; diff --git a/lib/Space/SpaceManager.php b/lib/Space/SpaceManager.php index 39eeebbd5..b669c1807 100644 --- a/lib/Space/SpaceManager.php +++ b/lib/Space/SpaceManager.php @@ -419,7 +419,7 @@ public function renameGroups(int $spaceId, string $oldSpacename, string $newSpac } $groups = array_map(fn ($gid) => $this->groupManager->get($gid), $gids); - $groups = array_filter($groups, fn ($group) => !in_array('LDAP', $group->getBackendNames())); + $groups = array_filter($groups, fn ($group) => !in_array('LDAP', $group->getBackendNames(), true)); foreach ($groups as $group) { $newGroupName = str_replace($oldSpacename, $newSpacename, $group->getDisplayName()); diff --git a/lib/Users/UserFormatter.php b/lib/Users/UserFormatter.php index 07f744094..762453fdd 100644 --- a/lib/Users/UserFormatter.php +++ b/lib/Users/UserFormatter.php @@ -29,7 +29,7 @@ public function formatUser(IUser $user, array $space, string $role): array { // Gets the workspace subgroups the user is member of $groups = []; foreach ($this->groupManager->getUserGroups($user) as $group) { - if (in_array($group->getGID(), array_keys($space['groups']))) { + if (in_array($group->getGID(), array_keys($space['groups']), true)) { array_push($groups, $group->getGID()); } }