1
0
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:
Tim Düsterhus 2022-03-04 18:28:07 +01:00
parent 00167fc6ed
commit be3b2657bf
Signed by: TimWolla
GPG Key ID: 8FF75566094168AF
4 changed files with 4 additions and 12 deletions

View File

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

View File

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

View File

@ -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,

View File

@ -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,