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

Add proper return types to all MessageTypes

This commit is contained in:
Tim Düsterhus 2022-03-04 19:27:17 +01:00
parent 9119b4ab22
commit 164e1ab1c6
Signed by: TimWolla
GPG Key ID: 8FF75566094168AF
21 changed files with 70 additions and 70 deletions

View File

@ -42,7 +42,7 @@ public function __construct()
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Plain';
}
@ -50,13 +50,13 @@ public function getJavaScriptModuleName()
/**
* @inheritDoc
*/
public function canDelete(Message $message, ?UserProfile $user = null)
public function canDelete(Message $message, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
}
return $user->getPermission('mod.chat.canDelete');
return !!$user->getPermission('mod.chat.canDelete');
}
/**

View File

@ -31,7 +31,7 @@ final class AwayMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Away';
}
@ -39,7 +39,7 @@ public function getJavaScriptModuleName()
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -63,7 +63,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -87,7 +87,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -31,7 +31,7 @@ final class BackMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Back';
}
@ -39,7 +39,7 @@ public function getJavaScriptModuleName()
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -63,7 +63,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -87,7 +87,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -39,7 +39,7 @@ public function __construct()
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Broadcast';
}
@ -55,7 +55,7 @@ public function getPayload(Message $message, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -75,7 +75,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -95,19 +95,19 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function canDelete(Message $message, ?UserProfile $user = null)
public function canDelete(Message $message, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
}
return $user->getPermission('mod.chat.canDelete');
return !!$user->getPermission('mod.chat.canDelete');
}
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -29,7 +29,7 @@ final class ChatUpdateMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/ChatUpdate';
}
@ -37,7 +37,7 @@ public function getJavaScriptModuleName()
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
return true;
}
@ -45,7 +45,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
return true;
}
@ -53,7 +53,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -31,7 +31,7 @@ final class ColorMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Color';
}
@ -39,7 +39,7 @@ public function getJavaScriptModuleName()
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -59,7 +59,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
return false;
}
@ -67,7 +67,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -26,7 +26,7 @@ final class InfoMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Info';
}

View File

@ -26,7 +26,7 @@ final class JoinMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Join';
}

View File

@ -26,7 +26,7 @@ final class LeaveMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Leave';
}

View File

@ -30,7 +30,7 @@ final class MeMessageType implements IMessageType, IDeletableMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Me';
}
@ -38,12 +38,12 @@ public function getJavaScriptModuleName()
/**
* @inheritDoc
*/
public function canDelete(Message $message, ?UserProfile $user = null)
public function canDelete(Message $message, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
}
return $user->getPermission('mod.chat.canDelete');
return !!$user->getPermission('mod.chat.canDelete');
}
}

View File

@ -42,7 +42,7 @@ public function __construct()
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Plain';
}
@ -50,13 +50,13 @@ public function getJavaScriptModuleName()
/**
* @inheritDoc
*/
public function canDelete(Message $message, ?UserProfile $user = null)
public function canDelete(Message $message, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
}
return $user->getPermission('mod.chat.canDelete');
return !!$user->getPermission('mod.chat.canDelete');
}
/**

View File

@ -29,7 +29,7 @@ final class SuspendMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Suspend';
}
@ -59,7 +59,7 @@ public function getPayload(Message $message, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -79,7 +79,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -99,7 +99,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -30,7 +30,7 @@ trait TCanSeeCreator
/**
* @see \chat\system\message\type\IMessageType::canSee()
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -50,7 +50,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @see \chat\system\message\type\IMessageType::canSeeInLog()
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -70,7 +70,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @see \chat\system\message\type\IMessageType::supportsFastSelect()
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
$parameters = [
'result' => true,

View File

@ -29,7 +29,7 @@ trait TCanSeeInSameRoom
/**
* @see \chat\system\message\type\IMessageType::canSee()
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -49,7 +49,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @see \chat\system\message\type\IMessageType::canSeeInLog()
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -69,7 +69,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @see \chat\system\message\type\IMessageType::supportsFastSelect()
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
$parameters = [
'result' => true,

View File

@ -39,7 +39,7 @@ public function __construct()
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Team';
}
@ -55,19 +55,19 @@ public function getPayload(Message $message, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canDelete(Message $message, ?UserProfile $user = null)
public function canDelete(Message $message, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
}
return $user->getPermission('mod.chat.canDelete');
return !!$user->getPermission('mod.chat.canDelete');
}
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -77,7 +77,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
'message' => $message,
'room' => $room,
'user' => $user,
'canSee' => $user->getPermission('mod.chat.canTeam'),
'canSee' => !!$user->getPermission('mod.chat.canTeam'),
];
EventHandler::getInstance()->fireAction($this, 'canSee', $parameters);
@ -87,7 +87,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -97,7 +97,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
'message' => $message,
'room' => $room,
'user' => $user,
'canSee' => $user->getPermission('mod.chat.canTeam'),
'canSee' => !!$user->getPermission('mod.chat.canTeam'),
];
EventHandler::getInstance()->fireAction($this, 'canSeeInLog', $parameters);
@ -107,7 +107,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -26,7 +26,7 @@ final class TemproomCreatedMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/TemproomCreated';
}

View File

@ -29,7 +29,7 @@ final class TemproomInvitedMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/TemproomInvited';
}
@ -64,7 +64,7 @@ public function getPayload(Message $message, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -84,7 +84,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -104,7 +104,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
$parameters = [
'result' => false,

View File

@ -31,7 +31,7 @@ final class TombstoneMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Tombstone';
}
@ -39,7 +39,7 @@ public function getJavaScriptModuleName()
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -59,7 +59,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
return false;
}
@ -67,7 +67,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -29,7 +29,7 @@ final class UnsuspendMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Unsuspend';
}
@ -59,7 +59,7 @@ public function getPayload(Message $message, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -79,7 +79,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -99,7 +99,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
return false;
}

View File

@ -31,7 +31,7 @@ final class WhereMessageType implements IMessageType
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Where';
}

View File

@ -41,7 +41,7 @@ public function __construct()
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
public function getJavaScriptModuleName(): string
{
return 'Bastelstu.be/Chat/MessageType/Whisper';
}
@ -91,7 +91,7 @@ public function getPayload(Message $message, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
public function canSee(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -111,7 +111,7 @@ public function canSee(Message $message, Room $room, ?UserProfile $user = null)
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null): bool
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
@ -131,7 +131,7 @@ public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = n
/**
* @inheritDoc
*/
public function supportsFastSelect()
public function supportsFastSelect(): bool
{
$parameters = [
'result' => false,