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

Add proper types to Suspension

This commit is contained in:
Tim Düsterhus 2022-03-04 19:14:03 +01:00
parent 06f15e0306
commit 56faf3fab1
Signed by: TimWolla
GPG Key ID: 8FF75566094168AF

View File

@ -18,6 +18,7 @@
use chat\data\room\Room;
use chat\data\room\RoomCache;
use wcf\data\DatabaseObject;
use wcf\data\object\type\ObjectType;
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\User;
use wcf\system\cache\runtime\UserRuntimeCache;
@ -31,10 +32,9 @@ class Suspension extends DatabaseObject implements \JsonSerializable
* Returns the active suspensions for the given (objectTypeID, Room, User)
* triple.
*
* @param int $objectTypeID
* @return \chat\data\suspension\Suspension[]
*/
public static function getActiveSuspensionsByTriple($objectTypeID, User $user, Room $room)
public static function getActiveSuspensionsByTriple(int $objectTypeID, User $user, Room $room)
{
$suspensionList = new SuspensionList();
@ -53,20 +53,16 @@ public static function getActiveSuspensionsByTriple($objectTypeID, User $user, R
/**
* Returns the suspension object type of this message.
*
* @return \wcf\data\object\type\ObjectType
*/
public function getSuspensionType()
public function getSuspensionType(): ObjectType
{
return ObjectTypeCache::getInstance()->getObjectType($this->objectTypeID);
}
/**
* Returns whether this suspension still is in effect.
*
* @return boolean
*/
public function isActive()
public function isActive(): bool
{
if ($this->revoked !== null) {
return false;
@ -85,10 +81,8 @@ public function isActive()
/**
* Returns the chat room this suspension is in effect.
* Returns null if this is a global suspension.
*
* @return \chat\data\room\Room
*/
public function getRoom()
public function getRoom(): ?Room
{
if ($this->roomID === null) {
return null;
@ -99,10 +93,8 @@ public function getRoom()
/**
* Returns the user that is affected by this suspension.
*
* @return \wcf\data\user\User
*/
public function getUser()
public function getUser(): User
{
return UserRuntimeCache::getInstance()->getObject($this->userID);
}