diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-21 23:56:00 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-02-22 00:08:27 +0300 |
commit | 8e5657014dc77eb2978c9b1c0aac505b7f30eaed (patch) | |
tree | 364f590458b1cd0fecffc461f1d1a964ec6cd5f5 /lib/public/SystemTag | |
parent | f01754a389cf30cbebd391f812e46548dc062cc2 (diff) |
Make SystemTag strict
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/public/SystemTag')
-rw-r--r-- | lib/public/SystemTag/ISystemTag.php | 9 | ||||
-rw-r--r-- | lib/public/SystemTag/ISystemTagManager.php | 39 | ||||
-rw-r--r-- | lib/public/SystemTag/ISystemTagManagerFactory.php | 5 | ||||
-rw-r--r-- | lib/public/SystemTag/ISystemTagObjectMapper.php | 19 | ||||
-rw-r--r-- | lib/public/SystemTag/ManagerEvent.php | 10 | ||||
-rw-r--r-- | lib/public/SystemTag/MapperEvent.php | 11 | ||||
-rw-r--r-- | lib/public/SystemTag/SystemTagsEntityEvent.php | 7 | ||||
-rw-r--r-- | lib/public/SystemTag/TagAlreadyExistsException.php | 1 | ||||
-rw-r--r-- | lib/public/SystemTag/TagNotFoundException.php | 5 |
9 files changed, 58 insertions, 48 deletions
diff --git a/lib/public/SystemTag/ISystemTag.php b/lib/public/SystemTag/ISystemTag.php index 539c7835fae..da434e8b5a0 100644 --- a/lib/public/SystemTag/ISystemTag.php +++ b/lib/public/SystemTag/ISystemTag.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -36,7 +37,7 @@ interface ISystemTag { * * @since 9.0.0 */ - public function getId(); + public function getId(): string; /** * Returns the tag display name @@ -45,7 +46,7 @@ interface ISystemTag { * * @since 9.0.0 */ - public function getName(); + public function getName(): string; /** * Returns whether the tag is visible for regular users @@ -54,7 +55,7 @@ interface ISystemTag { * * @since 9.0.0 */ - public function isUserVisible(); + public function isUserVisible(): bool; /** * Returns whether the tag can be assigned to objects by regular users @@ -63,7 +64,7 @@ interface ISystemTag { * * @since 9.0.0 */ - public function isUserAssignable(); + public function isUserAssignable(): bool; } diff --git a/lib/public/SystemTag/ISystemTagManager.php b/lib/public/SystemTag/ISystemTagManager.php index fff0a439116..4cce106790a 100644 --- a/lib/public/SystemTag/ISystemTagManager.php +++ b/lib/public/SystemTag/ISystemTagManager.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -37,15 +38,15 @@ interface ISystemTagManager { * * @param array|string $tagIds id or array of unique ids of the tag to retrieve * - * @return \OCP\SystemTag\ISystemTag[] array of system tags with tag id as key + * @return ISystemTag[] array of system tags with tag id as key * * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.) - * @throws \OCP\SystemTag\TagNotFoundException if at least one given tag ids did no exist + * @throws TagNotFoundException if at least one given tag ids did no exist * The message contains a json_encoded array of the ids that could not be found * * @since 9.0.0 */ - public function getTagsByIds($tagIds); + public function getTagsByIds($tagIds): array; /** * Returns the tag object matching the given attributes. @@ -54,13 +55,13 @@ interface ISystemTagManager { * @param bool $userVisible whether the tag is visible by users * @param bool $userAssignable whether the tag is assignable by users * - * @return \OCP\SystemTag\ISystemTag system tag + * @return ISystemTag system tag * - * @throws \OCP\SystemTag\TagNotFoundException if tag does not exist + * @throws TagNotFoundException if tag does not exist * * @since 9.0.0 */ - public function getTag($tagName, $userVisible, $userAssignable); + public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag; /** * Creates the tag object using the given attributes. @@ -69,13 +70,13 @@ interface ISystemTagManager { * @param bool $userVisible whether the tag is visible by users * @param bool $userAssignable whether the tag is assignable by users * - * @return \OCP\SystemTag\ISystemTag system tag + * @return ISystemTag system tag * - * @throws \OCP\SystemTag\TagAlreadyExistsException if tag already exists + * @throws TagAlreadyExistsException if tag already exists * * @since 9.0.0 */ - public function createTag($tagName, $userVisible, $userAssignable); + public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag; /** * Returns all known tags, optionally filtered by visibility. @@ -83,11 +84,11 @@ interface ISystemTagManager { * @param bool|null $visibilityFilter filter by visibility if non-null * @param string $nameSearchPattern optional search pattern for the tag name * - * @return \OCP\SystemTag\ISystemTag[] array of system tags or empty array if none found + * @return ISystemTag[] array of system tags or empty array if none found * * @since 9.0.0 */ - public function getAllTags($visibilityFilter = null, $nameSearchPattern = null); + public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array; /** * Updates the given tag @@ -97,20 +98,20 @@ interface ISystemTagManager { * @param bool $userVisible whether the tag is visible by users * @param bool $userAssignable whether the tag is assignable by users * - * @throws \OCP\SystemTag\TagNotFoundException if tag with the given id does not exist - * @throws \OCP\SystemTag\TagAlreadyExistsException if there is already another tag + * @throws TagNotFoundException if tag with the given id does not exist + * @throws TagAlreadyExistsException if there is already another tag * with the same attributes * * @since 9.0.0 */ - public function updateTag($tagId, $newName, $userVisible, $userAssignable); + public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable); /** * Delete the given tags from the database and all their relationships. * * @param string|array $tagIds array of tag ids * - * @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist + * @throws TagNotFoundException if at least one tag did not exist * * @since 9.0.0 */ @@ -127,7 +128,7 @@ interface ISystemTagManager { * * @since 9.1.0 */ - public function canUserAssignTag(ISystemTag $tag, IUser $user); + public function canUserAssignTag(ISystemTag $tag, IUser $user): bool; /** * Checks whether the given user is allowed to see the tag with the given id. @@ -139,7 +140,7 @@ interface ISystemTagManager { * * @since 9.1.0 */ - public function canUserSeeTag(ISystemTag $tag, IUser $userId); + public function canUserSeeTag(ISystemTag $tag, IUser $user): bool; /** * Set groups that can assign a given tag. @@ -149,7 +150,7 @@ interface ISystemTagManager { * * @since 9.1.0 */ - public function setTagGroups(ISystemTag $tag, $groupIds); + public function setTagGroups(ISystemTag $tag, array $groupIds); /** * Get groups that can assign a given tag. @@ -160,5 +161,5 @@ interface ISystemTagManager { * * @since 9.1.0 */ - public function getTagGroups(ISystemTag $tag); + public function getTagGroups(ISystemTag $tag): array; } diff --git a/lib/public/SystemTag/ISystemTagManagerFactory.php b/lib/public/SystemTag/ISystemTagManagerFactory.php index 0d652697490..25956b41df4 100644 --- a/lib/public/SystemTag/ISystemTagManagerFactory.php +++ b/lib/public/SystemTag/ISystemTagManagerFactory.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -47,7 +48,7 @@ interface ISystemTagManagerFactory { * @return ISystemTagManager * @since 9.0.0 */ - public function getManager(); + public function getManager(): ISystemTagManager; /** * creates and returns an instance of the system tag object @@ -56,5 +57,5 @@ interface ISystemTagManagerFactory { * @return ISystemTagObjectMapper * @since 9.0.0 */ - public function getObjectMapper(); + public function getObjectMapper(): ISystemTagObjectMapper; } diff --git a/lib/public/SystemTag/ISystemTagObjectMapper.php b/lib/public/SystemTag/ISystemTagObjectMapper.php index 3e28ab15773..1705bde23c5 100644 --- a/lib/public/SystemTag/ISystemTagObjectMapper.php +++ b/lib/public/SystemTag/ISystemTagObjectMapper.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -51,7 +52,7 @@ interface ISystemTagObjectMapper { * * @since 9.0.0 */ - public function getTagIdsForObjects($objIds, $objectType); + public function getTagIdsForObjects($objIds, string $objectType): array; /** * Get a list of objects tagged with $tagIds. @@ -63,14 +64,14 @@ interface ISystemTagObjectMapper { * * @return string[] array of object ids or empty array if none found * - * @throws \OCP\SystemTag\TagNotFoundException if at least one of the + * @throws TagNotFoundException if at least one of the * given tags does not exist * @throws \InvalidArgumentException When a limit is specified together with * multiple tag ids * * @since 9.0.0 */ - public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = ''); + public function getObjectIdsForTags($tagIds, string $objectType, int $limit = 0, string $offset = ''): array; /** * Assign the given tags to the given object. @@ -84,12 +85,12 @@ interface ISystemTagObjectMapper { * @param string $objectType object type * @param string|array $tagIds tag id or array of tag ids to assign * - * @throws \OCP\SystemTag\TagNotFoundException if at least one of the + * @throws TagNotFoundException if at least one of the * given tags does not exist * * @since 9.0.0 */ - public function assignTags($objId, $objectType, $tagIds); + public function assignTags(string $objId, string $objectType, $tagIds); /** * Unassign the given tags from the given object. @@ -103,12 +104,12 @@ interface ISystemTagObjectMapper { * @param string $objectType object type * @param string|array $tagIds tag id or array of tag ids to unassign * - * @throws \OCP\SystemTag\TagNotFoundException if at least one of the + * @throws TagNotFoundException if at least one of the * given tags does not exist * * @since 9.0.0 */ - public function unassignTags($objId, $objectType, $tagIds); + public function unassignTags(string $objId, string $objectType, $tagIds); /** * Checks whether the given objects have the given tag. @@ -122,10 +123,10 @@ interface ISystemTagObjectMapper { * @return bool true if the condition set by $all is matched, false * otherwise * - * @throws \OCP\SystemTag\TagNotFoundException if the tag does not exist + * @throws TagNotFoundException if the tag does not exist * * @since 9.0.0 */ - public function haveTag($objIds, $objectType, $tagId, $all = true); + public function haveTag($objIds, string $objectType, string $tagId, bool $all = true): bool; } diff --git a/lib/public/SystemTag/ManagerEvent.php b/lib/public/SystemTag/ManagerEvent.php index bb9fcc01f83..452c0d5da8f 100644 --- a/lib/public/SystemTag/ManagerEvent.php +++ b/lib/public/SystemTag/ManagerEvent.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -52,7 +53,7 @@ class ManagerEvent extends Event { * @param ISystemTag|null $beforeTag * @since 9.0.0 */ - public function __construct($event, ISystemTag $tag, ISystemTag $beforeTag = null) { + public function __construct(string $event, ISystemTag $tag, ISystemTag $beforeTag = null) { $this->event = $event; $this->tag = $tag; $this->beforeTag = $beforeTag; @@ -62,7 +63,7 @@ class ManagerEvent extends Event { * @return string * @since 9.0.0 */ - public function getEvent() { + public function getEvent(): string { return $this->event; } @@ -70,15 +71,16 @@ class ManagerEvent extends Event { * @return ISystemTag * @since 9.0.0 */ - public function getTag() { + public function getTag(): ISystemTag { return $this->tag; } /** * @return ISystemTag * @since 9.0.0 + * @throws \BadMethodCallException */ - public function getTagBefore() { + public function getTagBefore(): ISystemTag { if ($this->event !== self::EVENT_UPDATE) { throw new \BadMethodCallException('getTagBefore is only available on the update Event'); } diff --git a/lib/public/SystemTag/MapperEvent.php b/lib/public/SystemTag/MapperEvent.php index a86497c8440..d98caf1317b 100644 --- a/lib/public/SystemTag/MapperEvent.php +++ b/lib/public/SystemTag/MapperEvent.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -53,7 +54,7 @@ class MapperEvent extends Event { * @param int[] $tags * @since 9.0.0 */ - public function __construct($event, $objectType, $objectId, array $tags) { + public function __construct(string $event, string $objectType, string $objectId, array $tags) { $this->event = $event; $this->objectType = $objectType; $this->objectId = $objectId; @@ -64,7 +65,7 @@ class MapperEvent extends Event { * @return string * @since 9.0.0 */ - public function getEvent() { + public function getEvent(): string { return $this->event; } @@ -72,7 +73,7 @@ class MapperEvent extends Event { * @return string * @since 9.0.0 */ - public function getObjectType() { + public function getObjectType(): string { return $this->objectType; } @@ -80,7 +81,7 @@ class MapperEvent extends Event { * @return string * @since 9.0.0 */ - public function getObjectId() { + public function getObjectId(): string { return $this->objectId; } @@ -88,7 +89,7 @@ class MapperEvent extends Event { * @return int[] * @since 9.0.0 */ - public function getTags() { + public function getTags(): array { return $this->tags; } } diff --git a/lib/public/SystemTag/SystemTagsEntityEvent.php b/lib/public/SystemTag/SystemTagsEntityEvent.php index 15ae4439986..e439c16d9c6 100644 --- a/lib/public/SystemTag/SystemTagsEntityEvent.php +++ b/lib/public/SystemTag/SystemTagsEntityEvent.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -45,7 +46,7 @@ class SystemTagsEntityEvent extends Event { * @param string $event * @since 9.1.0 */ - public function __construct($event) { + public function __construct(string $event) { $this->event = $event; $this->collections = []; } @@ -59,7 +60,7 @@ class SystemTagsEntityEvent extends Event { * @throws \OutOfBoundsException when the entity name is already taken * @since 9.1.0 */ - public function addEntityCollection($name, \Closure $entityExistsFunction) { + public function addEntityCollection(string $name, \Closure $entityExistsFunction) { if (isset($this->collections[$name])) { throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); } @@ -71,7 +72,7 @@ class SystemTagsEntityEvent extends Event { * @return \Closure[] * @since 9.1.0 */ - public function getEntityCollections() { + public function getEntityCollections(): array { return $this->collections; } } diff --git a/lib/public/SystemTag/TagAlreadyExistsException.php b/lib/public/SystemTag/TagAlreadyExistsException.php index caf0d9f08bc..fbe8234d281 100644 --- a/lib/public/SystemTag/TagAlreadyExistsException.php +++ b/lib/public/SystemTag/TagAlreadyExistsException.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * diff --git a/lib/public/SystemTag/TagNotFoundException.php b/lib/public/SystemTag/TagNotFoundException.php index 9b06259807f..9f83c20e6c5 100644 --- a/lib/public/SystemTag/TagNotFoundException.php +++ b/lib/public/SystemTag/TagNotFoundException.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -43,7 +44,7 @@ class TagNotFoundException extends \RuntimeException { * @param string[] $tags * @since 9.0.0 */ - public function __construct($message = '', $code = 0, \Exception $previous = null, array $tags = []) { + public function __construct(string $message = '', int $code = 0, \Exception $previous = null, array $tags = []) { parent::__construct($message, $code, $previous); $this->tags = $tags; } @@ -52,7 +53,7 @@ class TagNotFoundException extends \RuntimeException { * @return string[] * @since 9.0.0 */ - public function getMissingTags() { + public function getMissingTags(): array { return $this->tags; } } |