From 7d3f237927ede74948c570ea6f548d462dffbd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 1 Nov 2020 14:13:04 +0100 Subject: [PATCH] Use return type annotations in favor of PHPDoc --- files/lib/data/message/Message.class.php | 18 ++++++++--------- files/lib/data/room/Room.class.php | 25 +++++------------------- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/files/lib/data/message/Message.class.php b/files/lib/data/message/Message.class.php index 9361fde..de0aa11 100644 --- a/files/lib/data/message/Message.class.php +++ b/files/lib/data/message/Message.class.php @@ -14,6 +14,10 @@ namespace chat\data\message; +use \chat\data\room\Room; +use \wcf\data\object\type\ObjectType; +use \wcf\data\object\type\ObjectTypeCache; + /** * Represents a chat message. * @@ -42,28 +46,22 @@ protected function handleData($data) { /** * Returns whether this message already is inside the log. - * - * @return boolean */ - public function isInLog() { + public function isInLog(): bool { return $this->time < (TIME_NOW - CHAT_ARCHIVE_AFTER); } /** * Returns the message type object of this message. - * - * @return \wcf\data\object\type\ObjectType */ - public function getMessageType() { - return \wcf\data\object\type\ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID); + public function getMessageType(): ObjectType { + return ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID); } /** * Returns the chat room that contains this message. - * - * @return \chat\data\room\Room */ - public function getRoom() { + public function getRoom(): Room { return \chat\data\room\RoomCache::getInstance()->getRoom($this->roomID); } } diff --git a/files/lib/data/room/Room.class.php b/files/lib/data/room/Room.class.php index 58a3601..de36be7 100644 --- a/files/lib/data/room/Room.class.php +++ b/files/lib/data/room/Room.class.php @@ -52,11 +52,8 @@ public function __toString() { * Returns whether the given user can see at least * one chat room. If no user is given the current user * should be assumed - * - * @param \wcf\data\user\UserProfile $user - * @return boolean */ - public static function canSeeAny(\wcf\data\user\UserProfile $user = null) { + public static function canSeeAny(\wcf\data\user\UserProfile $user = null): bool { $rooms = RoomCache::getInstance()->getRooms(); foreach ($rooms as $room) { if ($room->canSee($user)) return true; @@ -68,11 +65,8 @@ public static function canSeeAny(\wcf\data\user\UserProfile $user = null) { /** * Returns whether the given user can see this room. * If no user is given the current user should be assumed. - * - * @param \wcf\data\user\UserProfile $user - * @return boolean */ - public function canSee(\wcf\data\user\UserProfile $user = null, \Exception &$reason = null) { + public function canSee(\wcf\data\user\UserProfile $user = null, \Exception &$reason = null): bool { static $cache = [ ]; if ($user === null) $user = new \wcf\data\user\UserProfile(WCF::getUser()); @@ -107,11 +101,8 @@ public function canSee(\wcf\data\user\UserProfile $user = null, \Exception &$rea /** * Returns whether the given user can see the log of this room. * If no user is given the current user should be assumed. - * - * @param \wcf\data\user\UserProfile $user - * @return boolean */ - public function canSeeLog(\wcf\data\user\UserProfile $user = null, \Exception &$reason = null) { + public function canSeeLog(\wcf\data\user\UserProfile $user = null, \Exception &$reason = null): bool { static $cache = [ ]; if ($user === null) $user = new \wcf\data\user\UserProfile(WCF::getUser()); @@ -141,11 +132,8 @@ public function canSeeLog(\wcf\data\user\UserProfile $user = null, \Exception &$ /** * Returns whether the given user can join this room. * If no user is given the current user should be assumed. - * - * @param \wcf\data\user\UserProfile $user - * @return boolean */ - public function canJoin(\wcf\data\user\UserProfile $user = null, \Exception &$reason = null) { + public function canJoin(\wcf\data\user\UserProfile $user = null, \Exception &$reason = null): bool { static $cache = [ ]; if ($user === null) $user = new \wcf\data\user\UserProfile(WCF::getUser()); @@ -170,11 +158,8 @@ public function canJoin(\wcf\data\user\UserProfile $user = null, \Exception &$re /** * Returns whether the given user can write public messages in this room. * If no user is given the current user should be assumed. - * - * @param \wcf\data\user\UserProfile $user - * @return boolean */ - public function canWritePublicly(\wcf\data\user\UserProfile $user = null, \Exception &$reason = null) { + public function canWritePublicly(\wcf\data\user\UserProfile $user = null, \Exception &$reason = null): bool { static $cache = [ ]; if ($user === null) $user = new \wcf\data\user\UserProfile(WCF::getUser());