mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-21 21:30:08 +00:00
Use assert to verify invariants
This commit is contained in:
parent
00167fc6ed
commit
be3b2657bf
@ -291,9 +291,7 @@ public function leave()
|
||||
AND userID = ?";
|
||||
$statement = WCF::getDB()->prepare($sql);
|
||||
$statement->execute([ 0, $room->roomID, $user->userID ]);
|
||||
if ($statement->getAffectedRows() === 0) {
|
||||
throw new \LogicException('Unreachable');
|
||||
}
|
||||
\assert($statement->getAffectedRows() > 0);
|
||||
|
||||
WCF::getDB()->commitTransaction();
|
||||
$commited = true;
|
||||
|
@ -35,9 +35,7 @@ public function canDownload($objectID)
|
||||
if ($objectID) {
|
||||
$message = new Message($objectID);
|
||||
|
||||
if ($message->getMessageType()->objectType !== 'be.bastelstu.chat.messageType.attachment') {
|
||||
throw new \LogicException('Unreachable');
|
||||
}
|
||||
\assert($message->getMessageType()->objectType === 'be.bastelstu.chat.messageType.attachment');
|
||||
$room = $message->getRoom();
|
||||
|
||||
return $room->canSee();
|
||||
|
@ -35,9 +35,7 @@ public function execute($eventObj, $className, $eventName, array &$parameters)
|
||||
'be.bastelstu.chat.suspension',
|
||||
'be.bastelstu.chat.suspension.ban'
|
||||
);
|
||||
if (!$objectTypeID) {
|
||||
throw new \LogicException('Unreachable');
|
||||
}
|
||||
\assert($objectTypeID !== null);
|
||||
|
||||
$suspensions = Suspension::getActiveSuspensionsByTriple(
|
||||
$objectTypeID,
|
||||
|
@ -35,9 +35,7 @@ public function execute($eventObj, $className, $eventName, array &$parameters)
|
||||
'be.bastelstu.chat.suspension',
|
||||
'be.bastelstu.chat.suspension.mute'
|
||||
);
|
||||
if (!$objectTypeID) {
|
||||
throw new \LogicException('Unreachable');
|
||||
}
|
||||
\assert($objectTypeID !== null);
|
||||
|
||||
$suspensions = Suspension::getActiveSuspensionsByTriple(
|
||||
$objectTypeID,
|
||||
|
Loading…
Reference in New Issue
Block a user