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

Avoid the use of empty()

This commit is contained in:
Tim Düsterhus 2022-03-04 19:40:31 +01:00
parent ad9fba9d73
commit 527a04db58
Signed by: TimWolla
GPG Key ID: 8FF75566094168AF
10 changed files with 12 additions and 12 deletions

View File

@ -101,7 +101,7 @@ public function validate()
{ {
parent::validate(); parent::validate();
if (empty($this->commandTrigger)) { if ($this->commandTrigger === '') {
throw new UserInputException('commandTrigger', 'empty'); throw new UserInputException('commandTrigger', 'empty');
} }
@ -119,7 +119,7 @@ public function validate()
throw new UserInputException('commandTrigger', 'duplicate'); throw new UserInputException('commandTrigger', 'duplicate');
} }
if (empty($this->className)) { if ($this->className === '') {
throw new UserInputException('className', 'empty'); throw new UserInputException('className', 'empty');
} }

View File

@ -225,7 +225,7 @@ public function saveI18nValue(Room $room, $columns)
} }
} }
if (!empty($data)) { if ($data !== []) {
(new RoomEditor($room))->update($data); (new RoomEditor($room))->update($data);
} }
} }

View File

@ -149,7 +149,7 @@ public function readParameters()
if (isset($_POST['searchUsername'])) { if (isset($_POST['searchUsername'])) {
$this->searchUsername = StringUtil::trim($_POST['searchUsername']); $this->searchUsername = StringUtil::trim($_POST['searchUsername']);
if (!empty($this->searchUsername)) { if ($this->searchUsername !== '') {
$this->userID = User::getUserByUsername($this->searchUsername)->userID; $this->userID = User::getUserByUsername($this->searchUsername)->userID;
} }
} elseif ($this->userID !== null) { } elseif ($this->userID !== null) {
@ -159,7 +159,7 @@ public function readParameters()
if (isset($_POST['searchJudge'])) { if (isset($_POST['searchJudge'])) {
$this->searchJudge = StringUtil::trim($_POST['searchJudge']); $this->searchJudge = StringUtil::trim($_POST['searchJudge']);
if (!empty($this->searchJudge)) { if ($this->searchJudge !== '') {
$this->judgeID = User::getUserByUsername($this->searchJudge)->userID; $this->judgeID = User::getUserByUsername($this->searchJudge)->userID;
} }
} elseif ($this->judgeID !== null) { } elseif ($this->judgeID !== null) {

View File

@ -333,7 +333,7 @@ public function pull()
return $message->hasEmbeddedObjects; return $message->hasEmbeddedObjects;
})); }));
if (!empty($embeddedObjectMessageIDs)) { if ($embeddedObjectMessageIDs !== []) {
// load embedded objects // load embedded objects
MessageEmbeddedObjectManager::getInstance()->loadObjects('be.bastelstu.chat.message', $embeddedObjectMessageIDs); MessageEmbeddedObjectManager::getInstance()->loadObjects('be.bastelstu.chat.message', $embeddedObjectMessageIDs);
} }

View File

@ -37,7 +37,7 @@ public static function deleteAll(array $messageIDs = [])
WCF::getDB()->beginTransaction(); WCF::getDB()->beginTransaction();
$result = parent::deleteAll($messageIDs); $result = parent::deleteAll($messageIDs);
if (!empty($messageIDs)) { if ($messageIDs !== []) {
AttachmentHandler::removeAttachments('be.bastelstu.chat.message', $messageIDs); AttachmentHandler::removeAttachments('be.bastelstu.chat.message', $messageIDs);
} }

View File

@ -88,7 +88,7 @@ public function getUsersByID()
public function clearDeadSessions() public function clearDeadSessions()
{ {
$sessions = User::getDeadSessions(); $sessions = User::getDeadSessions();
if (empty($sessions)) { if ($sessions !== []) {
return; return;
} }
$userIDs = \array_map(static function ($item) { $userIDs = \array_map(static function ($item) {

View File

@ -41,7 +41,7 @@ public function execute($eventObj, $className, $eventName, array &$parameters)
$toDelete[] = $room; $toDelete[] = $room;
} }
} }
if (!empty($toDelete)) { if ($toDelete !== []) {
(new RoomAction( (new RoomAction(
$toDelete, $toDelete,
'delete' 'delete'

View File

@ -42,7 +42,7 @@ public function execute($eventObj, $className, $eventName, array &$parameters)
$parameters['user']->getDecoratedObject(), $parameters['user']->getDecoratedObject(),
$eventObj $eventObj
); );
if (!empty($suspensions)) { if ($suspensions !== []) {
$parameters['result'] = new PermissionDeniedException( $parameters['result'] = new PermissionDeniedException(
WCF::getLanguage()->getDynamicVariable('chat.suspension.info.be.bastelstu.chat.suspension.ban') WCF::getLanguage()->getDynamicVariable('chat.suspension.info.be.bastelstu.chat.suspension.ban')
); );

View File

@ -42,7 +42,7 @@ public function execute($eventObj, $className, $eventName, array &$parameters)
$parameters['user']->getDecoratedObject(), $parameters['user']->getDecoratedObject(),
$eventObj $eventObj
); );
if (!empty($suspensions)) { if ($suspensions !== []) {
$parameters['result'] = new PermissionDeniedException( $parameters['result'] = new PermissionDeniedException(
WCF::getLanguage()->getDynamicVariable('chat.suspension.info.be.bastelstu.chat.suspension.mute') WCF::getLanguage()->getDynamicVariable('chat.suspension.info.be.bastelstu.chat.suspension.mute')
); );

View File

@ -36,7 +36,7 @@ public function getOutstandingItemCount($objectID = null): int
return $room->canSee(); return $room->canSee();
})); }));
if (empty($users)) { if ($users === []) {
return 0; return 0;
} }