diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-11-06 08:56:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 08:56:30 +0100 |
commit | d53fde8eef13d408fcf035ea8a95e6345df9b99b (patch) | |
tree | 60f6b612d967a9a264589cdd6cc0c6d008e1bf05 /lib | |
parent | 8fab143aa486904f7a17c4f1c2f6364cd43bf9d9 (diff) | |
parent | 77114fb3277742fc69ddcf2432311ecb263af97e (diff) | |
download | nextcloud-server-d53fde8eef13d408fcf035ea8a95e6345df9b99b.tar.gz nextcloud-server-d53fde8eef13d408fcf035ea8a95e6345df9b99b.zip |
Merge pull request #49015 from nextcloud/fix/openapi/array-syntax
Diffstat (limited to 'lib')
29 files changed, 115 insertions, 51 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index 312b6973403..a0e5d7e28e8 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -76,7 +76,7 @@ class AppConfig implements IAppConfig { /** * @inheritDoc * - * @return string[] list of app ids + * @return list<string> list of app ids * @since 7.0.0 */ public function getApps(): array { @@ -92,7 +92,7 @@ class AppConfig implements IAppConfig { * * @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 { diff --git a/lib/private/Files/Template/TemplateManager.php b/lib/private/Files/Template/TemplateManager.php index 865af4eb90c..47011f875ae 100644 --- a/lib/private/Files/Template/TemplateManager.php +++ b/lib/private/Files/Template/TemplateManager.php @@ -118,11 +118,11 @@ class TemplateManager implements ITemplateManager { } 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())); } /** @@ -180,6 +180,9 @@ class TemplateManager implements ITemplateManager { throw new NotFoundException(); } + /** + * @return list<Template> + */ private function getTemplateFiles(TemplateFileCreator $type): array { $templates = []; foreach ($this->getRegisteredProviders() as $provider) { diff --git a/lib/private/Group/Backend.php b/lib/private/Group/Backend.php index f6844308a15..f4a90018b5a 100644 --- a/lib/private/Group/Backend.php +++ b/lib/private/Group/Backend.php @@ -71,7 +71,7 @@ abstract class Backend implements \OCP\GroupInterface { /** * 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. diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php index 095cbe24316..0cb571a3935 100644 --- a/lib/private/Group/Database.php +++ b/lib/private/Group/Database.php @@ -194,7 +194,7 @@ class Database extends ABackend implements /** * 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. diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index bd46780a602..e58a1fe6585 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -361,7 +361,7 @@ class Manager extends PublicEmitter implements IGroupManager { * 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()); @@ -369,7 +369,7 @@ class Manager extends PublicEmitter implements IGroupManager { /** * @param string $uid the user id - * @return string[] + * @return list<string> */ private function getUserIdGroupIds(string $uid): array { if (!isset($this->cachedUserGroups[$uid])) { diff --git a/lib/private/OCM/Model/OCMProvider.php b/lib/private/OCM/Model/OCMProvider.php index 9bda95ebc17..73002ae668d 100644 --- a/lib/private/OCM/Model/OCMProvider.php +++ b/lib/private/OCM/Model/OCMProvider.php @@ -194,12 +194,12 @@ class OCMProvider implements IOCMProvider { * 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 = []; diff --git a/lib/private/OCM/Model/OCMResource.php b/lib/private/OCM/Model/OCMResource.php index 68f9ee18f79..3d619db1927 100644 --- a/lib/private/OCM/Model/OCMResource.php +++ b/lib/private/OCM/Model/OCMResource.php @@ -16,7 +16,7 @@ use OCP\OCM\IOCMResource; */ class OCMResource implements IOCMResource { private string $name = ''; - /** @var string[] */ + /** @var list<string> */ private array $shareTypes = []; /** @var array<string, string> */ private array $protocols = []; @@ -40,7 +40,7 @@ class OCMResource implements IOCMResource { } /** - * @param string[] $shareTypes + * @param list<string> $shareTypes * * @return $this */ @@ -51,7 +51,7 @@ class OCMResource implements IOCMResource { } /** - * @return string[] + * @return list<string> */ public function getShareTypes(): array { return $this->shareTypes; @@ -92,7 +92,7 @@ class OCMResource implements IOCMResource { /** * @return array{ * name: string, - * shareTypes: string[], + * shareTypes: list<string>, * protocols: array<string, string> * } */ diff --git a/lib/private/Search/SearchComposer.php b/lib/private/Search/SearchComposer.php index d23662f7055..71fd003717c 100644 --- a/lib/private/Search/SearchComposer.php +++ b/lib/private/Search/SearchComposer.php @@ -10,6 +10,7 @@ namespace OC\Search; use InvalidArgumentException; use OC\AppFramework\Bootstrap\Coordinator; +use OC\Core\ResponseDefinitions; use OCP\IURLGenerator; use OCP\IUser; use OCP\Search\FilterDefinition; @@ -43,6 +44,7 @@ use function array_map; * 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 { /** @@ -156,7 +158,7 @@ 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(); @@ -183,7 +185,7 @@ class SearchComposer { '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, ]; diff --git a/lib/private/Tags.php b/lib/private/Tags.php index 1f22a4c6a33..d59c1bd6928 100644 --- a/lib/private/Tags.php +++ b/lib/private/Tags.php @@ -147,9 +147,9 @@ class Tags implements ITags { /** * 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 = []; diff --git a/lib/private/Teams/TeamManager.php b/lib/private/Teams/TeamManager.php index 223579a1182..d75b0209c71 100644 --- a/lib/private/Teams/TeamManager.php +++ b/lib/private/Teams/TeamManager.php @@ -80,7 +80,7 @@ class TeamManager implements ITeamManager { array_push($resources, ...$provider->getSharedWith($teamId)); } - return $resources; + return array_values($resources); } public function getTeamsForResource(string $providerId, string $resourceId, string $userId): array { diff --git a/lib/private/Updater/ChangesCheck.php b/lib/private/Updater/ChangesCheck.php index df017b09040..e88969f62a8 100644 --- a/lib/private/Updater/ChangesCheck.php +++ b/lib/private/Updater/ChangesCheck.php @@ -32,7 +32,7 @@ class ChangesCheck { /** * @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); diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 6afd4086cb3..544938b6ff9 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -169,7 +169,7 @@ class OC_App { * @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)) { diff --git a/lib/public/Dashboard/IAPIWidget.php b/lib/public/Dashboard/IAPIWidget.php index 8fec40cf1b1..c8f98290a0e 100644 --- a/lib/public/Dashboard/IAPIWidget.php +++ b/lib/public/Dashboard/IAPIWidget.php @@ -9,6 +9,8 @@ declare(strict_types=1); namespace OCP\Dashboard; +use OCP\Dashboard\Model\WidgetItem; + /** * interface IAPIWidget * @@ -16,7 +18,7 @@ namespace OCP\Dashboard; */ 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; diff --git a/lib/public/Dashboard/IButtonWidget.php b/lib/public/Dashboard/IButtonWidget.php index fa8d6bc36a6..f4ebd9253c7 100644 --- a/lib/public/Dashboard/IButtonWidget.php +++ b/lib/public/Dashboard/IButtonWidget.php @@ -19,7 +19,7 @@ interface IButtonWidget extends IWidget { * 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; diff --git a/lib/public/Dashboard/Model/WidgetItem.php b/lib/public/Dashboard/Model/WidgetItem.php index be5fba82323..680daf1b114 100644 --- a/lib/public/Dashboard/Model/WidgetItem.php +++ b/lib/public/Dashboard/Model/WidgetItem.php @@ -134,8 +134,14 @@ final class WidgetItem implements JsonSerializable { /** * @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 [ diff --git a/lib/public/Files/Template/Field.php b/lib/public/Files/Template/Field.php index ec195ca3504..e047e83a29e 100644 --- a/lib/public/Files/Template/Field.php +++ b/lib/public/Files/Template/Field.php @@ -32,6 +32,15 @@ abstract class Field implements \JsonSerializable { 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 { diff --git a/lib/public/Files/Template/Fields/CheckBoxField.php b/lib/public/Files/Template/Fields/CheckBoxField.php index 48ccb04336a..6fab3ce66a6 100644 --- a/lib/public/Files/Template/Fields/CheckBoxField.php +++ b/lib/public/Files/Template/Fields/CheckBoxField.php @@ -37,6 +37,15 @@ class CheckBoxField extends Field { } /** + * @return array{ + * index: string, + * type: string, + * alias: ?string, + * tag: ?string, + * id: ?int, + * content?: string, + * checked?: bool, + * } * @since 30.0.0 */ public function jsonSerialize(): array { diff --git a/lib/public/Files/Template/Fields/RichTextField.php b/lib/public/Files/Template/Fields/RichTextField.php index 14539bc9dbd..93ead68747c 100644 --- a/lib/public/Files/Template/Fields/RichTextField.php +++ b/lib/public/Files/Template/Fields/RichTextField.php @@ -37,6 +37,15 @@ class RichTextField extends Field { } /** + * @return array{ + * index: string, + * type: string, + * alias: ?string, + * tag: ?string, + * id: ?int, + * content?: string, + * checked?: bool, + * } * @since 30.0.0 */ public function jsonSerialize(): array { diff --git a/lib/public/Files/Template/ITemplateManager.php b/lib/public/Files/Template/ITemplateManager.php index 94e0db935e7..9a81aa51ceb 100644 --- a/lib/public/Files/Template/ITemplateManager.php +++ b/lib/public/Files/Template/ITemplateManager.php @@ -33,7 +33,7 @@ interface ITemplateManager { /** * 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; diff --git a/lib/public/Files/Template/Template.php b/lib/public/Files/Template/Template.php index 634935d212e..7f01c2afa48 100644 --- a/lib/public/Files/Template/Template.php +++ b/lib/public/Files/Template/Template.php @@ -24,7 +24,7 @@ final class Template implements \JsonSerializable { private $hasPreview = false; /** @var string|null */ private $previewUrl = null; - /** @var array */ + /** @var list<Field> */ private $fields = []; /** @@ -51,6 +51,7 @@ final class Template implements \JsonSerializable { } /** + * @param list<Field> $fields * @since 30.0.0 */ public function setFields(array $fields): void { @@ -58,6 +59,29 @@ final class Template implements \JsonSerializable { } /** + * @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 { @@ -74,7 +98,7 @@ final class Template implements \JsonSerializable { 'type' => $this->file->getType(), 'hasPreview' => $this->hasPreview, 'previewUrl' => $this->previewUrl, - 'fields' => $this->fields + 'fields' => array_map(static fn (Field $field) => $field->jsonSerialize(), $this->fields), ]; } } diff --git a/lib/public/Files/Template/TemplateFileCreator.php b/lib/public/Files/Template/TemplateFileCreator.php index 9a4bd2fae43..809bd3d0bc2 100644 --- a/lib/public/Files/Template/TemplateFileCreator.php +++ b/lib/public/Files/Template/TemplateFileCreator.php @@ -13,7 +13,7 @@ namespace OCP\Files\Template; */ final class TemplateFileCreator implements \JsonSerializable { protected $appId; - /** @var string[] $mimetypes */ + /** @var list<string> $mimetypes */ protected $mimetypes = []; protected $actionName; protected $fileExtension; @@ -121,7 +121,7 @@ final class TemplateFileCreator implements \JsonSerializable { /** * @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 [ diff --git a/lib/public/GroupInterface.php b/lib/public/GroupInterface.php index a6c01fa1d11..cbfd74a068a 100644 --- a/lib/public/GroupInterface.php +++ b/lib/public/GroupInterface.php @@ -86,7 +86,7 @@ interface GroupInterface { /** * 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 diff --git a/lib/public/IAppConfig.php b/lib/public/IAppConfig.php index 49f51467308..fe894da8d31 100644 --- a/lib/public/IAppConfig.php +++ b/lib/public/IAppConfig.php @@ -50,7 +50,7 @@ interface IAppConfig { * * **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; @@ -63,7 +63,7 @@ interface IAppConfig { * * @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; diff --git a/lib/public/ITags.php b/lib/public/ITags.php index 0da4522c86c..633cec72085 100644 --- a/lib/public/ITags.php +++ b/lib/public/ITags.php @@ -76,9 +76,9 @@ interface ITags { * ] * ``` * - * @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); diff --git a/lib/public/OCM/IOCMProvider.php b/lib/public/OCM/IOCMProvider.php index 58b50aca172..ba2ab6ce759 100644 --- a/lib/public/OCM/IOCMProvider.php +++ b/lib/public/OCM/IOCMProvider.php @@ -136,11 +136,11 @@ interface IOCMProvider extends JsonSerializable { * 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 */ diff --git a/lib/public/OCM/IOCMResource.php b/lib/public/OCM/IOCMResource.php index 788b5563cfc..60bf701e8ea 100644 --- a/lib/public/OCM/IOCMResource.php +++ b/lib/public/OCM/IOCMResource.php @@ -39,7 +39,7 @@ interface IOCMResource extends JsonSerializable { /** * set share types * - * @param string[] $shareTypes + * @param list<string> $shareTypes * * @return $this * @since 28.0.0 @@ -49,7 +49,7 @@ interface IOCMResource extends JsonSerializable { /** * get share types * - * @return string[] + * @return list<string> * @since 28.0.0 */ public function getShareTypes(): array; @@ -85,7 +85,7 @@ interface IOCMResource extends JsonSerializable { /** * @return array{ * name: string, - * shareTypes: string[], + * shareTypes: list<string>, * protocols: array<string, string> * } * @since 28.0.0 diff --git a/lib/public/TaskProcessing/IManager.php b/lib/public/TaskProcessing/IManager.php index 2d5fe1d9ba6..1b59bb12ad4 100644 --- a/lib/public/TaskProcessing/IManager.php +++ b/lib/public/TaskProcessing/IManager.php @@ -46,7 +46,7 @@ interface IManager { 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; diff --git a/lib/public/TaskProcessing/Task.php b/lib/public/TaskProcessing/Task.php index db8e4d7fab5..71c271cd43d 100644 --- a/lib/public/TaskProcessing/Task.php +++ b/lib/public/TaskProcessing/Task.php @@ -253,12 +253,12 @@ final class Task implements \JsonSerializable { } /** - * @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()), diff --git a/lib/public/Teams/ITeamManager.php b/lib/public/Teams/ITeamManager.php index 5c4c63b4f23..144a141f93e 100644 --- a/lib/public/Teams/ITeamManager.php +++ b/lib/public/Teams/ITeamManager.php @@ -28,7 +28,7 @@ interface ITeamManager { /** * 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; |