diff options
Diffstat (limited to 'apps/provisioning_api/lib/Controller')
6 files changed, 54 insertions, 60 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index 603c6306227..61459e40b8b 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -222,7 +222,7 @@ abstract class AUserData extends OCSController { * Get the groups a user is a subadmin of * * @param string $userId - * @return string[] + * @return list<string> * @throws OCSException */ protected function getUserSubAdminGroupsData(string $userId): array { diff --git a/apps/provisioning_api/lib/Controller/AppConfigController.php b/apps/provisioning_api/lib/Controller/AppConfigController.php index bb161f6cb8c..d8af1f38d95 100644 --- a/apps/provisioning_api/lib/Controller/AppConfigController.php +++ b/apps/provisioning_api/lib/Controller/AppConfigController.php @@ -44,7 +44,7 @@ class AppConfigController extends OCSController { /** * Get a list of apps * - * @return DataResponse<Http::STATUS_OK, array{data: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{data: list<string>}, array{}> * * 200: Apps returned */ @@ -58,7 +58,7 @@ class AppConfigController extends OCSController { * Get the config keys of an app * * @param string $app ID of the app - * @return DataResponse<Http::STATUS_OK, array{data: string[]}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> + * @return DataResponse<Http::STATUS_OK, array{data: list<string>}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> * * 200: Keys returned * 403: App is not allowed @@ -105,7 +105,7 @@ class AppConfigController extends OCSController { * @param string $app ID of the app * @param string $key Key to update * @param string $value New value for the key - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> * * 200: Value updated successfully * 403: App or key is not allowed @@ -154,7 +154,7 @@ class AppConfigController extends OCSController { * * @param string $app ID of the app * @param string $key Key to delete - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> * * 200: Key deleted successfully * 403: App or key is not allowed diff --git a/apps/provisioning_api/lib/Controller/AppsController.php b/apps/provisioning_api/lib/Controller/AppsController.php index ae08a9cade0..04dfd8f29b1 100644 --- a/apps/provisioning_api/lib/Controller/AppsController.php +++ b/apps/provisioning_api/lib/Controller/AppsController.php @@ -31,18 +31,18 @@ class AppsController extends OCSController { * Get a list of installed apps * * @param ?string $filter Filter for enabled or disabled apps - * @return DataResponse<Http::STATUS_OK, array{apps: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{apps: list<string>}, array{}> * @throws OCSException * * 200: Installed apps returned */ public function getApps(?string $filter = null): DataResponse { $apps = (new OC_App())->listAllApps(); + /** @var list<string> $list */ $list = []; foreach ($apps as $app) { $list[] = $app['id']; } - /** @var string[] $list */ if ($filter) { switch ($filter) { case 'enabled': @@ -50,7 +50,7 @@ class AppsController extends OCSController { break; case 'disabled': $enabled = OC_App::getEnabledApps(); - return new DataResponse(['apps' => array_diff($list, $enabled)]); + return new DataResponse(['apps' => array_values(array_diff($list, $enabled))]); break; default: // Invalid filter variable @@ -83,7 +83,7 @@ class AppsController extends OCSController { * Enable an app * * @param string $app ID of the app - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: App enabled successfully @@ -102,7 +102,7 @@ class AppsController extends OCSController { * Disable an app * * @param string $app ID of the app - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * * 200: App disabled successfully */ diff --git a/apps/provisioning_api/lib/Controller/GroupsController.php b/apps/provisioning_api/lib/Controller/GroupsController.php index 0b16c319f1d..87544cc8992 100644 --- a/apps/provisioning_api/lib/Controller/GroupsController.php +++ b/apps/provisioning_api/lib/Controller/GroupsController.php @@ -68,17 +68,17 @@ class GroupsController extends AUserData { * @param string $search Text to search for * @param ?int $limit Limit the amount of groups returned * @param int $offset Offset for searching for groups - * @return DataResponse<Http::STATUS_OK, array{groups: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{groups: list<string>}, array{}> * * 200: Groups returned */ #[NoAdminRequired] public function getGroups(string $search = '', ?int $limit = null, int $offset = 0): DataResponse { $groups = $this->groupManager->search($search, $limit, $offset); - $groups = array_map(function ($group) { + $groups = array_values(array_map(function ($group) { /** @var IGroup $group */ return $group->getGID(); - }, $groups); + }, $groups)); return new DataResponse(['groups' => $groups]); } @@ -89,7 +89,7 @@ class GroupsController extends AUserData { * @param string $search Text to search for * @param ?int $limit Limit the amount of groups returned * @param int $offset Offset for searching for groups - * @return DataResponse<Http::STATUS_OK, array{groups: Provisioning_APIGroupDetails[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{groups: list<Provisioning_APIGroupDetails>}, array{}> * * 200: Groups details returned */ @@ -97,7 +97,7 @@ class GroupsController extends AUserData { #[AuthorizedAdminSetting(settings: Sharing::class)] public function getGroupsDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse { $groups = $this->groupManager->search($search, $limit, $offset); - $groups = array_map(function ($group) { + $groups = array_values(array_map(function ($group) { /** @var IGroup $group */ return [ 'id' => $group->getGID(), @@ -107,7 +107,7 @@ class GroupsController extends AUserData { 'canAdd' => $group->canAddUser(), 'canRemove' => $group->canRemoveUser(), ]; - }, $groups); + }, $groups)); return new DataResponse(['groups' => $groups]); } @@ -116,7 +116,7 @@ class GroupsController extends AUserData { * Get a list of users in the specified group * * @param string $groupId ID of the group - * @return DataResponse<Http::STATUS_OK, array{users: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{users: list<string>}, array{}> * @throws OCSException * * @deprecated 14 Use getGroupUsers @@ -132,7 +132,7 @@ class GroupsController extends AUserData { * Get a list of users in the specified group * * @param string $groupId ID of the group - * @return DataResponse<Http::STATUS_OK, array{users: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{users: list<string>}, array{}> * @throws OCSException * @throws OCSNotFoundException Group not found * @throws OCSForbiddenException Missing permissions to get users in the group @@ -163,7 +163,7 @@ class GroupsController extends AUserData { /** @var IUser $user */ return $user->getUID(); }, $users); - /** @var string[] $users */ + /** @var list<string> $users */ $users = array_values($users); return new DataResponse(['users' => $users]); } @@ -233,7 +233,7 @@ class GroupsController extends AUserData { * * @param string $groupid ID of the group * @param string $displayname Display name of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: Group created successfully @@ -266,7 +266,7 @@ class GroupsController extends AUserData { * @param string $groupId ID of the group * @param string $key Key to update, only 'displayname' * @param string $value New value for the key - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: Group updated successfully @@ -295,7 +295,7 @@ class GroupsController extends AUserData { * Delete a group * * @param string $groupId ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: Group deleted successfully @@ -320,7 +320,7 @@ class GroupsController extends AUserData { * Get the list of user IDs that are a subadmin of the group * * @param string $groupId ID of the group - * @return DataResponse<Http::STATUS_OK, string[], array{}> + * @return DataResponse<Http::STATUS_OK, list<string>, array{}> * @throws OCSException * * 200: Sub admins returned @@ -336,7 +336,7 @@ class GroupsController extends AUserData { /** @var IUser[] $subadmins */ $subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup); // New class returns IUser[] so convert back - /** @var string[] $uids */ + /** @var list<string> $uids */ $uids = []; foreach ($subadmins as $user) { $uids[] = $user->getUID(); diff --git a/apps/provisioning_api/lib/Controller/PreferencesController.php b/apps/provisioning_api/lib/Controller/PreferencesController.php index 672aec7756c..8ae64e65b81 100644 --- a/apps/provisioning_api/lib/Controller/PreferencesController.php +++ b/apps/provisioning_api/lib/Controller/PreferencesController.php @@ -40,7 +40,7 @@ class PreferencesController extends OCSController { * @param string $appId ID of the app * @param array<string, string> $configs Key-value pairs of the preferences * - * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, list<empty>, array{}> * * 200: Preferences updated successfully * 400: Preference invalid @@ -85,7 +85,7 @@ class PreferencesController extends OCSController { * @param string $appId ID of the app * @param string $configKey Key of the preference * @param string $configValue New value - * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, list<empty>, array{}> * * 200: Preference updated successfully * 400: Preference invalid @@ -124,9 +124,9 @@ class PreferencesController extends OCSController { * Delete multiple preferences for an app * * @param string $appId ID of the app - * @param string[] $configKeys Keys to delete + * @param list<string> $configKeys Keys to delete * - * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, list<empty>, array{}> * * 200: Preferences deleted successfully * 400: Preference invalid @@ -168,7 +168,7 @@ class PreferencesController extends OCSController { * * @param string $appId ID of the app * @param string $configKey Key to delete - * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST, list<empty>, array{}> * * 200: Preference deleted successfully * 400: Preference invalid diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index b0cd9bfb448..9363b4ca935 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -97,7 +97,7 @@ class UsersController extends AUserData { * @param string $search Text to search for * @param int|null $limit Limit the amount of groups returned * @param int $offset Offset for searching for groups - * @return DataResponse<Http::STATUS_OK, array{users: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{users: list<string>}, array{}> * * 200: Users returned */ @@ -125,7 +125,7 @@ class UsersController extends AUserData { } } - /** @var string[] $users */ + /** @var list<string> $users */ $users = array_keys($users); return new DataResponse([ @@ -341,8 +341,8 @@ class UsersController extends AUserData { * Search users by their phone numbers * * @param string $location Location of the phone number (for country code) - * @param array<string, string[]> $search Phone numbers to search for - * @return DataResponse<Http::STATUS_OK, array<string, string>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array<empty>, array{}> + * @param array<string, list<string>> $search Phone numbers to search for + * @return DataResponse<Http::STATUS_OK, array<string, string>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, list<empty>, array{}> * * 200: Users returned * 400: Invalid location @@ -433,8 +433,8 @@ class UsersController extends AUserData { * @param string $password Password of the user * @param string $displayName Display name of the user * @param string $email Email of the user - * @param string[] $groups Groups of the user - * @param string[] $subadmin Groups where the user is subadmin + * @param list<string> $groups Groups of the user + * @param list<string> $subadmin Groups where the user is subadmin * @param string $quota Quota of the user * @param string $language Language of the user * @param ?string $manager Manager of the user @@ -689,7 +689,7 @@ class UsersController extends AUserData { * * Get a list of fields that are editable for the current user * - * @return DataResponse<Http::STATUS_OK, string[], array{}> + * @return DataResponse<Http::STATUS_OK, list<string>, array{}> * @throws OCSException * * 200: Editable fields returned @@ -710,7 +710,7 @@ class UsersController extends AUserData { * Get a list of fields that are editable for a user * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, string[], array{}> + * @return DataResponse<Http::STATUS_OK, list<string>, array{}> * @throws OCSException * * 200: Editable fields for user returned @@ -779,7 +779,7 @@ class UsersController extends AUserData { * @param string $collectionName Collection to update * @param string $key Key that will be updated * @param string $value New value for the key - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User values edited successfully @@ -884,7 +884,7 @@ class UsersController extends AUserData { * @param string $userId ID of the user * @param string $key Key that will be updated * @param string $value New value for the key - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User value edited successfully @@ -1222,7 +1222,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * * @throws OCSException * @@ -1261,7 +1261,7 @@ class UsersController extends AUserData { * Delete a user * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User deleted successfully @@ -1301,7 +1301,7 @@ class UsersController extends AUserData { * Disable a user * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User disabled successfully @@ -1316,7 +1316,7 @@ class UsersController extends AUserData { * Enable a user * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User enabled successfully @@ -1330,7 +1330,7 @@ class UsersController extends AUserData { /** * @param string $userId * @param bool $value - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException */ private function setEnabled(string $userId, bool $value): DataResponse { @@ -1360,7 +1360,7 @@ class UsersController extends AUserData { * Get a list of groups the user belongs to * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, array{groups: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{groups: list<string>}, array{}> * @throws OCSException * * 200: Users groups returned @@ -1387,16 +1387,10 @@ class UsersController extends AUserData { // Looking up someone else if ($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) { // Return the group that the method caller is subadmin of for the user in question - /** @var IGroup[] $getSubAdminsGroups */ - $getSubAdminsGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); - foreach ($getSubAdminsGroups as $key => $group) { - $getSubAdminsGroups[$key] = $group->getGID(); - } - /** @var string[] $groups */ - $groups = array_intersect( - $getSubAdminsGroups, + $groups = array_values(array_intersect( + array_map(static fn (IGroup $group) => $group->getGID(), $subAdminManager->getSubAdminsGroups($loggedInUser)), $this->groupManager->getUserGroupIds($targetUser) - ); + )); return new DataResponse(['groups' => $groups]); } else { // Not permitted @@ -1410,7 +1404,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * @param string $groupid ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User added to group successfully @@ -1450,7 +1444,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * @param string $groupid ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User removed from group successfully @@ -1517,7 +1511,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * @param string $groupid ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User added as group subadmin successfully @@ -1557,7 +1551,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * @param string $groupid ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User removed as group subadmin successfully @@ -1591,7 +1585,7 @@ class UsersController extends AUserData { * Get the groups a user is a subadmin of * * @param string $userId ID if the user - * @return DataResponse<Http::STATUS_OK, string[], array{}> + * @return DataResponse<Http::STATUS_OK, list<string>, array{}> * @throws OCSException * * 200: User subadmin groups returned @@ -1606,7 +1600,7 @@ class UsersController extends AUserData { * Resend the welcome message * * @param string $userId ID if the user - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: Resent welcome message successfully |