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 @@ class CommandTriggerAddForm extends AbstractForm
{
parent::validate();
if (empty($this->commandTrigger)) {
if ($this->commandTrigger === '') {
throw new UserInputException('commandTrigger', 'empty');
}
@ -119,7 +119,7 @@ class CommandTriggerAddForm extends AbstractForm
throw new UserInputException('commandTrigger', 'duplicate');
}
if (empty($this->className)) {
if ($this->className === '') {
throw new UserInputException('className', 'empty');
}

View File

@ -225,7 +225,7 @@ class RoomAddForm extends AbstractForm
}
}
if (!empty($data)) {
if ($data !== []) {
(new RoomEditor($room))->update($data);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@ final class HourlyCleanUpCronjobExecuteTemproomListener implements IParameterize
$toDelete[] = $room;
}
}
if (!empty($toDelete)) {
if ($toDelete !== []) {
(new RoomAction(
$toDelete,
'delete'

View File

@ -42,7 +42,7 @@ final class RoomCanJoinBanListener implements IParameterizedEventListener
$parameters['user']->getDecoratedObject(),
$eventObj
);
if (!empty($suspensions)) {
if ($suspensions !== []) {
$parameters['result'] = new PermissionDeniedException(
WCF::getLanguage()->getDynamicVariable('chat.suspension.info.be.bastelstu.chat.suspension.ban')
);

View File

@ -42,7 +42,7 @@ final class RoomCanWritePubliclyMuteListener implements IParameterizedEventListe
$parameters['user']->getDecoratedObject(),
$eventObj
);
if (!empty($suspensions)) {
if ($suspensions !== []) {
$parameters['result'] = new PermissionDeniedException(
WCF::getLanguage()->getDynamicVariable('chat.suspension.info.be.bastelstu.chat.suspension.mute')
);

View File

@ -36,7 +36,7 @@ final class RoomListPageHandler extends AbstractMenuPageHandler
return $room->canSee();
}));
if (empty($users)) {
if ($users === []) {
return 0;
}