1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-21 21:30:08 +00:00

Use return type annotations in favor of PHPDoc

This commit is contained in:
Tim Düsterhus 2020-11-01 14:13:04 +01:00
parent 9c9e634388
commit 7d3f237927
Signed by: TimWolla
GPG Key ID: 8FF75566094168AF
2 changed files with 13 additions and 30 deletions

View File

@ -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);
}
}

View File

@ -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());