소스 검색

Make SystemTag strict

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Roeland Jago Douma 6 년 전
부모
커밋
8e5657014d

+ 3 - 2
lib/private/SystemTag/ManagerFactory.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *
@@ -57,7 +58,7 @@ class ManagerFactory implements ISystemTagManagerFactory {
 	 * @return ISystemTagManager
 	 * @since 9.0.0
 	 */
-	public function getManager() {
+	public function getManager(): ISystemTagManager {
 		return new SystemTagManager(
 			$this->serverContainer->getDatabaseConnection(),
 			$this->serverContainer->getGroupManager(),
@@ -72,7 +73,7 @@ class ManagerFactory implements ISystemTagManagerFactory {
 	 * @return ISystemTagObjectMapper
 	 * @since 9.0.0
 	 */
-	public function getObjectMapper() {
+	public function getObjectMapper(): ISystemTagObjectMapper {
 		return new SystemTagObjectMapper(
 			$this->serverContainer->getDatabaseConnection(),
 			$this->getManager(),

+ 6 - 5
lib/private/SystemTag/SystemTag.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *
@@ -55,7 +56,7 @@ class SystemTag implements ISystemTag {
 	 * @param bool $userVisible whether the tag is user visible
 	 * @param bool $userAssignable whether the tag is user assignable
 	 */
-	public function __construct($id, $name, $userVisible, $userAssignable) {
+	public function __construct(string $id, string $name, bool $userVisible, bool $userAssignable) {
 		$this->id = $id;
 		$this->name = $name;
 		$this->userVisible = $userVisible;
@@ -65,28 +66,28 @@ class SystemTag implements ISystemTag {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function getId() {
+	public function getId(): string {
 		return $this->id;
 	}
 
 	/**
 	 * {@inheritdoc}
 	 */
-	public function getName() {
+	public function getName(): string {
 		return $this->name;
 	}
 
 	/**
 	 * {@inheritdoc}
 	 */
-	public function isUserVisible() {
+	public function isUserVisible(): bool {
 		return $this->userVisible;
 	}
 
 	/**
 	 * {@inheritdoc}
 	 */
-	public function isUserAssignable() {
+	public function isUserAssignable(): bool {
 		return $this->userAssignable;
 	}
 }

+ 28 - 35
lib/private/SystemTag/SystemTagManager.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *
@@ -65,6 +66,7 @@ class SystemTagManager implements ISystemTagManager {
 	 * Constructor.
 	 *
 	 * @param IDBConnection $connection database connection
+	 * @param IGroupManager $groupManager
 	 * @param EventDispatcherInterface $dispatcher
 	 */
 	public function __construct(
@@ -87,8 +89,8 @@ class SystemTagManager implements ISystemTagManager {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function getTagsByIds($tagIds) {
-		if (!is_array($tagIds)) {
+	public function getTagsByIds($tagIds): array {
+		if (!\is_array($tagIds)) {
 			$tagIds = [$tagIds];
 		}
 
@@ -117,7 +119,7 @@ class SystemTagManager implements ISystemTagManager {
 
 		$result->closeCursor();
 
-		if (count($tags) !== count($tagIds)) {
+		if (\count($tags) !== \count($tagIds)) {
 			throw new TagNotFoundException(
 				'Tag id(s) not found', 0, null, array_diff($tagIds, array_keys($tags))
 			);
@@ -129,14 +131,14 @@ class SystemTagManager implements ISystemTagManager {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function getAllTags($visibilityFilter = null, $nameSearchPattern = null) {
+	public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array {
 		$tags = [];
 
 		$query = $this->connection->getQueryBuilder();
 		$query->select('*')
 			->from(self::TAG_TABLE);
 
-		if (!is_null($visibilityFilter)) {
+		if (!\is_null($visibilityFilter)) {
 			$query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int)$visibilityFilter)));
 		}
 
@@ -167,14 +169,11 @@ class SystemTagManager implements ISystemTagManager {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function getTag($tagName, $userVisible, $userAssignable) {
-		$userVisible = (int)$userVisible;
-		$userAssignable = (int)$userAssignable;
-
+	public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
 		$result = $this->selectTagQuery
 			->setParameter('name', $tagName)
-			->setParameter('visibility', $userVisible)
-			->setParameter('editable', $userAssignable)
+			->setParameter('visibility', $userVisible ? 1 : 0)
+			->setParameter('editable', $userAssignable ? 1 : 0)
 			->execute();
 
 		$row = $result->fetch();
@@ -191,16 +190,13 @@ class SystemTagManager implements ISystemTagManager {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function createTag($tagName, $userVisible, $userAssignable) {
-		$userVisible = (int)$userVisible;
-		$userAssignable = (int)$userAssignable;
-
+	public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
 		$query = $this->connection->getQueryBuilder();
 		$query->insert(self::TAG_TABLE)
 			->values([
 				'name' => $query->createNamedParameter($tagName),
-				'visibility' => $query->createNamedParameter($userVisible),
-				'editable' => $query->createNamedParameter($userAssignable),
+				'visibility' => $query->createNamedParameter($userVisible ? 1 : 0),
+				'editable' => $query->createNamedParameter($userAssignable ? 1 : 0),
 			]);
 
 		try {
@@ -216,10 +212,10 @@ class SystemTagManager implements ISystemTagManager {
 		$tagId = $query->getLastInsertId();
 
 		$tag = new SystemTag(
-			(int)$tagId,
+			(string)$tagId,
 			$tagName,
-			(bool)$userVisible,
-			(bool)$userAssignable
+			$userVisible,
+			$userAssignable
 		);
 
 		$this->dispatcher->dispatch(ManagerEvent::EVENT_CREATE, new ManagerEvent(
@@ -232,10 +228,7 @@ class SystemTagManager implements ISystemTagManager {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function updateTag($tagId, $tagName, $userVisible, $userAssignable) {
-		$userVisible = (int)$userVisible;
-		$userAssignable = (int)$userAssignable;
-
+	public function updateTag(string $tagId, string $tagName, bool $userVisible, bool $userAssignable) {
 		try {
 			$tags = $this->getTagsByIds($tagId);
 		} catch (TagNotFoundException $e) {
@@ -246,10 +239,10 @@ class SystemTagManager implements ISystemTagManager {
 
 		$beforeUpdate = array_shift($tags);
 		$afterUpdate = new SystemTag(
-			(int) $tagId,
+			$tagId,
 			$tagName,
-			(bool) $userVisible,
-			(bool) $userAssignable
+			$userVisible,
+			$userAssignable
 		);
 
 		$query = $this->connection->getQueryBuilder();
@@ -259,8 +252,8 @@ class SystemTagManager implements ISystemTagManager {
 			->set('editable', $query->createParameter('editable'))
 			->where($query->expr()->eq('id', $query->createParameter('tagid')))
 			->setParameter('name', $tagName)
-			->setParameter('visibility', $userVisible)
-			->setParameter('editable', $userAssignable)
+			->setParameter('visibility', $userVisible ? 1 : 0)
+			->setParameter('editable', $userAssignable ? 1 : 0)
 			->setParameter('tagid', $tagId);
 
 		try {
@@ -286,7 +279,7 @@ class SystemTagManager implements ISystemTagManager {
 	 * {@inheritdoc}
 	 */
 	public function deleteTags($tagIds) {
-		if (!is_array($tagIds)) {
+		if (!\is_array($tagIds)) {
 			$tagIds = [$tagIds];
 		}
 
@@ -337,7 +330,7 @@ class SystemTagManager implements ISystemTagManager {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function canUserAssignTag(ISystemTag $tag, IUser $user) {
+	public function canUserAssignTag(ISystemTag $tag, IUser $user): bool {
 		// early check to avoid unneeded group lookups
 		if ($tag->isUserAssignable() && $tag->isUserVisible()) {
 			return true;
@@ -365,7 +358,7 @@ class SystemTagManager implements ISystemTagManager {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function canUserSeeTag(ISystemTag $tag, IUser $user) {
+	public function canUserSeeTag(ISystemTag $tag, IUser $user): bool {
 		if ($tag->isUserVisible()) {
 			return true;
 		}
@@ -378,13 +371,13 @@ class SystemTagManager implements ISystemTagManager {
 	}
 
 	private function createSystemTagFromRow($row) {
-		return new SystemTag((int)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable']);
+		return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable']);
 	}
 
 	/**
 	 * {@inheritdoc}
 	 */
-	public function setTagGroups(ISystemTag $tag, $groupIds) {
+	public function setTagGroups(ISystemTag $tag, array $groupIds) {
 		// delete relationships first
 		$this->connection->beginTransaction();
 		try {
@@ -418,7 +411,7 @@ class SystemTagManager implements ISystemTagManager {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function getTagGroups(ISystemTag $tag) {
+	public function getTagGroups(ISystemTag $tag): array {
 		$groupIds = [];
 		$query = $this->connection->getQueryBuilder();
 		$query->select('gid')

+ 16 - 15
lib/private/SystemTag/SystemTagObjectMapper.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *
@@ -63,8 +64,8 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function getTagIdsForObjects($objIds, $objectType) {
-		if (!is_array($objIds)) {
+	public function getTagIdsForObjects($objIds, string $objectType): array {
+		if (!\is_array($objIds)) {
 			$objIds = [$objIds];
 		} else if (empty($objIds)) {
 			return [];
@@ -99,8 +100,8 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = '') {
-		if (!is_array($tagIds)) {
+	public function getObjectIdsForTags($tagIds, string $objectType, int $limit = 0, string $offset = ''): array {
+		if (!\is_array($tagIds)) {
 			$tagIds = [$tagIds];
 		}
 
@@ -113,7 +114,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
 			->andWhere($query->expr()->eq('objecttype', $query->createNamedParameter($objectType)));
 
 		if ($limit) {
-			if (count($tagIds) !== 1) {
+			if (\count($tagIds) !== 1) {
 				throw new \InvalidArgumentException('Limit is only allowed with a single tag');
 			}
 
@@ -138,8 +139,8 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function assignTags($objId, $objectType, $tagIds) {
-		if (!is_array($tagIds)) {
+	public function assignTags(string $objId, string $objectType, $tagIds) {
+		if (!\is_array($tagIds)) {
 			$tagIds = [$tagIds];
 		}
 
@@ -173,8 +174,8 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function unassignTags($objId, $objectType, $tagIds) {
-		if (!is_array($tagIds)) {
+	public function unassignTags(string $objId, string $objectType, $tagIds) {
+		if (!\is_array($tagIds)) {
 			$tagIds = [$tagIds];
 		}
 
@@ -201,10 +202,10 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
 	/**
 	 * {@inheritdoc}
 	 */
-	public function haveTag($objIds, $objectType, $tagId, $all = true) {
+	public function haveTag($objIds, string $objectType, string $tagId, bool $all = true): bool {
 		$this->assertTagsExist([$tagId]);
 
-		if (!is_array($objIds)) {
+		if (!\is_array($objIds)) {
 			$objIds = [$objIds];
 		}
 
@@ -232,10 +233,10 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
 		$result->closeCursor();
 
 		if ($all) {
-			return ((int)$row[0] === count($objIds));
-		} else {
-			return (bool) $row;
+			return ((int)$row[0] === \count($objIds));
 		}
+
+		return (bool) $row;
 	}
 
 	/**
@@ -247,7 +248,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
 	 */
 	private function assertTagsExist($tagIds) {
 		$tags = $this->tagManager->getTagsByIds($tagIds);
-		if (count($tags) !== count($tagIds)) {
+		if (\count($tags) !== \count($tagIds)) {
 			// at least one tag missing, bail out
 			$foundTagIds = array_map(
 				function(ISystemTag $tag) {

+ 5 - 4
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;
 
 }
 

+ 20 - 19
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;
 }

+ 3 - 2
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;
 }

+ 10 - 9
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;
 
 }

+ 6 - 4
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');
 		}

+ 6 - 5
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;
 	}
 }

+ 4 - 3
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;
 	}
 }

+ 1 - 0
lib/public/SystemTag/TagAlreadyExistsException.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 /**
  * @copyright Copyright (c) 2016, ownCloud, Inc.
  *

+ 3 - 2
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;
 	}
 }