* enabled: bool,
* apiVersion: string,
* endPoint: string,
- * resourceTypes: array{
+ * resourceTypes: list<array{
* name: string,
- * shareTypes: string[],
+ * shareTypes: list<string>,
* protocols: array<string, string>
- * }[],
+ * }>,
* },
* }
* @throws OCMArgumentException
* @param string|null $ownerDisplayName Display name of the user who shared the item
* @param string|null $sharedBy Provider specific UID of the user who shared the resource
* @param string|null $sharedByDisplayName Display name of the user who shared the resource
- * @param array{name: string[], options: array<string, mixed>} $protocol e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]]
+ * @param array{name: list<string>, options: array<string, mixed>} $protocol e,.g. ['name' => 'webdav', 'options' => ['username' => 'john', 'permissions' => 31]]
* @param string $shareType 'group' or 'user' share
* @param string $resourceType 'file', 'calendar',...
*
* }
*
* @psalm-type CloudFederationAPIValidationError = CloudFederationAPIError&array{
- * validationErrors: array{
+ * validationErrors: list<array{
* name: string,
* message: string|null,
- * }[],
+ * }>,
* }
*/
class ResponseDefinitions {
* @param array<string, string> $sinceIds Array indexed by widget Ids, contains date/id from which we want the new items
* @param int $limit Limit number of result items per widget
* @psalm-param int<1, 30> $limit
- * @param string[] $widgets Limit results to specific widgets
- * @return DataResponse<Http::STATUS_OK, array<string, DashboardWidgetItem[]>, array{}>
+ * @param list<string> $widgets Limit results to specific widgets
+ * @return DataResponse<Http::STATUS_OK, array<string, list<DashboardWidgetItem>>, array{}>
*
* 200: Widget items returned
*/
* @param array<string, string> $sinceIds Array indexed by widget Ids, contains date/id from which we want the new items
* @param int $limit Limit number of result items per widget, not more than 30 are allowed
* @psalm-param int<1, 30> $limit
- * @param string[] $widgets Limit results to specific widgets
+ * @param list<string> $widgets Limit results to specific widgets
* @return DataResponse<Http::STATUS_OK, array<string, DashboardWidgetItems>, array{}>
*
* 200: Widget items returned
* icon_url: string,
* widget_url: ?string,
* item_icons_round: bool,
- * item_api_versions: int[],
+ * item_api_versions: list<int>,
* reload_interval: int,
- * buttons?: array{
+ * buttons?: list<array{
* type: string,
* text: string,
* link: string,
- * }[],
+ * }>,
* }
*
* @psalm-type DashboardWidgetItem = array{
* }
*
* @psalm-type DashboardWidgetItems = array{
- * items: DashboardWidgetItem[],
+ * items: list<DashboardWidgetItem>,
* emptyContentMessage: string,
* halfEmptyContentMessage: string,
* }
* Get information about upcoming events
*
* @param string|null $location location/URL to filter by
- * @return DataResponse<Http::STATUS_OK, array{events: DAVUpcomingEvent[]}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, null, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{events: list<DAVUpcomingEvent>}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, null, array{}>
*
* 200: Upcoming events
* 401: When not authenticated
}
return new DataResponse([
- 'events' => array_map(fn (UpcomingEvent $e) => $e->jsonSerialize(), $this->service->getEvents(
+ 'events' => array_values(array_map(fn (UpcomingEvent $e) => $e->jsonSerialize(), $this->service->getEvents(
$this->userId,
$location,
- )),
+ ))),
]);
}
* @param int|null $remoteId ID of the remote
* @param string|null $sharedByFederatedId Federated ID of the sender
* @param string|null $ownerFederatedId Federated ID of the receiver
- * @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSException
*
* 200: Share created successfully
*
* @param int $id ID of the remote share
* @param string|null $token Shared secret between servers
- * @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSException
* @throws ShareNotFound
* @throws HintException
*
* @param int $id ID of the remote share
* @param string|null $token Shared secret between servers
- * @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSException
*
* 200: Share declined successfully
*
* @param int $id ID of the share
* @param string|null $token Shared secret between servers
- * @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSException
*
* 200: Share unshared successfully
*
* @param int $id ID of the share
* @param string|null $token Shared secret between servers
- * @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSBadRequestException Revoking the share is not possible
*
* 200: Share revoked successfully
* @param int $id ID of the share
* @param string|null $token Shared secret between servers
* @param int|null $permissions New permissions
- * @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return Http\DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSBadRequestException Updating permissions is not possible
*
* 200: Permissions updated successfully
*
* @param string $url URL of the server
* @param string $token Token of the server
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSForbiddenException Requesting shared secret is not allowed
*
* 200: Shared secret requested successfully
*
* @param string $url URL of the server
* @param string $token Token of the server
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSForbiddenException Requesting shared secret is not allowed
*
* 200: Shared secret requested successfully
/**
* Return this classes capabilities
*
- * @return array{files: array{'$comment': ?string, bigfilechunking: bool, blacklisted_files: array<mixed>, forbidden_filenames: list<string>, forbidden_filename_basenames: list<string>, forbidden_filename_characters: list<string>, forbidden_filename_extensions: list<string>, chunked_upload: array{max_size: int, max_parallel_count: int}}}
+ * @return array{files: array{'$comment': ?string, bigfilechunking: bool, blacklisted_files: list<mixed>, forbidden_filenames: list<string>, forbidden_filename_basenames: list<string>, forbidden_filename_characters: list<string>, forbidden_filename_extensions: list<string>, chunked_upload: array{max_size: int, max_parallel_count: int}}}
*/
public function getCapabilities(): array {
return [
/**
* Get the direct editing capabilities
- * @return DataResponse<Http::STATUS_OK, array{editors: array<string, array{id: string, name: string, mimetypes: string[], optionalMimetypes: string[], secure: bool}>, creators: array<string, array{id: string, editor: string, name: string, extension: string, templates: bool, mimetypes: string[]}>}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{editors: array<string, array{id: string, name: string, mimetypes: list<string>, optionalMimetypes: list<string>, secure: bool}>, creators: array<string, array{id: string, editor: string, name: string, extension: string, templates: bool, mimetypes: list<string>}>}, array{}>
*
* 200: Direct editing capabilities returned
*/
*
* @param string $path Path of the file
*
- * @return DataResponse<Http::STATUS_OK, array{userId: ?string, pathHash: string, expirationTime: int, token: string}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{userId: ?string, pathHash: string, expirationTime: int, token: string}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, list<empty>, array{}>
*
* 200: Local editor returned
*/
* @param string $path Path of the file
* @param string $token Token of the local editor
*
- * @return DataResponse<Http::STATUS_OK, array{userId: string, pathHash: string, expirationTime: int, token: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{userId: string, pathHash: string, expirationTime: int, token: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Local editor validated successfully
* 404: Local editor not found
use OCP\AppFramework\OCSController;
use OCP\Files\GenericFileException;
use OCP\Files\Template\ITemplateManager;
+use OCP\Files\Template\Template;
use OCP\Files\Template\TemplateFileCreator;
use OCP\IRequest;
/**
* @psalm-import-type FilesTemplateFile from ResponseDefinitions
* @psalm-import-type FilesTemplateFileCreator from ResponseDefinitions
+ * @psalm-import-type FilesTemplateFileCreatorWithTemplates from ResponseDefinitions
* @psalm-import-type FilesTemplateField from ResponseDefinitions
+ * @psalm-import-type FilesTemplate from ResponseDefinitions
*/
class TemplateController extends OCSController {
public function __construct(
/**
* List the available templates
*
- * @return DataResponse<Http::STATUS_OK, array<FilesTemplateFileCreator>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<FilesTemplateFileCreatorWithTemplates>, array{}>
*
* 200: Available templates returned
*/
#[NoAdminRequired]
public function list(): DataResponse {
- return new DataResponse($this->templateManager->listTemplates());
+ /* Convert embedded Template instances to arrays to match return type */
+ return new DataResponse(array_map(static function (array $templateFileCreator) {
+ $templateFileCreator['templates'] = array_map(static fn (Template $template) => $template->jsonSerialize(), $templateFileCreator['templates']);
+ return $templateFileCreator;
+ }, $this->templateManager->listTemplates()));
}
/**
* @param string $filePath Path of the file
* @param string $templatePath Name of the template
* @param string $templateType Type of the template
- * @param FilesTemplateField[] $templateFields Fields of the template
+ * @param list<FilesTemplateField> $templateFields Fields of the template
*
* @return DataResponse<Http::STATUS_OK, FilesTemplateFile, array{}>
* @throws OCSForbiddenException Creating template is not allowed
* @param string $templatePath Path of the template directory
* @param bool $copySystemTemplates Whether to copy the system templates to the template directory
*
- * @return DataResponse<Http::STATUS_OK, array{template_path: string, templates: FilesTemplateFileCreator[]}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{template_path: string, templates: list<FilesTemplateFileCreator>}, array{}>
* @throws OCSForbiddenException Initializing the template directory is not allowed
*
* 200: Template directory initialized successfully
$templatePath = $this->templateManager->initializeTemplateDirectory($templatePath, null, $copySystemTemplates);
return new DataResponse([
'template_path' => $templatePath,
- 'templates' => array_map(fn (TemplateFileCreator $creator) => $creator->jsonSerialize(), $this->templateManager->listCreators()),
+ 'templates' => array_values(array_map(fn (TemplateFileCreator $creator) => $creator->jsonSerialize(), $this->templateManager->listCreators())),
]);
} catch (\Exception $e) {
throw new OCSForbiddenException($e->getMessage());
* @param string $recipient Username of the recipient
* @param string $path Path of the file
*
- * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK|Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN, list<empty>, array{}>
*
* 200: Ownership transferred successfully
* 400: Transferring ownership is not possible
*
* @param int $id ID of the ownership transfer
*
- * @return DataResponse<Http::STATUS_OK|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Ownership transfer accepted successfully
* 403: Accepting ownership transfer is not allowed
*
* @param int $id ID of the ownership transfer
*
- * @return DataResponse<Http::STATUS_OK|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Ownership transfer rejected successfully
* 403: Rejecting ownership transfer is not allowed
/**
* Populate the result set with file tags
*
- * @param array $fileList
- * @param string $fileIdentifier identifier attribute name for values in $fileList
- * @param ITagManager $tagManager
- * @return array file list populated with tags
+ * @psalm-template T of array{tags?: list<string>, file_source: int, ...array<string, mixed>}
+ * @param list<T> $fileList
+ * @return list<T> file list populated with tags
*/
- public static function populateTags(array $fileList, $fileIdentifier, ITagManager $tagManager) {
- $ids = [];
- foreach ($fileList as $fileData) {
- $ids[] = $fileData[$fileIdentifier];
- }
+ public static function populateTags(array $fileList, ITagManager $tagManager) {
$tagger = $tagManager->load('files');
- $tags = $tagger->getTagsForObjects($ids);
+ $tags = $tagger->getTagsForObjects(array_map(static fn (array $fileData) => $fileData['file_source'], $fileList));
if (!is_array($tags)) {
throw new \UnexpectedValueException('$tags must be an array');
}
// Set empty tag array
- foreach ($fileList as $key => $fileData) {
- $fileList[$key]['tags'] = [];
+ foreach ($fileList as &$fileData) {
+ $fileData['tags'] = [];
}
+ unset($fileData);
if (!empty($tags)) {
foreach ($tags as $fileId => $fileTags) {
- foreach ($fileList as $key => $fileData) {
- if ($fileId !== $fileData[$fileIdentifier]) {
+ foreach ($fileList as &$fileData) {
+ if ($fileId !== $fileData['file_source']) {
continue;
}
- $fileList[$key]['tags'] = $fileTags;
+ $fileData['tags'] = $fileTags;
}
+ unset($fileData);
}
}
* hasPreview: bool,
* }
*
+ * @psalm-type FilesTemplateField = array{
+ * index: string,
+ * type: string,
+ * alias: ?string,
+ * tag: ?string,
+ * id: ?int,
+ * content?: string,
+ * checked?: bool,
+ * }
+ *
+ * @psalm-type FilesTemplate = array{
+ * templateType: string,
+ * templateId: string,
+ * basename: string,
+ * etag: string,
+ * fileid: int,
+ * filename: string,
+ * lastmod: int,
+ * mime: string,
+ * size: int|float,
+ * type: string,
+ * hasPreview: bool,
+ * previewUrl: ?string,
+ * fields: list<FilesTemplateField>,
+ * }
+ *
* @psalm-type FilesTemplateFileCreator = array{
* app: string,
* label: string,
* extension: string,
* iconClass: ?string,
* iconSvgInline: ?string,
- * mimetypes: string[],
+ * mimetypes: list<string>,
* ratio: ?float,
* actionLabel: string,
* }
*
- * @psalm-type FilesTemplateField = array{
- * index: string,
- * content: string,
- * type: string,
+ * @psalm-type FilesTemplateFileCreatorWithTemplates = FilesTemplateFileCreator&array{
+ * templates: list<FilesTemplate>,
* }
*
* @psalm-type FilesFolderTree = list<array{
}
}
},
+ "Template": {
+ "type": "object",
+ "required": [
+ "templateType",
+ "templateId",
+ "basename",
+ "etag",
+ "fileid",
+ "filename",
+ "lastmod",
+ "mime",
+ "size",
+ "type",
+ "hasPreview",
+ "previewUrl",
+ "fields"
+ ],
+ "properties": {
+ "templateType": {
+ "type": "string"
+ },
+ "templateId": {
+ "type": "string"
+ },
+ "basename": {
+ "type": "string"
+ },
+ "etag": {
+ "type": "string"
+ },
+ "fileid": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "filename": {
+ "type": "string"
+ },
+ "lastmod": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "mime": {
+ "type": "string"
+ },
+ "size": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "format": "int64"
+ },
+ {
+ "type": "number",
+ "format": "double"
+ }
+ ]
+ },
+ "type": {
+ "type": "string"
+ },
+ "hasPreview": {
+ "type": "boolean"
+ },
+ "previewUrl": {
+ "type": "string",
+ "nullable": true
+ },
+ "fields": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/TemplateField"
+ }
+ }
+ }
+ },
"TemplateField": {
"type": "object",
"required": [
"index",
- "content",
- "type"
+ "type",
+ "alias",
+ "tag",
+ "id"
],
"properties": {
"index": {
"type": "string"
},
- "content": {
+ "type": {
"type": "string"
},
- "type": {
+ "alias": {
+ "type": "string",
+ "nullable": true
+ },
+ "tag": {
+ "type": "string",
+ "nullable": true
+ },
+ "id": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ },
+ "content": {
"type": "string"
+ },
+ "checked": {
+ "type": "boolean"
}
}
},
"type": "string"
}
}
+ },
+ "TemplateFileCreatorWithTemplates": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/TemplateFileCreator"
+ },
+ {
+ "type": "object",
+ "required": [
+ "templates"
+ ],
+ "properties": {
+ "templates": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Template"
+ }
+ }
+ }
+ }
+ ]
}
}
},
"data": {
"type": "array",
"items": {
- "$ref": "#/components/schemas/TemplateFileCreator"
+ "$ref": "#/components/schemas/TemplateFileCreatorWithTemplates"
}
}
}
->willReturn($tagger);
$data = [
- ['id' => 10],
- ['id' => 22, 'foo' => 'bar'],
- ['id' => 42, 'x' => 'y'],
+ ['file_source' => 10],
+ ['file_source' => 22, 'foo' => 'bar'],
+ ['file_source' => 42, 'x' => 'y'],
];
$tags = [
->with([10, 22, 42])
->willReturn($tags);
- $result = Helper::populateTags($data, 'id', $tagManager);
+ $result = Helper::populateTags($data, $tagManager);
$this->assertSame([
- ['id' => 10, 'tags' => ['tag3']],
- ['id' => 22, 'foo' => 'bar', 'tags' => []],
- ['id' => 42, 'x' => 'y', 'tags' => ['tag1', 'tag2']],
+ ['file_source' => 10, 'tags' => ['tag3']],
+ ['file_source' => 22, 'foo' => 'bar', 'tags' => []],
+ ['file_source' => 42, 'x' => 'y', 'tags' => ['tag1', 'tag2']],
], $result);
}
}
/**
* Get the mount points visible for this user
*
- * @return DataResponse<Http::STATUS_OK, Files_ExternalMount[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_ExternalMount>, array{}>
*
* 200: User mounts returned
*/
/**
* List of users who have access to this storage
*
- * @var string[]
+ * @var list<string>
*/
private $applicableUsers = [];
/**
* List of groups that have access to this storage
*
- * @var string[]
+ * @var list<string>
*/
private $applicableGroups = [];
/**
* Returns the users for which to mount this storage
*
- * @return string[] applicable users
+ * @return list<string> applicable users
*/
public function getApplicableUsers() {
return $this->applicableUsers;
/**
* Sets the users for which to mount this storage
*
- * @param string[]|null $applicableUsers applicable users
+ * @param list<string>|null $applicableUsers applicable users
*/
public function setApplicableUsers($applicableUsers) {
if (is_null($applicableUsers)) {
/**
* Returns the groups for which to mount this storage
*
- * @return string[] applicable groups
+ * @return list<string> applicable groups
*/
public function getApplicableGroups() {
return $this->applicableGroups;
/**
* Sets the groups for which to mount this storage
*
- * @param string[]|null $applicableGroups applicable groups
+ * @param list<string>|null $applicableGroups applicable groups
*/
public function setApplicableGroups($applicableGroups) {
if (is_null($applicableGroups)) {
/**
* @psalm-type Files_ExternalStorageConfig = array{
- * applicableGroups?: string[],
- * applicableUsers?: string[],
+ * applicableGroups?: list<string>,
+ * applicableUsers?: list<string>,
* authMechanism: string,
* backend: string,
* backendOptions: array<string, mixed>,
* Get a reminder
*
* @param int $fileId ID of the file
- * @return DataResponse<Http::STATUS_OK, array{dueDate: ?string}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{dueDate: ?string}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, list<empty>, array{}>
*
* 200: Reminder returned
* 401: Account not found
* @param int $fileId ID of the file
* @param string $dueDate ISO 8601 formatted date time string
*
- * @return DataResponse<Http::STATUS_OK|Http::STATUS_CREATED|Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK|Http::STATUS_CREATED|Http::STATUS_BAD_REQUEST|Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Reminder updated
* 201: Reminder created successfully
*
* @param int $fileId ID of the file
*
- * @return DataResponse<Http::STATUS_OK|Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK|Http::STATUS_UNAUTHORIZED|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Reminder deleted successfully
* 401: Account not found
/**
* Get a list of all deleted shares
*
- * @return DataResponse<Http::STATUS_OK, Files_SharingDeletedShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingDeletedShare>, array{}>
*
* 200: Deleted shares returned
*/
$shares = array_merge($groupShares, $roomShares, $deckShares, $sciencemeshShares);
- $shares = array_map(function (IShare $share) {
+ $shares = array_values(array_map(function (IShare $share) {
return $this->formatShare($share);
- }, $shares);
+ }, $shares));
return new DataResponse($shares);
}
* Undelete a deleted share
*
* @param string $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSException
* @throws OCSNotFoundException Share not found
*
* @param int $x Width of the preview
* @param int $y Height of the preview
* @param bool $a Whether to not crop the preview
- * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Preview returned
* 400: Getting preview is not possible
* Get a direct link preview for a shared file
*
* @param string $token Token of the share
- * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Preview returned
* 400: Getting preview is not possible
/**
* Get list of pending remote shares
*
- * @return DataResponse<Http::STATUS_OK, Files_SharingRemoteShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingRemoteShare>, array{}>
*
* 200: Pending remote shares returned
*/
* Accept a remote share
*
* @param int $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSNotFoundException Share not found
*
* 200: Share accepted successfully
* Decline a remote share
*
* @param int $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSNotFoundException Share not found
*
* 200: Share declined successfully
/**
* Get a list of accepted remote shares
*
- * @return DataResponse<Http::STATUS_OK, Files_SharingRemoteShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingRemoteShare>, array{}>
*
* 200: Accepted remote shares returned
*/
#[NoAdminRequired]
public function getShares() {
$shares = $this->externalManager->getAcceptedShares();
- $shares = array_map('self::extendShareInfo', $shares);
+ $shares = array_map(self::extendShareInfo(...), $shares);
return new DataResponse($shares);
}
* Unshare a remote share
*
* @param int $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSNotFoundException Share not found
* @throws OCSForbiddenException Unsharing is not possible
*
/**
- * @param array $shares
- * @param array|null $updatedDisplayName
+ * @param list<Files_SharingShare> $shares
+ * @param array<string, string>|null $updatedDisplayName
*
- * @return array
+ * @return list<Files_SharingShare>
*/
private function fixMissingDisplayName(array $shares, ?array $updatedDisplayName = null): array {
$userIds = $updated = [];
*
* @param string $id ID of the share
* @param bool $include_tags Include tags in the share
- * @return DataResponse<Http::STATUS_OK, Files_SharingShare, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingShare>, array{}>
* @throws OCSNotFoundException Share not found
*
* 200: Share returned
$share = $this->formatShare($share);
if ($include_tags) {
- $share = Helper::populateTags([$share], 'file_source', \OC::$server->getTagManager());
+ $share = Helper::populateTags([$share], \OC::$server->getTagManager());
} else {
$share = [$share];
}
* Delete a share
*
* @param string $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSNotFoundException Share not found
* @throws OCSForbiddenException Missing permissions to delete the share
*
* @param null|Node $node
* @param boolean $includeTags
*
- * @return Files_SharingShare[]
+ * @return list<Files_SharingShare>
*/
private function getSharedWithMe($node, bool $includeTags): array {
$userShares = $this->shareManager->getSharedWith($this->userId, IShare::TYPE_USER, $node, -1, 0);
}
if ($includeTags) {
- $formatted = Helper::populateTags($formatted, 'file_source', \OC::$server->getTagManager());
+ $formatted = Helper::populateTags($formatted, \OC::$server->getTagManager());
}
return $formatted;
/**
* @param Node $folder
*
- * @return Files_SharingShare[]
+ * @return list<Files_SharingShare>
* @throws OCSBadRequestException
* @throws NotFoundException
*/
* @param string $path Get shares for a specific path
* @param string $include_tags Include tags in the share
*
- * @return DataResponse<Http::STATUS_OK, Files_SharingShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingShare>, array{}>
* @throws OCSNotFoundException The folder was not found or is inaccessible
*
* 200: Shares returned
* @param bool $subFiles
* @param bool $includeTags
*
- * @return Files_SharingShare[]
+ * @return list<Files_SharingShare>
* @throws NotFoundException
* @throws OCSBadRequestException
*/
if ($includeTags) {
$formatted =
- Helper::populateTags($formatted, 'file_source', \OC::$server->getTagManager());
+ Helper::populateTags($formatted, \OC::$server->getTagManager());
}
return $formatted;
*
* @param string $path Path all shares will be relative to
*
- * @return DataResponse<Http::STATUS_OK, Files_SharingShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingShare>, array{}>
* @throws InvalidPathException
* @throws NotFoundException
* @throws OCSNotFoundException The given path is invalid
/**
* Get all shares that are still pending
*
- * @return DataResponse<Http::STATUS_OK, Files_SharingShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingShare>, array{}>
*
* 200: Pending shares returned
*/
}
}
- $result = array_filter(array_map(function (IShare $share) {
+ $result = array_values(array_filter(array_map(function (IShare $share) {
$userFolder = $this->rootFolder->getUserFolder($share->getSharedBy());
$node = $userFolder->getFirstNodeById($share->getNodeId());
if (!$node) {
}
}, $pendingShares), function ($entry) {
return $entry !== null;
- });
+ }));
return new DataResponse($result);
}
* Accept a share
*
* @param string $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSNotFoundException Share not found
* @throws OCSException
* @throws OCSBadRequestException Share could not be accepted
* @throws OCSForbiddenException You are not allowed to send mail notifications
* @throws OCSBadRequestException Invalid request or wrong password
* @throws OCSException Error while sending mail notification
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
*
* 200: The email notification was sent successfully
*/
* @param string|null $password Password of the share
* @param string|null $dir Subdirectory to get info about
* @param int $depth Maximum depth to get info about
- * @return JSONResponse<Http::STATUS_OK, Files_SharingShareInfo, array{}>|JSONResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return JSONResponse<Http::STATUS_OK, Files_SharingShareInfo, array{}>|JSONResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Share info returned
* 403: Getting share info is not allowed
* @param string|null $itemType Limit to specific item types
* @param int $page Page offset for searching
* @param int $perPage Limit amount of search results per page
- * @param int|int[]|null $shareType Limit to specific share types
+ * @param int|list<int>|null $shareType Limit to specific share types
* @param bool $lookup If a global lookup should be performed too
* @return DataResponse<Http::STATUS_OK, Files_SharingShareesSearchResult, array{Link?: string}>
* @throws OCSBadRequestException Invalid search parameters
* Find recommended sharees
*
* @param string $itemType Limit to specific item types
- * @param int|int[]|null $shareType Limit to specific share types
+ * @param int|list<int>|null $shareType Limit to specific share types
* @return DataResponse<Http::STATUS_OK, Files_SharingShareesRecommendedResult, array{}>
*
* 200: Recommended sharees returned
use OC\Files\Filesystem;
use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
use OCA\Files_Sharing\Helper;
+use OCA\Files_Sharing\ResponseDefinitions;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
+/**
+ * @psalm-import-type Files_SharingRemoteShare from ResponseDefinitions
+ */
class Manager {
public const STORAGE = '\OCA\Files_Sharing\External\Storage';
/**
* return a list of shares which are not yet accepted by the user
*
- * @return array list of open server-to-server shares
+ * @return list<Files_SharingRemoteShare> list of open server-to-server shares
*/
public function getOpenShares() {
return $this->getShares(false);
/**
* return a list of shares which are accepted by the user
*
- * @return array list of accepted server-to-server shares
+ * @return list<Files_SharingRemoteShare> list of accepted server-to-server shares
*/
public function getAcceptedShares() {
return $this->getShares(true);
* @param bool|null $accepted True for accepted only,
* false for not accepted,
* null for all shares of the user
- * @return array list of open server-to-server shares
+ * @return list<Files_SharingRemoteShare> list of open server-to-server shares
*/
private function getShares($accepted) {
$user = $this->userManager->get($this->uid);
*
* @psalm-type Files_SharingShareesSearchResult = array{
* exact: array{
- * circles: Files_SharingShareeCircle[],
- * emails: Files_SharingShareeEmail[],
- * groups: Files_SharingSharee[],
- * remote_groups: Files_SharingShareeRemoteGroup[],
- * remotes: Files_SharingShareeRemote[],
- * rooms: Files_SharingSharee[],
- * users: Files_SharingShareeUser[],
+ * circles: list<Files_SharingShareeCircle>,
+ * emails: list<Files_SharingShareeEmail>,
+ * groups: list<Files_SharingSharee>,
+ * remote_groups: list<Files_SharingShareeRemoteGroup>,
+ * remotes: list<Files_SharingShareeRemote>,
+ * rooms: list<Files_SharingSharee>,
+ * users: list<Files_SharingShareeUser>,
* },
- * circles: Files_SharingShareeCircle[],
- * emails: Files_SharingShareeEmail[],
- * groups: Files_SharingSharee[],
- * lookup: Files_SharingShareeLookup[],
- * remote_groups: Files_SharingShareeRemoteGroup[],
- * remotes: Files_SharingShareeRemote[],
- * rooms: Files_SharingSharee[],
- * users: Files_SharingShareeUser[],
+ * circles: list<Files_SharingShareeCircle>,
+ * emails: list<Files_SharingShareeEmail>,
+ * groups: list<Files_SharingSharee>,
+ * lookup: list<Files_SharingShareeLookup>,
+ * remote_groups: list<Files_SharingShareeRemoteGroup>,
+ * remotes: list<Files_SharingShareeRemote>,
+ * rooms: list<Files_SharingSharee>,
+ * users: list<Files_SharingShareeUser>,
* lookupEnabled: bool,
* }
*
* @psalm-type Files_SharingShareesRecommendedResult = array{
* exact: array{
- * emails: Files_SharingShareeEmail[],
- * groups: Files_SharingSharee[],
- * remote_groups: Files_SharingShareeRemoteGroup[],
- * remotes: Files_SharingShareeRemote[],
- * users: Files_SharingShareeUser[],
+ * emails: list<Files_SharingShareeEmail>,
+ * groups: list<Files_SharingSharee>,
+ * remote_groups: list<Files_SharingShareeRemoteGroup>,
+ * remotes: list<Files_SharingShareeRemote>,
+ * users: list<Files_SharingShareeUser>,
* },
- * emails: Files_SharingShareeEmail[],
- * groups: Files_SharingSharee[],
- * remote_groups: Files_SharingShareeRemoteGroup[],
- * remotes: Files_SharingShareeRemote[],
- * users: Files_SharingShareeUser[],
+ * emails: list<Files_SharingShareeEmail>,
+ * groups: list<Files_SharingSharee>,
+ * remote_groups: list<Files_SharingShareeRemoteGroup>,
+ * remotes: list<Files_SharingShareeRemote>,
+ * users: list<Files_SharingShareeUser>,
* }
*
* @psalm-type Files_SharingShareInfo = array{
* size: int|float,
* type: string,
* etag: string,
- * children?: array<string, mixed>[],
+ * children?: list<array<string, mixed>>,
* }
*/
class ResponseDefinitions {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
- "$ref": "#/components/schemas/Share"
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Share"
+ }
}
}
}
* @param int $y Height of the preview
* @param bool $a Whether to not crop the preview
*
- * @return Http\FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return Http\FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Preview returned
* 400: Getting preview is not possible
* @param int $x Width of the preview
* @param int $y Height of the preview
* @param string $version Version of the file to get the preview for
- * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Preview returned
* 400: Getting preview is not possible
* 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 {
/**
* 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
*/
* 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
* @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
*
* @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
* 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':
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
* 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
* 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
*/
* @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]);
}
* @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
*/
#[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(),
'canAdd' => $group->canAddUser(),
'canRemove' => $group->canRemoveUser(),
];
- }, $groups);
+ }, $groups));
return new DataResponse(['groups' => $groups]);
}
* 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
* 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
/** @var IUser $user */
return $user->getUID();
}, $users);
- /** @var string[] $users */
+ /** @var list<string> $users */
$users = array_values($users);
return new DataResponse(['users' => $users]);
}
*
* @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
* @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
* 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
* 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
/** @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();
* @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
* @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
* 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
*
* @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
* @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
*/
}
}
- /** @var string[] $users */
+ /** @var list<string> $users */
$users = array_keys($users);
return new DataResponse([
* 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
* @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
*
* 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
* 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
* @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
* @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
*
* @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
*
* 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
* 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
* 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
/**
* @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 {
* 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
// 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
*
* @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
*
* @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
*
* @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
*
* @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
* 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
* 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
* @psalm-type Provisioning_APIUserDetailsScope = 'v2-private'|'v2-local'|'v2-federated'|'v2-published'|'private'|'contacts'|'public'
*
* @psalm-type Provisioning_APIUserDetails = array{
- * additional_mail: string[],
- * additional_mailScope?: Provisioning_APIUserDetailsScope[],
+ * additional_mail: list<string>,
+ * additional_mailScope?: list<Provisioning_APIUserDetailsScope>,
* address: string,
* addressScope?: Provisioning_APIUserDetailsScope,
* avatarScope?: Provisioning_APIUserDetailsScope,
* enabled?: bool,
* fediverse: string,
* fediverseScope?: Provisioning_APIUserDetailsScope,
- * groups: string[],
+ * groups: list<string>,
* headline: string,
* headlineScope?: Provisioning_APIUserDetailsScope,
* id: string,
* role: string,
* roleScope?: Provisioning_APIUserDetailsScope,
* storageLocation?: string,
- * subadmin: string[],
+ * subadmin: list<string>,
* twitter: string,
* twitterScope?: Provisioning_APIUserDetailsScope,
* website: string,
/**
* @return array{
- * files_sharing: array{
+ * files_sharing?: array{
* sharebymail: array{
* enabled: bool,
* send_password_by_mail: bool,
* },
* }
* }
- * }|array<empty>
+ * }
*/
public function getCapabilities(): array {
if (!$this->appManager->isEnabledForUser('files_sharing')) {
},
"schemas": {
"Capabilities": {
- "oneOf": [
- {
+ "type": "object",
+ "properties": {
+ "files_sharing": {
"type": "object",
"required": [
- "files_sharing"
+ "sharebymail"
],
"properties": {
- "files_sharing": {
+ "sharebymail": {
"type": "object",
"required": [
- "sharebymail"
+ "enabled",
+ "send_password_by_mail",
+ "upload_files_drop",
+ "password",
+ "expire_date"
],
"properties": {
- "sharebymail": {
+ "enabled": {
+ "type": "boolean"
+ },
+ "send_password_by_mail": {
+ "type": "boolean"
+ },
+ "upload_files_drop": {
+ "type": "object",
+ "required": [
+ "enabled"
+ ],
+ "properties": {
+ "enabled": {
+ "type": "boolean"
+ }
+ }
+ },
+ "password": {
"type": "object",
"required": [
"enabled",
- "send_password_by_mail",
- "upload_files_drop",
- "password",
- "expire_date"
+ "enforced"
],
"properties": {
"enabled": {
"type": "boolean"
},
- "send_password_by_mail": {
+ "enforced": {
+ "type": "boolean"
+ }
+ }
+ },
+ "expire_date": {
+ "type": "object",
+ "required": [
+ "enabled",
+ "enforced"
+ ],
+ "properties": {
+ "enabled": {
"type": "boolean"
},
- "upload_files_drop": {
- "type": "object",
- "required": [
- "enabled"
- ],
- "properties": {
- "enabled": {
- "type": "boolean"
- }
- }
- },
- "password": {
- "type": "object",
- "required": [
- "enabled",
- "enforced"
- ],
- "properties": {
- "enabled": {
- "type": "boolean"
- },
- "enforced": {
- "type": "boolean"
- }
- }
- },
- "expire_date": {
- "type": "object",
- "required": [
- "enabled",
- "enforced"
- ],
- "properties": {
- "enabled": {
- "type": "boolean"
- },
- "enforced": {
- "type": "boolean"
- }
- }
+ "enforced": {
+ "type": "boolean"
}
}
}
}
}
}
- },
- {
- "type": "array",
- "maxItems": 0
}
- ]
+ }
}
}
},
*
* @param string $app ID of the app
* @psalm-suppress LessSpecificReturnStatement The content of the Manifest doesn't need to be described in the return type
- * @return JSONResponse<Http::STATUS_OK, array{name: string, short_name: string, start_url: string, theme_color: string, background_color: string, description: string, icons: array{src: non-empty-string, type: string, sizes: string}[], display: string}, array{}>|JSONResponse<Http::STATUS_NOT_FOUND, array{}, array{}>
+ * @return JSONResponse<Http::STATUS_OK, array{name: string, short_name: string, start_url: string, theme_color: string, background_color: string, description: string, icons: list<array{src: non-empty-string, type: string, sizes: string}>, display: string}, array{}>|JSONResponse<Http::STATUS_NOT_FOUND, array{}, array{}>
*
* 200: Manifest returned
* 404: App not found
* Enable theme
*
* @param string $themeId the theme ID
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSBadRequestException Enabling theme is not possible
* @throws PreConditionNotMetException
*
* Disable theme
*
* @param string $themeId the theme ID
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSBadRequestException Disabling theme is not possible
* @throws PreConditionNotMetException
*
*
* @param string $newVersion Server version to check updates for
*
- * @return DataResponse<Http::STATUS_OK, array{missing: UpdateNotificationApp[], available: UpdateNotificationApp[]}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array{appstore_disabled: bool, already_on_latest?: bool}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{missing: list<UpdateNotificationApp>, available: list<UpdateNotificationApp>}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array{appstore_disabled: bool, already_on_latest?: bool}, array{}>
*
* 200: Apps returned
* 404: New versions not found
* Delete a LDAP configuration
*
* @param string $configID ID of the config
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSException
* @throws OCSNotFoundException Config not found
*
*
* @param string $configID ID of the config
* @param array<string, mixed> $configData New config
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSException
* @throws OCSBadRequestException Modifying config is not possible
* @throws OCSNotFoundException Config not found
return false;
}
+ /**
+ * @param string $uid
+ * @return list<string>
+ */
protected function getCachedGroupsForUserId(string $uid): array {
$groupStr = $this->config->getUserValue($uid, 'user_ldap', 'cached-group-memberships-' . $this->access->connection->getConfigPrefix(), '[]');
return json_decode($groupStr, true) ?? [];
* This function includes groups based on dynamic group membership.
*
* @param string $uid Name of the user
- * @return string[] Group names
+ * @return list<string> Group names
* @throws Exception
* @throws ServerNotAvailableException
*/
* Get all groups a user belongs to
*
* @param string $uid Name of the user
- * @return string[] with group names
+ * @return list<string> with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
*
* @param string $status Only online, away
*
- * @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NO_CONTENT, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, UserStatusPrivate, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NO_CONTENT, list<empty>, array{}>
*
* 200: Status successfully updated
* 204: User has no status to keep alive
/**
* Get all predefined messages
*
- * @return DataResponse<Http::STATUS_OK, UserStatusPredefined[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<UserStatusPredefined>, array{}>
*
* 200: Predefined statuses returned
*/
#[ApiRoute(verb: 'GET', url: '/api/v1/predefined_statuses/')]
public function findAll():DataResponse {
// Filtering out the invisible one, that should only be set by API
- return new DataResponse(array_filter($this->predefinedStatusService->getDefaultStatuses(), function (array $status) {
+ return new DataResponse(array_values(array_filter($this->predefinedStatusService->getDefaultStatuses(), function (array $status) {
return !array_key_exists('visible', $status) || $status['visible'] === true;
- }));
+ })));
}
}
*
* @param int|null $limit Maximum number of statuses to find
* @param int|null $offset Offset for finding statuses
- * @return DataResponse<Http::STATUS_OK, UserStatusPublic[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<UserStatusPublic>, array{}>
*
* 200: Statuses returned
*/
public function findAll(?int $limit = null, ?int $offset = null): DataResponse {
$allStatuses = $this->service->findAll($limit, $offset);
- return new DataResponse(array_map(function ($userStatus) {
+ return new DataResponse(array_values(array_map(function ($userStatus) {
return $this->formatStatus($userStatus);
- }, $allStatuses));
+ }, $allStatuses)));
}
/**
/**
* Clear the message of the current user
*
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
*
* 200: Message cleared successfully
*/
*
* @param string $messageId ID of the message to delete
*
- * @return DataResponse<Http::STATUS_OK, UserStatusPrivate|array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, UserStatusPrivate|list<empty>, array{}>
*
* 200: Status reverted
*/
public function getItems(string $userId, ?string $since = null, int $limit = 7): array {
$widgetItemsData = $this->getWidgetData($userId, $since, $limit);
- return array_map(function (array $widgetData) {
+ return array_values(array_map(function (array $widgetData) {
$formattedDate = $this->dateTimeFormatter->formatTimeSpan($widgetData['timestamp']);
return new WidgetItem(
$widgetData['displayName'],
),
(string)$widgetData['timestamp']
);
- }, $widgetItemsData);
+ }, $widgetItemsData));
}
/**
/**
* Get forecast for current location
*
- * @return DataResponse<Http::STATUS_OK, WeatherStatusForecast[]|array{error: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, WeatherStatusSuccess, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<WeatherStatusForecast>|array{error: string}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, WeatherStatusSuccess, array{}>
*
* 200: Forecast returned
* 404: Forecast not found
/**
* Get favorites list
*
- * @return DataResponse<Http::STATUS_OK, string[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<string>, array{}>
*
* 200: Favorites returned
*/
/**
* Set favorites list
*
- * @param string[] $favorites Favorite addresses
+ * @param list<string> $favorites Favorite addresses
* @return DataResponse<Http::STATUS_OK, WeatherStatusSuccess, array{}>
*
* 200: Favorites updated
/**
* Get favorites list
- * @return string[]
+ * @return list<string>
*/
public function getFavorites(): array {
$favoritesJson = $this->config->getUserValue($this->userId, Application::APP_ID, 'favorites', '');
/**
* Set favorites list
- * @param string[] $favorites
+ * @param list<string> $favorites
* @return WeatherStatusSuccess success state
*/
public function setFavorites(array $favorites): array {
/**
* Get forecast for current location
*
- * @return WeatherStatusForecast[]|array{error: string}|WeatherStatusSuccess which contains success state and filtered forecast data
+ * @return list<WeatherStatusForecast>|array{error: string}|WeatherStatusSuccess which contains success state and filtered forecast data
*/
public function getForecast(): array {
$lat = $this->config->getUserValue($this->userId, Application::APP_ID, 'lat', '');
* @param float $lon Longitude of requested forecast, in decimal degree format
* @param float $altitude Altitude of requested forecast, in meter
* @param int $nbValues Number of forecast values (hours)
- * @return WeatherStatusForecast[]|array{error: string} Filtered forecast data
+ * @return list<WeatherStatusForecast>|array{error: string} Filtered forecast data
*/
private function forecastRequest(float $lat, float $lon, float $altitude, int $nbValues = 10): array {
$params = [
* List registered webhooks
*
* @param string|null $uri The callback URI to filter by
- * @return DataResponse<Http::STATUS_OK, WebhookListenersWebhookInfo[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<WebhookListenersWebhookInfo>, array{}>
* @throws OCSException Other internal error
*
* 200: Webhook registrations returned
$webhookListeners = $this->mapper->getAll();
}
- return new DataResponse(
- array_map(
- fn (WebhookListener $listener): array => $listener->jsonSerialize(),
- $webhookListeners
- )
- );
+ return new DataResponse(array_values(array_map(
+ fn (WebhookListener $listener): array => $listener->jsonSerialize(),
+ $webhookListeners
+ )));
} catch (\Exception $e) {
$this->logger->error('Error when listing webhooks', ['exception' => $e]);
throw new OCSException('An internal error occurred', Http::STATUS_INTERNAL_SERVER_ERROR, $e);
/**
* Delete app password
*
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSForbiddenException Deleting app password is not allowed
*
* 200: App password deleted successfully
*
* @param string $password The password of the user
*
- * @return DataResponse<Http::STATUS_OK, array{lastLogin: int}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{lastLogin: int}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, list<empty>, array{}>
*
* 200: Password confirmation succeeded
* 403: Password confirmation failed
* @param string|null $itemType Type of the items to search for
* @param string|null $itemId ID of the items to search for
* @param string|null $sorter can be piped, top prio first, e.g.: "commenters|share-recipients"
- * @param int[] $shareTypes Types of shares to search for
+ * @param list<int> $shareTypes Types of shares to search for
* @param int $limit Maximum number of results to return
*
- * @return DataResponse<Http::STATUS_OK, CoreAutocompleteResult[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<CoreAutocompleteResult>, array{}>
*
* 200: Autocomplete results returned
*/
}
/**
- * @return CoreAutocompleteResult[]
+ * @return list<CoreAutocompleteResult>
*/
protected function prepareResultArray(array $results): array {
$output = [];
* @param string $userId ID of the user
* @param 64|512 $size Size of the avatar
* @param bool $guestFallback Fallback to guest avatar if not found
- * @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar: int}>|JSONResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
+ * @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar: int}>|JSONResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
*
* 200: Avatar returned
* 201: Avatar returned
* @param string $userId ID of the user
* @param 64|512 $size Size of the avatar
* @param bool $guestFallback Fallback to guest avatar if not found
- * @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar: int}>|JSONResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
+ * @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar: int}>|JSONResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
*
* 200: Avatar returned
* 201: Avatar returned
/**
* Returns a new CSRF token.
*
- * @return JSONResponse<Http::STATUS_OK, array{token: string}, array{}>|JSONResponse<Http::STATUS_FORBIDDEN, array<empty>, array{}>
+ * @return JSONResponse<Http::STATUS_OK, array{token: string}, array{}>|JSONResponse<Http::STATUS_FORBIDDEN, list<empty>, array{}>
*
* 200: CSRF token returned
* 403: Strict cookie check failed
* Poll the login flow credentials
*
* @param string $token Token of the flow
- * @return JSONResponse<Http::STATUS_OK, CoreLoginFlowV2Credentials, array{}>|JSONResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return JSONResponse<Http::STATUS_OK, CoreLoginFlowV2Credentials, array{}>|JSONResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Login flow credentials returned
* 404: Login flow not found or completed
* Get a collection
*
* @param int $collectionId ID of the collection
- * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, list<empty>, array{}>
*
* 200: Collection returned
* 404: Collection not found
* Search for collections
*
* @param string $filter Filter collections
- * @return DataResponse<Http::STATUS_OK, CoreCollection[], array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<CoreCollection>, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Collections returned
* 404: Collection not found
* @param int $collectionId ID of the collection
* @param string $resourceType Name of the resource
* @param string $resourceId ID of the resource
- * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, list<empty>, array{}>
*
* 200: Collection returned
* 404: Collection not found or resource inaccessible
* @param int $collectionId ID of the collection
* @param string $resourceType Name of the resource
* @param string $resourceId ID of the resource
- * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, list<empty>, array{}>
*
* 200: Collection returned
* 404: Collection or resource not found
*
* @param string $resourceType Type of the resource
* @param string $resourceId ID of the resource
- * @return DataResponse<Http::STATUS_OK, CoreCollection[], array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<CoreCollection>, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Collections returned
* 404: Resource not accessible
* @param string $baseResourceType Type of the base resource
* @param string $baseResourceId ID of the base resource
* @param string $name Name of the collection
- * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, list<empty>, array{}>
*
* 200: Collection returned
* 400: Creating collection is not possible
*
* @param int $collectionId ID of the collection
* @param string $collectionName New name
- * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, list<empty>, array{}>
*
* 200: Collection returned
* 404: Collection not found
}
/**
- * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, CoreCollection, array{}>|DataResponse<Http::STATUS_NOT_FOUND|Http::STATUS_INTERNAL_SERVER_ERROR, list<empty>, array{}>
*/
protected function respondCollection(ICollection $collection): DataResponse {
try {
}
/**
- * @return CoreCollection[]
+ * @return list<CoreCollection>
*/
protected function prepareCollections(array $collections): array {
$result = [];
}
/**
- * @return CoreResource[]
+ * @return list<CoreResource>
*/
protected function prepareResources(array $resources): array {
$result = [];
* Get the account details for a hovercard
*
* @param string $userId ID of the user
- * @return DataResponse<Http::STATUS_OK, array{userId: string, displayName: string, actions: CoreContactsAction[]}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{userId: string, displayName: string, actions: list<CoreContactsAction>}, array{}>|DataResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Account details returned
* 404: Account not found
array_unshift($actions, $data['topAction']);
}
- /** @var CoreContactsAction[] $actions */
+ /** @var list<CoreContactsAction> $actions */
return new DataResponse([
'userId' => $userId,
'displayName' => $contact->getFullName(),
*
* @param string $password The password of the user
*
- * @return DataResponse<Http::STATUS_OK, array{lastLogin: int}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{lastLogin: int}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, list<empty>, array{}>
*
* 200: Password confirmation succeeded
* 403: Password confirmation failed
* Get the apps navigation
*
* @param bool $absolute Rewrite URLs to absolute ones
- * @return DataResponse<Http::STATUS_OK, CoreNavigationEntry[], array{}>|DataResponse<Http::STATUS_NOT_MODIFIED, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<CoreNavigationEntry>, array{}>|DataResponse<Http::STATUS_NOT_MODIFIED, list<empty>, array{}>
*
* 200: Apps navigation returned
* 304: No apps navigation changed
* Get the settings navigation
*
* @param bool $absolute Rewrite URLs to absolute ones
- * @return DataResponse<Http::STATUS_OK, CoreNavigationEntry[], array{}>|DataResponse<Http::STATUS_NOT_MODIFIED, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<CoreNavigationEntry>, array{}>|DataResponse<Http::STATUS_NOT_MODIFIED, list<empty>, array{}>
*
* 200: Apps navigation returned
* 304: No apps navigation changed
*
* @psalm-suppress MoreSpecificReturnType
* @psalm-suppress LessSpecificReturnStatement
- * @return DataResponse<Http::STATUS_OK, array{enabled: bool, apiVersion: string, endPoint: string, resourceTypes: array{name: string, shareTypes: string[], protocols: array{webdav: string}}[]}, array{X-NEXTCLOUD-OCM-PROVIDERS: true, Content-Type: 'application/json'}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{enabled: bool, apiVersion: string, endPoint: string, resourceTypes: list<array{name: string, shareTypes: list<string>, protocols: array{webdav: string}}>}, array{X-NEXTCLOUD-OCM-PROVIDERS: true, Content-Type: 'application/json'}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: OCM Provider details returned
* 500: OCM not supported
* @param bool $forceIcon Force returning an icon
* @param 'fill'|'cover' $mode How to crop the image
* @param bool $mimeFallback Whether to fallback to the mime icon if no preview is available
- * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>|RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
+ * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, list<empty>, array{}>|RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
*
* 200: Preview returned
* 303: Redirect to the mime icon url if mimeFallback is true
* @param bool $forceIcon Force returning an icon
* @param 'fill'|'cover' $mode How to crop the image
* @param bool $mimeFallback Whether to fallback to the mime icon if no preview is available
- * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>|RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
+ * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, list<empty>, array{}>|RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
*
* 200: Preview returned
* 303: Redirect to the mime icon url if mimeFallback is true
}
/**
- * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>|RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
+ * @return FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|DataResponse<Http::STATUS_BAD_REQUEST|Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, list<empty>, array{}>|RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
*/
private function fetchPreview(
Node $node,
* @param string $targetUserId ID of the user
* @param string $paramId ID of the parameter
* @param string $visibility New visibility
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSBadRequestException Updating visibility is not possible
* @throws OCSForbiddenException Not allowed to edit other users visibility
* @throws OCSNotFoundException Account not found
/**
* Resolve multiple references
*
- * @param string[] $references References to resolve
+ * @param list<string> $references References to resolve
* @param int $limit Maximum amount of references to resolve
* @return DataResponse<Http::STATUS_OK, array{references: array<string, CoreReference|null>}, array{}>
*
/**
* Resolve multiple references from a public page
*
- * @param string[] $references References to resolve
+ * @param list<string> $references References to resolve
* @param string $sharingToken Token of the public share
* @param int $limit Maximum amount of references to resolve, limited to 15
* @return DataResponse<Http::STATUS_OK, array{references: array<string, CoreReference|null>}, array{}>
/**
* Get the providers
*
- * @return DataResponse<Http::STATUS_OK, CoreReferenceProvider[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<CoreReferenceProvider>, array{}>
*
* 200: Providers returned
*/
#[ApiRoute(verb: 'GET', url: '/providers', root: '/references')]
public function getProvidersInfo(): DataResponse {
$providers = $this->referenceManager->getDiscoverableProviders();
- $jsonProviders = array_map(static function (IDiscoverableReferenceProvider $provider) {
+ $jsonProviders = array_values(array_map(static function (IDiscoverableReferenceProvider $provider) {
return $provider->jsonSerialize();
- }, $providers);
+ }, $providers));
return new DataResponse($jsonProviders);
}
#[ApiRoute(verb: 'GET', url: '/tasktypes', root: '/taskprocessing')]
public function taskTypes(): DataResponse {
$taskTypes = array_map(function (array $tt) {
- $tt['inputShape'] = array_map(function ($descriptor) {
+ $tt['inputShape'] = array_values(array_map(function ($descriptor) {
return $descriptor->jsonSerialize();
- }, $tt['inputShape']);
- $tt['outputShape'] = array_map(function ($descriptor) {
+ }, $tt['inputShape']));
+ $tt['outputShape'] = array_values(array_map(function ($descriptor) {
return $descriptor->jsonSerialize();
- }, $tt['outputShape']);
- $tt['optionalInputShape'] = array_map(function ($descriptor) {
+ }, $tt['outputShape']));
+ $tt['optionalInputShape'] = array_values(array_map(function ($descriptor) {
return $descriptor->jsonSerialize();
- }, $tt['optionalInputShape']);
- $tt['optionalOutputShape'] = array_map(function ($descriptor) {
+ }, $tt['optionalInputShape']));
+ $tt['optionalOutputShape'] = array_values(array_map(function ($descriptor) {
return $descriptor->jsonSerialize();
- }, $tt['optionalOutputShape']);
- $tt['inputShapeEnumValues'] = array_map(function (array $enumValues) {
- return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues);
- }, $tt['inputShapeEnumValues']);
- $tt['optionalInputShapeEnumValues'] = array_map(function (array $enumValues) {
- return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues);
- }, $tt['optionalInputShapeEnumValues']);
- $tt['outputShapeEnumValues'] = array_map(function (array $enumValues) {
- return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues);
- }, $tt['outputShapeEnumValues']);
- $tt['optionalOutputShapeEnumValues'] = array_map(function (array $enumValues) {
- return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues);
- }, $tt['optionalOutputShapeEnumValues']);
+ }, $tt['optionalOutputShape']));
+ $tt['inputShapeEnumValues'] = array_values(array_map(function (array $enumValues) {
+ return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues));
+ }, $tt['inputShapeEnumValues']));
+ $tt['optionalInputShapeEnumValues'] = array_values(array_map(function (array $enumValues) {
+ return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues));
+ }, $tt['optionalInputShapeEnumValues']));
+ $tt['outputShapeEnumValues'] = array_values(array_map(function (array $enumValues) {
+ return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues));
+ }, $tt['outputShapeEnumValues']));
+ $tt['optionalOutputShapeEnumValues'] = array_values(array_map(function (array $enumValues) {
+ return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues));
+ }, $tt['optionalOutputShapeEnumValues']));
return $tt;
}, $this->taskProcessingManager->getAvailableTaskTypes());
return new DataResponse([
*
* @param string $appId ID of the app
* @param string|null $customId An arbitrary identifier for the task
- * @return DataResponse<Http::STATUS_OK, array{tasks: CoreTaskProcessingTask[]}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{tasks: list<CoreTaskProcessingTask>}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Tasks returned
*/
public function listTasksByApp(string $appId, ?string $customId = null): DataResponse {
try {
$tasks = $this->taskProcessingManager->getUserTasksByApp($this->userId, $appId, $customId);
- /** @var CoreTaskProcessingTask[] $json */
$json = array_map(static function (Task $task) {
return $task->jsonSerialize();
}, $tasks);
*
* @param string|null $taskType The task type to filter by
* @param string|null $customId An arbitrary identifier for the task
- * @return DataResponse<Http::STATUS_OK, array{tasks: CoreTaskProcessingTask[]}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{tasks: list<CoreTaskProcessingTask>}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Tasks returned
*/
public function listTasks(?string $taskType, ?string $customId = null): DataResponse {
try {
$tasks = $this->taskProcessingManager->getUserTasks($this->userId, $taskType, $customId);
- /** @var CoreTaskProcessingTask[] $json */
$json = array_map(static function (Task $task) {
return $task->jsonSerialize();
}, $tasks);
* Get all resources of a team
*
* @param string $teamId Unique id of the team
- * @return DataResponse<Http::STATUS_OK, array{resources: CoreTeamResource[]}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{resources: list<CoreTeamResource>}, array{}>
*
* 200: Resources returned
*/
#[ApiRoute(verb: 'GET', url: '/{teamId}/resources', root: '/teams')]
public function resolveOne(string $teamId): DataResponse {
/**
- * @var CoreTeamResource[] $resolvedResources
+ * @var list<CoreTeamResource> $resolvedResources
* @psalm-suppress PossiblyNullArgument The route is limited to logged-in users
*/
$resolvedResources = $this->teamManager->getSharedWith($teamId, $this->userId);
*
* @param string $providerId Identifier of the provider (e.g. deck, talk, collectives)
* @param string $resourceId Unique id of the resource to list teams for (e.g. deck board id)
- * @return DataResponse<Http::STATUS_OK, array{teams: CoreTeam[]}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{teams: list<CoreTeam>}, array{}>
*
* 200: Teams returned
*/
public function listTeams(string $providerId, string $resourceId): DataResponse {
/** @psalm-suppress PossiblyNullArgument The route is limited to logged-in users */
$teams = $this->teamManager->getTeamsForResource($providerId, $resourceId, $this->userId);
- /** @var CoreTeam[] $teams */
- $teams = array_map(function (Team $team) {
+ /** @var list<CoreTeam> $teams */
+ $teams = array_values(array_map(function (Team $team) {
$response = $team->jsonSerialize();
/** @psalm-suppress PossiblyNullArgument The route is limited to logged in users */
$response['resources'] = $this->teamManager->getSharedWith($team->getId(), $this->userId);
return $response;
- }, $teams);
+ }, $teams));
return new DataResponse([
'teams' => $teams,
/**
* This endpoint returns all available LanguageModel task types
*
- * @return DataResponse<Http::STATUS_OK, array{types: array{id: string, name: string, description: string}[]}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{types: list<array{id: string, name: string, description: string}>}, array{}>
*
* 200: Task types returned
*/
*
* @param string $appId ID of the app
* @param string|null $identifier An arbitrary identifier for the task
- * @return DataResponse<Http::STATUS_OK, array{tasks: CoreTextProcessingTask[]}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{tasks: list<CoreTextProcessingTask>}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Task list returned
*/
public function listTasksByApp(string $appId, ?string $identifier = null): DataResponse {
try {
$tasks = $this->textProcessingManager->getUserTasksByApp($this->userId, $appId, $identifier);
- /** @var CoreTextProcessingTask[] $json */
- $json = array_map(static function (Task $task) {
+ $json = array_values(array_map(static function (Task $task) {
return $task->jsonSerialize();
- }, $tasks);
+ }, $tasks));
return new DataResponse([
'tasks' => $json,
*
* @param string $appId ID of the app
* @param string|null $identifier An arbitrary identifier for the task
- * @return DataResponse<Http::STATUS_OK, array{tasks: CoreTextToImageTask[]}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{tasks: list<CoreTextToImageTask>}, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*
* 200: Task list returned
*/
public function listTasksByApp(string $appId, ?string $identifier = null): DataResponse {
try {
$tasks = $this->textToImageManager->getUserTasksByApp($this->userId, $appId, $identifier);
- /** @var CoreTextToImageTask[] $json */
- $json = array_map(static function (Task $task) {
+ $json = array_values(array_map(static function (Task $task) {
return $task->jsonSerialize();
- }, $tasks);
+ }, $tasks));
return new DataResponse([
'tasks' => $json,
/**
* Get the list of supported languages
*
- * @return DataResponse<Http::STATUS_OK, array{languages: array{from: string, fromLabel: string, to: string, toLabel: string}[], languageDetection: bool}, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{languages: list<array{from: string, fromLabel: string, to: string, toLabel: string}>, languageDetection: bool}, array{}>
*
* 200: Supported languages returned
*/
#[ApiRoute(verb: 'GET', url: '/languages', root: '/translation')]
public function languages(): DataResponse {
return new DataResponse([
- 'languages' => array_map(fn ($lang) => $lang->jsonSerialize(), $this->translationManager->getLanguages()),
+ 'languages' => array_values(array_map(fn ($lang) => $lang->jsonSerialize(), $this->translationManager->getLanguages())),
'languageDetection' => $this->translationManager->canDetectLanguage(),
]);
}
* Get the providers for unified search
*
* @param string $from the url the user is currently at
- * @return DataResponse<Http::STATUS_OK, CoreUnifiedSearchProvider[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<CoreUnifiedSearchProvider>, array{}>
*
* 200: Providers returned
*/
/**
* Get the changes
*
- * @return DataResponse<Http::STATUS_OK, array{changelogURL: string, product: string, version: string, whatsNew?: array{regular: string[], admin: string[]}}, array{}>|DataResponse<Http::STATUS_NO_CONTENT, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, array{changelogURL: string, product: string, version: string, whatsNew?: array{regular: list<string>, admin: list<string>}}, array{}>|DataResponse<Http::STATUS_NO_CONTENT, list<empty>, array{}>
*
* 200: Changes returned
* 204: No changes
*
* @param string $version Version to dismiss the changes for
*
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws \OCP\PreConditionNotMetException
* @throws DoesNotExistException
*
*
* @param string $token App password
*
- * @return JSONResponse<Http::STATUS_OK, array{wipe: bool}, array{}>|JSONResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return JSONResponse<Http::STATUS_OK, array{wipe: bool}, array{}>|JSONResponse<Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Device should be wiped
* 404: Device should not be wiped
*
* @param string $token App password
*
- * @return JSONResponse<Http::STATUS_OK|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return JSONResponse<Http::STATUS_OK|Http::STATUS_NOT_FOUND, list<empty>, array{}>
*
* 200: Wipe finished successfully
* 404: Device should not be wiped
* @psalm-type CoreCollection = array{
* id: int,
* name: string,
- * resources: CoreResource[],
+ * resources: list<CoreResource>,
* }
*
* @psalm-type CoreReference = array{
* title: string,
* icon_url: string,
* order: int,
- * search_providers_ids: ?string[]
+ * search_providers_ids: ?list<string>,
* }
*
* @psalm-type CoreUnifiedSearchProvider = array{
* name: string,
* icon: string,
* order: int,
- * triggers: string[],
+ * triggers: list<string>,
* filters: array<string, string>,
* inAppSearch: bool,
* }
* resourceUrl: string,
* icon: string,
* rounded: bool,
- * attributes: string[],
+ * attributes: list<string>,
* }
*
* @psalm-type CoreUnifiedSearchResult = array{
* name: string,
* isPaginated: bool,
- * entries: CoreUnifiedSearchResultEntry[],
+ * entries: list<CoreUnifiedSearchResultEntry>,
* cursor: int|string|null,
* }
*
* @psalm-type CoreTaskProcessingTaskType = array{
* name: string,
* description: string,
- * inputShape: CoreTaskProcessingShape[],
- * inputShapeEnumValues: array{name: string, value: string}[][],
+ * inputShape: list<CoreTaskProcessingShape>,
+ * inputShapeEnumValues: list<list<array{name: string, value: string}>>,
* inputShapeDefaults: array<string, numeric|string>,
- * optionalInputShape: CoreTaskProcessingShape[],
- * optionalInputShapeEnumValues: array{name: string, value: string}[][],
+ * optionalInputShape: list<CoreTaskProcessingShape>,
+ * optionalInputShapeEnumValues: list<list<array{name: string, value: string}>>,
* optionalInputShapeDefaults: array<string, numeric|string>,
- * outputShape: CoreTaskProcessingShape[],
- * outputShapeEnumValues: array{name: string, value: string}[][],
- * optionalOutputShape: CoreTaskProcessingShape[],
- * optionalOutputShapeEnumValues: array{name: string, value: string}[][]}
+ * outputShape: list<CoreTaskProcessingShape>,
+ * outputShapeEnumValues: list<list<array{name: string, value: string}>>,
+ * optionalOutputShape: list<CoreTaskProcessingShape>,
+ * optionalOutputShapeEnumValues: list<list<array{name: string, value: string}>>,
* }
*
* @psalm-type CoreTaskProcessingIO = array<string, numeric|list<numeric>|string|list<string>>
* output: null|CoreTaskProcessingIO,
* customId: ?string,
* completionExpectedAt: ?int,
- * progress: ?float
+ * progress: ?float,
+ * scheduledAt: ?int,
+ * startedAt: ?int,
+ * endedAt: ?int,
* }
*
*/
"output",
"customId",
"completionExpectedAt",
- "progress"
+ "progress",
+ "scheduledAt",
+ "startedAt",
+ "endedAt"
],
"properties": {
"id": {
"type": "number",
"format": "double",
"nullable": true
+ },
+ "scheduledAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ },
+ "startedAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ },
+ "endedAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
}
}
}
"output",
"customId",
"completionExpectedAt",
- "progress"
+ "progress",
+ "scheduledAt",
+ "startedAt",
+ "endedAt"
],
"properties": {
"id": {
"type": "number",
"format": "double",
"nullable": true
+ },
+ "scheduledAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ },
+ "startedAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ },
+ "endedAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
}
}
},
"output",
"customId",
"completionExpectedAt",
- "progress"
+ "progress",
+ "scheduledAt",
+ "startedAt",
+ "endedAt"
],
"properties": {
"id": {
"type": "number",
"format": "double",
"nullable": true
+ },
+ "scheduledAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ },
+ "startedAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
+ },
+ "endedAt": {
+ "type": "integer",
+ "format": "int64",
+ "nullable": true
}
}
},
/**
* @inheritDoc
*
- * @return string[] list of app ids
+ * @return list<string> list of app ids
* @since 7.0.0
*/
public function getApps(): array {
*
* @param string $app id of the app
*
- * @return string[] list of stored config keys
+ * @return list<string> list of stored config keys
* @since 29.0.0
*/
public function getKeys(string $app): array {
}
public function listTemplates(): array {
- return array_map(function (TemplateFileCreator $entry) {
+ return array_values(array_map(function (TemplateFileCreator $entry) {
return array_merge($entry->jsonSerialize(), [
'templates' => $this->getTemplateFiles($entry)
]);
- }, $this->listCreators());
+ }, $this->listCreators()));
}
/**
throw new NotFoundException();
}
+ /**
+ * @return list<Template>
+ */
private function getTemplateFiles(TemplateFileCreator $type): array {
$templates = [];
foreach ($this->getRegisteredProviders() as $provider) {
/**
* Get all groups a user belongs to
* @param string $uid Name of the user
- * @return array an array of group names
+ * @return list<string> an array of group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
/**
* Get all groups a user belongs to
* @param string $uid Name of the user
- * @return array an array of group names
+ * @return list<string> an array of group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
* get a list of group ids for a user
*
* @param IUser $user
- * @return string[] with group ids
+ * @return list<string> with group ids
*/
public function getUserGroupIds(IUser $user): array {
return $this->getUserIdGroupIds($user->getUID());
/**
* @param string $uid the user id
- * @return string[]
+ * @return list<string>
*/
private function getUserIdGroupIds(string $uid): array {
if (!isset($this->cachedUserGroups[$uid])) {
* enabled: bool,
* apiVersion: string,
* endPoint: string,
- * resourceTypes: array{
- * name: string,
- * shareTypes: string[],
- * protocols: array<string, string>
- * }[]
- * }
+ * resourceTypes: list<array{
+ * name: string,
+ * shareTypes: list<string>,
+ * protocols: array<string, string>
+ * }>,
+ * }
*/
public function jsonSerialize(): array {
$resourceTypes = [];
*/
class OCMResource implements IOCMResource {
private string $name = '';
- /** @var string[] */
+ /** @var list<string> */
private array $shareTypes = [];
/** @var array<string, string> */
private array $protocols = [];
}
/**
- * @param string[] $shareTypes
+ * @param list<string> $shareTypes
*
* @return $this
*/
}
/**
- * @return string[]
+ * @return list<string>
*/
public function getShareTypes(): array {
return $this->shareTypes;
/**
* @return array{
* name: string,
- * shareTypes: string[],
+ * shareTypes: list<string>,
* protocols: array<string, string>
* }
*/
use InvalidArgumentException;
use OC\AppFramework\Bootstrap\Coordinator;
+use OC\Core\ResponseDefinitions;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Search\FilterDefinition;
* results are awaited or shown as they come in.
*
* @see IProvider::search() for the arguments of the individual search requests
+ * @psalm-import-type CoreUnifiedSearchProvider from ResponseDefinitions
*/
class SearchComposer {
/**
* @param string $route the route the user is currently at
* @param array $routeParameters the parameters of the route the user is currently at
*
- * @return array
+ * @return list<CoreUnifiedSearchProvider>
*/
public function getProviders(string $route, array $routeParameters): array {
$this->loadLazyProviders();
'name' => $provider->getName(),
'icon' => $this->fetchIcon($appId, $provider->getId()),
'order' => $order,
- 'triggers' => $triggers,
+ 'triggers' => array_values($triggers),
'filters' => $this->getFiltersType($filters, $provider->getId()),
'inAppSearch' => $provider instanceof IInAppSearch,
];
/**
* Get the list of tags for the given ids.
*
- * @param array $objIds array of object ids
- * @return array|false of tags id as key to array of tag names
- * or false if an error occurred
+ * @param list<int> $objIds array of object ids
+ * @return array<int, list<string>>|false of tags id as key to array of tag names
+ * or false if an error occurred
*/
public function getTagsForObjects(array $objIds) {
$entries = [];
array_push($resources, ...$provider->getSharedWith($teamId));
}
- return $resources;
+ return array_values($resources);
}
public function getTeamsForResource(string $providerId, string $resourceId, string $userId): array {
/**
* @throws DoesNotExistException
- * @return array{changelogURL: string, whatsNew: array<string, array{admin: string[], regular: string[]}>}
+ * @return array{changelogURL: string, whatsNew: array<string, array{admin: list<string>, regular: list<string>}>}
*/
public function getChangesForVersion(string $version): array {
$version = $this->normalizeVersion($version);
* @param bool $forceRefresh whether to refresh the cache
* @param bool $all whether to return apps for all users, not only the
* currently logged in one
- * @return string[]
+ * @return list<string>
*/
public static function getEnabledApps(bool $forceRefresh = false, bool $all = false): array {
if (!\OC::$server->getSystemConfig()->getValue('installed', false)) {
namespace OCP\Dashboard;
+use OCP\Dashboard\Model\WidgetItem;
+
/**
* interface IAPIWidget
*
*/
interface IAPIWidget extends IWidget {
/**
- * @return \OCP\Dashboard\Model\WidgetItem[] The widget items
+ * @return list<WidgetItem> The widget items
* @since 22.0.0
*/
public function getItems(string $userId, ?string $since = null, int $limit = 7): array;
* Get the buttons to show on the widget
*
* @param string $userId
- * @return WidgetButton[]
+ * @return list<WidgetButton>
* @since 25.0.0
*/
public function getWidgetButtons(string $userId): array;
/**
* @since 22.0.0
- *
- * @return array
+ * @return array{
+ * subtitle: string,
+ * title: string,
+ * link: string,
+ * iconUrl: string,
+ * overlayIconUrl: string,
+ * sinceId: string,
+ * }
*/
public function jsonSerialize(): array {
return [
abstract public function setValue(mixed $value): void;
/**
+ * @return array{
+ * index: string,
+ * type: string,
+ * alias: ?string,
+ * tag: ?string,
+ * id: ?int,
+ * content?: string,
+ * checked?: bool,
+ * }
* @since 30.0.0
*/
public function jsonSerialize(): array {
}
/**
+ * @return array{
+ * index: string,
+ * type: string,
+ * alias: ?string,
+ * tag: ?string,
+ * id: ?int,
+ * content?: string,
+ * checked?: bool,
+ * }
* @since 30.0.0
*/
public function jsonSerialize(): array {
}
/**
+ * @return array{
+ * index: string,
+ * type: string,
+ * alias: ?string,
+ * tag: ?string,
+ * id: ?int,
+ * content?: string,
+ * checked?: bool,
+ * }
* @since 30.0.0
*/
public function jsonSerialize(): array {
/**
* Get a list of available file creators and their offered templates
*
- * @return array
+ * @return list<array{app: string, label: string, extension: string, iconClass: ?string, iconSvgInline: ?string, mimetypes: list<string>, ratio: ?float, actionLabel: string, templates: list<Template>}>
* @since 21.0.0
*/
public function listTemplates(): array;
private $hasPreview = false;
/** @var string|null */
private $previewUrl = null;
- /** @var array */
+ /** @var list<Field> */
private $fields = [];
/**
}
/**
+ * @param list<Field> $fields
* @since 30.0.0
*/
public function setFields(array $fields): void {
}
/**
+ * @return array{
+ * templateType: string,
+ * templateId: string,
+ * basename: string,
+ * etag: string,
+ * fileid: int,
+ * filename: string,
+ * lastmod: int,
+ * mime: string,
+ * size: int|float,
+ * type: string,
+ * hasPreview: bool,
+ * previewUrl: ?string,
+ * fields: list<array{
+ * index: string,
+ * type: string,
+ * alias: ?string,
+ * tag: ?string,
+ * id: ?int,
+ * content?: string,
+ * checked?: bool,
+ * }>,
+ * }
* @since 21.0.0
*/
public function jsonSerialize(): array {
'type' => $this->file->getType(),
'hasPreview' => $this->hasPreview,
'previewUrl' => $this->previewUrl,
- 'fields' => $this->fields
+ 'fields' => array_map(static fn (Field $field) => $field->jsonSerialize(), $this->fields),
];
}
}
*/
final class TemplateFileCreator implements \JsonSerializable {
protected $appId;
- /** @var string[] $mimetypes */
+ /** @var list<string> $mimetypes */
protected $mimetypes = [];
protected $actionName;
protected $fileExtension;
/**
* @since 21.0.0
- * @return array{app: string, label: string, extension: string, iconClass: ?string, iconSvgInline: ?string, mimetypes: string[], ratio: ?float, actionLabel: string}
+ * @return array{app: string, label: string, extension: string, iconClass: ?string, iconSvgInline: ?string, mimetypes: list<string>, ratio: ?float, actionLabel: string}
*/
public function jsonSerialize(): array {
return [
/**
* Get all groups a user belongs to
* @param string $uid Name of the user
- * @return array an array of group names
+ * @return list<string> an array of group names
* @since 4.5.0
*
* This function fetches all groups a user belongs to. It does not check
*
* **WARNING:** ignore lazy filtering, all config values are loaded from database
*
- * @return string[] list of app ids
+ * @return list<string> list of app ids
* @since 7.0.0
*/
public function getApps(): array;
*
* @param string $app id of the app
*
- * @return string[] list of stored config keys
+ * @return list<string> list of stored config keys
* @since 29.0.0
*/
public function getKeys(string $app): array;
* ]
* ```
*
- * @param array $objIds item ids
- * @return array|false with object id as key and an array
- * of tag names as value or false if an error occurred
+ * @param list<int> $objIds item ids
+ * @return array<int, list<string>>|false with object id as key and an array
+ * of tag names as value or false if an error occurred
* @since 8.0.0
*/
public function getTagsForObjects(array $objIds);
* enabled: bool,
* apiVersion: string,
* endPoint: string,
- * resourceTypes: array{
+ * resourceTypes: list<array{
* name: string,
- * shareTypes: string[],
+ * shareTypes: list<string>,
* protocols: array<string, string>
- * }[]
+ * }>,
* }
* @since 28.0.0
*/
/**
* set share types
*
- * @param string[] $shareTypes
+ * @param list<string> $shareTypes
*
* @return $this
* @since 28.0.0
/**
* get share types
*
- * @return string[]
+ * @return list<string>
* @since 28.0.0
*/
public function getShareTypes(): array;
/**
* @return array{
* name: string,
- * shareTypes: string[],
+ * shareTypes: list<string>,
* protocols: array<string, string>
* }
* @since 28.0.0
public function getPreferredProvider(string $taskTypeId);
/**
- * @return array<array-key,array{name: string, description: string, inputShape: ShapeDescriptor[], inputShapeEnumValues: ShapeEnumValue[][], inputShapeDefaults: array<array-key, numeric|string>, optionalInputShape: ShapeDescriptor[], optionalInputShapeEnumValues: ShapeEnumValue[][], optionalInputShapeDefaults: array<array-key, numeric|string>, outputShape: ShapeDescriptor[], outputShapeEnumValues: ShapeEnumValue[][], optionalOutputShape: ShapeDescriptor[], optionalOutputShapeEnumValues: ShapeEnumValue[][]}>
+ * @return array<string, array{name: string, description: string, inputShape: ShapeDescriptor[], inputShapeEnumValues: ShapeEnumValue[][], inputShapeDefaults: array<array-key, numeric|string>, optionalInputShape: ShapeDescriptor[], optionalInputShapeEnumValues: ShapeEnumValue[][], optionalInputShapeDefaults: array<array-key, numeric|string>, outputShape: ShapeDescriptor[], outputShapeEnumValues: ShapeEnumValue[][], optionalOutputShape: ShapeDescriptor[], optionalOutputShapeEnumValues: ShapeEnumValue[][]}>
* @since 30.0.0
*/
public function getAvailableTaskTypes(): array;
}
/**
- * @psalm-return array{id: ?int, lastUpdated: int, type: string, status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN', userId: ?string, appId: string, input: array<array-key, list<numeric|string>|numeric|string>, output: ?array<array-key, list<numeric|string>|numeric|string>, customId: ?string, completionExpectedAt: ?int, progress: ?float, scheduledAt: ?int, startedAt: ?int, endedAt: ?int}
+ * @psalm-return array{id: int, lastUpdated: int, type: string, status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN', userId: ?string, appId: string, input: array<string, list<numeric|string>|numeric|string>, output: ?array<string, list<numeric|string>|numeric|string>, customId: ?string, completionExpectedAt: ?int, progress: ?float, scheduledAt: ?int, startedAt: ?int, endedAt: ?int}
* @since 30.0.0
*/
final public function jsonSerialize(): array {
return [
- 'id' => $this->getId(),
+ 'id' => (int)$this->getId(),
'type' => $this->getTaskTypeId(),
'lastUpdated' => $this->getLastUpdated(),
'status' => self::statusToString($this->getStatus()),
/**
* Returns all team resources for a given team and user
*
- * @return TeamResource[]
+ * @return list<TeamResource>
* @since 29.0.0
*/
public function getSharedWith(string $teamId, string $userId): array;