From 4dbe0677ad25d9ccbc4efcdc67c0e5b3d736d70f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 12 Oct 2023 12:24:03 +0200 Subject: fix(OCM): Make the public API only rely on OCP Signed-off-by: Joas Schilling --- lib/private/OCM/Model/OCMProvider.php | 34 +++++++++++++++++----------------- lib/private/OCM/Model/OCMResource.php | 18 ++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) (limited to 'lib/private/OCM') diff --git a/lib/private/OCM/Model/OCMProvider.php b/lib/private/OCM/Model/OCMProvider.php index 44f4fbebc10..1a8d943f79f 100644 --- a/lib/private/OCM/Model/OCMProvider.php +++ b/lib/private/OCM/Model/OCMProvider.php @@ -26,27 +26,27 @@ declare(strict_types=1); namespace OC\OCM\Model; -use JsonSerializable; use OCP\OCM\Exceptions\OCMArgumentException; use OCP\OCM\Exceptions\OCMProviderException; use OCP\OCM\IOCMProvider; +use OCP\OCM\IOCMResource; /** * @since 28.0.0 */ -class OCMProvider implements IOCMProvider, JsonSerializable { +class OCMProvider implements IOCMProvider { private bool $enabled = false; private string $apiVersion = ''; private string $endPoint = ''; - /** @var OCMResource[] */ + /** @var IOCMResource[] */ private array $resourceTypes = []; /** * @param bool $enabled * - * @return OCMProvider + * @return $this */ - public function setEnabled(bool $enabled): self { + public function setEnabled(bool $enabled): static { $this->enabled = $enabled; return $this; @@ -62,9 +62,9 @@ class OCMProvider implements IOCMProvider, JsonSerializable { /** * @param string $apiVersion * - * @return OCMProvider + * @return $this */ - public function setApiVersion(string $apiVersion): self { + public function setApiVersion(string $apiVersion): static { $this->apiVersion = $apiVersion; return $this; @@ -80,9 +80,9 @@ class OCMProvider implements IOCMProvider, JsonSerializable { /** * @param string $endPoint * - * @return OCMProvider + * @return $this */ - public function setEndPoint(string $endPoint): self { + public function setEndPoint(string $endPoint): static { $this->endPoint = $endPoint; return $this; @@ -96,29 +96,29 @@ class OCMProvider implements IOCMProvider, JsonSerializable { } /** - * @param OCMResource $resource + * @param IOCMResource $resource * * @return $this */ - public function addResourceType(OCMResource $resource): self { + public function addResourceType(IOCMResource $resource): static { $this->resourceTypes[] = $resource; return $this; } /** - * @param OCMResource[] $resourceTypes + * @param IOCMResource[] $resourceTypes * - * @return OCMProvider + * @return $this */ - public function setResourceTypes(array $resourceTypes): self { + public function setResourceTypes(array $resourceTypes): static { $this->resourceTypes = $resourceTypes; return $this; } /** - * @return OCMResource[] + * @return IOCMResource[] */ public function getResourceTypes(): array { return $this->resourceTypes; @@ -151,11 +151,11 @@ class OCMProvider implements IOCMProvider, JsonSerializable { * * @param array $data * - * @return self + * @return $this * @throws OCMProviderException in case a descent provider cannot be generated from data * @see self::jsonSerialize() */ - public function import(array $data): self { + public function import(array $data): static { $this->setEnabled(is_bool($data['enabled'] ?? '') ? $data['enabled'] : false) ->setApiVersion((string)($data['apiVersion'] ?? '')) ->setEndPoint($data['endPoint'] ?? ''); diff --git a/lib/private/OCM/Model/OCMResource.php b/lib/private/OCM/Model/OCMResource.php index 12948aa8949..c4a91f2eabf 100644 --- a/lib/private/OCM/Model/OCMResource.php +++ b/lib/private/OCM/Model/OCMResource.php @@ -26,13 +26,12 @@ declare(strict_types=1); namespace OC\OCM\Model; -use JsonSerializable; use OCP\OCM\IOCMResource; /** * @since 28.0.0 */ -class OCMResource implements IOCMResource, JsonSerializable { +class OCMResource implements IOCMResource { private string $name = ''; /** @var string[] */ private array $shareTypes = []; @@ -42,9 +41,9 @@ class OCMResource implements IOCMResource, JsonSerializable { /** * @param string $name * - * @return OCMResource + * @return $this */ - public function setName(string $name): self { + public function setName(string $name): static { $this->name = $name; return $this; @@ -60,9 +59,9 @@ class OCMResource implements IOCMResource, JsonSerializable { /** * @param string[] $shareTypes * - * @return OCMResource + * @return $this */ - public function setShareTypes(array $shareTypes): self { + public function setShareTypes(array $shareTypes): static { $this->shareTypes = $shareTypes; return $this; @@ -80,7 +79,7 @@ class OCMResource implements IOCMResource, JsonSerializable { * * @return $this */ - public function setProtocols(array $protocols): self { + public function setProtocols(array $protocols): static { $this->protocols = $protocols; return $this; @@ -98,17 +97,16 @@ class OCMResource implements IOCMResource, JsonSerializable { * * @param array $data * - * @return self + * @return $this * @see self::jsonSerialize() */ - public function import(array $data): self { + public function import(array $data): static { return $this->setName((string)($data['name'] ?? '')) ->setShareTypes($data['shareTypes'] ?? []) ->setProtocols($data['protocols'] ?? []); } /** - * * @return array{ * name: string, * shareTypes: string[], -- cgit v1.2.3