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 = ?";
|
AND userID = ?";
|
||||||
$statement = WCF::getDB()->prepare($sql);
|
$statement = WCF::getDB()->prepare($sql);
|
||||||
$statement->execute([ 0, $room->roomID, $user->userID ]);
|
$statement->execute([ 0, $room->roomID, $user->userID ]);
|
||||||
if ($statement->getAffectedRows() === 0) {
|
\assert($statement->getAffectedRows() > 0);
|
||||||
throw new \LogicException('Unreachable');
|
|
||||||
}
|
|
||||||
|
|
||||||
WCF::getDB()->commitTransaction();
|
WCF::getDB()->commitTransaction();
|
||||||
$commited = true;
|
$commited = true;
|
||||||
|
@ -35,9 +35,7 @@ public function canDownload($objectID)
|
|||||||
if ($objectID) {
|
if ($objectID) {
|
||||||
$message = new Message($objectID);
|
$message = new Message($objectID);
|
||||||
|
|
||||||
if ($message->getMessageType()->objectType !== 'be.bastelstu.chat.messageType.attachment') {
|
\assert($message->getMessageType()->objectType === 'be.bastelstu.chat.messageType.attachment');
|
||||||
throw new \LogicException('Unreachable');
|
|
||||||
}
|
|
||||||
$room = $message->getRoom();
|
$room = $message->getRoom();
|
||||||
|
|
||||||
return $room->canSee();
|
return $room->canSee();
|
||||||
|
@ -35,9 +35,7 @@ public function execute($eventObj, $className, $eventName, array &$parameters)
|
|||||||
'be.bastelstu.chat.suspension',
|
'be.bastelstu.chat.suspension',
|
||||||
'be.bastelstu.chat.suspension.ban'
|
'be.bastelstu.chat.suspension.ban'
|
||||||
);
|
);
|
||||||
if (!$objectTypeID) {
|
\assert($objectTypeID !== null);
|
||||||
throw new \LogicException('Unreachable');
|
|
||||||
}
|
|
||||||
|
|
||||||
$suspensions = Suspension::getActiveSuspensionsByTriple(
|
$suspensions = Suspension::getActiveSuspensionsByTriple(
|
||||||
$objectTypeID,
|
$objectTypeID,
|
||||||
|
@ -35,9 +35,7 @@ public function execute($eventObj, $className, $eventName, array &$parameters)
|
|||||||
'be.bastelstu.chat.suspension',
|
'be.bastelstu.chat.suspension',
|
||||||
'be.bastelstu.chat.suspension.mute'
|
'be.bastelstu.chat.suspension.mute'
|
||||||
);
|
);
|
||||||
if (!$objectTypeID) {
|
\assert($objectTypeID !== null);
|
||||||
throw new \LogicException('Unreachable');
|
|
||||||
}
|
|
||||||
|
|
||||||
$suspensions = Suspension::getActiveSuspensionsByTriple(
|
$suspensions = Suspension::getActiveSuspensionsByTriple(
|
||||||
$objectTypeID,
|
$objectTypeID,
|
||||||
|
Loading…
Reference in New Issue
Block a user