From 529eabfa89ae38ae9133ef58f30c1131dac7d0f9 Mon Sep 17 00:00:00 2001 From: luke- Date: Mon, 9 Sep 2024 10:29:31 +0000 Subject: [PATCH] Autocommit PHP CS Fixer --- Events.php | 18 +++++++++--------- controllers/InboxController.php | 2 +- controllers/TagController.php | 4 ++-- migrations/m150709_050452_message_tags.php | 2 +- .../m150709_050453_conversation_tags.php | 4 ++-- models/Config.php | 10 +++++----- models/Message.php | 14 +++++++------- models/MessageTag.php | 8 ++++---- models/UserMessage.php | 2 +- models/forms/ConversationTagsForm.php | 2 +- models/forms/InboxFilterForm.php | 14 +++++++------- models/forms/InviteParticipantForm.php | 6 +++--- tests/codeception/unit/InboxFilterFormTest.php | 2 +- widgets/Messages.php | 2 +- widgets/NewMessageButton.php | 8 ++++---- widgets/TimeAgo.php | 4 ++-- 16 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Events.php b/Events.php index e1519bc0..d713228c 100644 --- a/Events.php +++ b/Events.php @@ -42,7 +42,7 @@ public static function onIntegrityCheck($event) try { foreach (Message::find()->each() as $message) { /* @var $message Message */ - if(!$message->getAuthor()->count()) { + if (!$message->getAuthor()->count()) { if ($integrityController->showFix("Deleting conversation id " . $message->id . " without existing author!")) { $message->delete(); } @@ -53,12 +53,12 @@ public static function onIntegrityCheck($event) foreach (MessageEntry::find()->each() as $messageEntry) { /* @var $messageEntry MessageEntry */ - if(!$messageEntry->getUser()->count()) { + if (!$messageEntry->getUser()->count()) { if ($integrityController->showFix("Deleting message entry id " . $messageEntry->id . " without existing user!")) { $messageEntry->delete(); } } - if(!$messageEntry->message) { + if (!$messageEntry->message) { if ($integrityController->showFix("Deleting message entry id " . $messageEntry->id . " without existing conversation!")) { $messageEntry->delete(); } @@ -69,7 +69,7 @@ public static function onIntegrityCheck($event) foreach (UserMessage::find()->each() as $userMessage) { /* @var $userMessage UserMessage */ - if(!$userMessage->getUser()->count()) { + if (!$userMessage->getUser()->count()) { if ($integrityController->showFix("Deleting user message id " . $userMessage->message_id . " without existing user!")) { $userMessage->delete(); } @@ -80,13 +80,13 @@ public static function onIntegrityCheck($event) foreach (UserMessageTag::find()->each() as $messageTag) { /* @var $messageTag UserMessageTag */ - if(!$messageTag->getUser()->count()) { + if (!$messageTag->getUser()->count()) { if ($integrityController->showFix("Deleting user tag id " . $messageTag->id . " without existing user!")) { $messageTag->delete(); } } } - } catch(\Throwable $e) { + } catch (\Throwable $e) { Yii::error($e); } } @@ -109,7 +109,7 @@ public static function onUserDelete($event) } foreach (UserMessage::findAll(['user_id' => $event->sender->id]) as $userMessage) { - if($userMessage->message) { + if ($userMessage->message) { $userMessage->message->leave($event->sender->id); } @@ -119,7 +119,7 @@ public static function onUserDelete($event) foreach (UserMessageTag::findAll(['user_id' => $event->sender->id]) as $userMessageTag) { $userMessageTag->delete(); } - } catch(\Throwable $e) { + } catch (\Throwable $e) { Yii::error($e); } @@ -150,7 +150,7 @@ public static function onTopMenuInit($event) 'sortOrder' => 300, ]); } - } catch(\Throwable $e) { + } catch (\Throwable $e) { Yii::error($e); } } diff --git a/controllers/InboxController.php b/controllers/InboxController.php index 58b6ef38..d7bff32c 100644 --- a/controllers/InboxController.php +++ b/controllers/InboxController.php @@ -49,7 +49,7 @@ public function actionLoadMore() foreach ($userMessages as $userMessage) { try { $result .= InboxMessagePreview::widget(['userMessage' => $userMessage]); - } catch(\Throwable $e) { + } catch (\Throwable $e) { Yii::error($e); } } diff --git a/controllers/TagController.php b/controllers/TagController.php index c1deee55..a4abce46 100644 --- a/controllers/TagController.php +++ b/controllers/TagController.php @@ -43,7 +43,7 @@ public function actionAdd() { $model = new AddTag(); $model->load(Yii::$app->request->post()); - if($model->save()) { + if ($model->save()) { $model = new AddTag(); } return $this->render('manage', ['model' => $model]); @@ -53,7 +53,7 @@ public function actionEdit($id) { $tag = $this->findTag($id); - if($tag->load(Yii::$app->request->post()) && $tag->save()) { + if ($tag->load(Yii::$app->request->post()) && $tag->save()) { return ModalClose::widget(['reload' => true]); } diff --git a/migrations/m150709_050452_message_tags.php b/migrations/m150709_050452_message_tags.php index 5a69f6b8..4e1d2a10 100644 --- a/migrations/m150709_050452_message_tags.php +++ b/migrations/m150709_050452_message_tags.php @@ -18,7 +18,7 @@ public function safeUp() try { $this->addForeignKey('fk-message-tag-user-id', 'message_tag', 'user_id', 'user', 'id', 'cascade'); - } catch(\Exception $e) { + } catch (\Exception $e) { Yii::error($e); } } diff --git a/migrations/m150709_050453_conversation_tags.php b/migrations/m150709_050453_conversation_tags.php index 5bb231e5..8dc0c995 100644 --- a/migrations/m150709_050453_conversation_tags.php +++ b/migrations/m150709_050453_conversation_tags.php @@ -19,13 +19,13 @@ public function safeUp() try { $this->addForeignKey('fk-user-message-id', 'user_message_tag', ['message_id', 'user_id'], 'user_message', ['message_id', 'user_id'], 'cascade'); - } catch(\Exception $e) { + } catch (\Exception $e) { Yii::error($e, 'mail'); } try { $this->addForeignKey('fk-conversation-tag-tag-id', 'user_message_tag', 'tag_id', 'message_tag', 'id', 'cascade'); - } catch(\Exception $e) { + } catch (\Exception $e) { Yii::error($e, 'mail'); } } diff --git a/models/Config.php b/models/Config.php index 1f698a1e..e3009f15 100644 --- a/models/Config.php +++ b/models/Config.php @@ -86,7 +86,7 @@ public function attributeLabels() public function save() { - if(!$this->validate()) { + if (!$this->validate()) { return false; } @@ -103,7 +103,7 @@ public function save() public function canCreateConversation(User $originator) { - if($originator->isSystemAdmin()) { + if ($originator->isSystemAdmin()) { return true; } @@ -116,7 +116,7 @@ public function canCreateConversation(User $originator) public function isNewUser(User $originator) { - if(empty($this->newUserRestrictionEnabled)) { + if (empty($this->newUserRestrictionEnabled)) { return false; } @@ -128,7 +128,7 @@ public function getConversationCount($originator) $module = static::getModule(); $lastTS = $module->settings->contentContainer($originator)->get('conversationCountTime'); - if(!$lastTS) { + if (!$lastTS) { $module->settings->contentContainer($originator)->set('conversationCountTime', time()); $module->settings->contentContainer($originator)->set('conversationCount', 0); return 0; @@ -137,7 +137,7 @@ public function getConversationCount($originator) $lastDate = (new \DateTime())->setTimestamp($lastTS); $today = (new \DateTime())->setTime(0, 0, 0); - if($today > $lastDate) { + if ($today > $lastDate) { $module->settings->contentContainer($originator)->set('conversationCountTime', time()); $module->settings->contentContainer($originator)->set('conversationCount', 0); return 0; diff --git a/models/Message.php b/models/Message.php index 33207ad5..8eaf3327 100644 --- a/models/Message.php +++ b/models/Message.php @@ -181,14 +181,14 @@ public function getOriginator() */ public function attributeLabels() { - return array( + return [ 'id' => 'ID', 'title' => Yii::t('MailModule.base', 'Title'), 'created_at' => Yii::t('MailModule.base', 'Created At'), 'created_by' => Yii::t('MailModule.base', 'Created By'), 'updated_at' => Yii::t('MailModule.base', 'Updated At'), 'updated_by' => Yii::t('MailModule.base', 'Updated By'), - ); + ]; } /** @@ -240,7 +240,7 @@ public function getLastActiveParticipant(bool $includeMe = false): User public function deleteEntry($entry) { if ($entry->message->id == $this->id) { - if($this->getEntries()->count() > 1) { + if ($this->getEntries()->count() > 1) { $entry->delete(); } else { $this->delete(); @@ -318,10 +318,10 @@ public function leave($userId = null) public function seen($userId) { // Update User Message Entry - $userMessage = UserMessage::findOne(array( + $userMessage = UserMessage::findOne([ 'user_id' => $userId, 'message_id' => $this->id, - )); + ]); if ($userMessage !== null) { $userMessage->last_viewed = date('Y-m-d G:i:s'); $userMessage->save(); @@ -333,11 +333,11 @@ public function seen($userId) */ public function delete() { - foreach (MessageEntry::findAll(array('message_id' => $this->id)) as $messageEntry) { + foreach (MessageEntry::findAll(['message_id' => $this->id]) as $messageEntry) { $messageEntry->delete(); } - foreach (UserMessage::findAll(array('message_id' => $this->id)) as $userMessage) { + foreach (UserMessage::findAll(['message_id' => $this->id]) as $userMessage) { $userMessage->delete(); } diff --git a/models/MessageTag.php b/models/MessageTag.php index 2a25680f..2ade37d6 100644 --- a/models/MessageTag.php +++ b/models/MessageTag.php @@ -40,7 +40,7 @@ public function rules() public static function search($userId, $keyword) { - if(empty($userId)) { + if (empty($userId)) { return []; } @@ -63,7 +63,7 @@ public static function attach($userId, Message $message, $tags = []) $userMessage = $message->getUserMessage(); - if(!$userMessage) { + if (!$userMessage) { throw new NotFoundHttpException(); } @@ -77,7 +77,7 @@ public static function attach($userId, Message $message, $tags = []) $tags = is_array($tags) ? $tags : [$tags]; foreach ($tags as $tag) { - if(is_string($tag) && strpos($tag, '_add:') === 0) { + if (is_string($tag) && strpos($tag, '_add:') === 0) { $newTag = new static([ 'name' => substr($tag, strlen('_add:')), 'user_id' => $userId, @@ -108,7 +108,7 @@ private static function deleteTagRelations($userId, UserMessage $message) public function afterDelete() { - foreach(UserMessageTag::find()->where(['tag_id' => $this->id])->all() as $messageTag) { + foreach (UserMessageTag::find()->where(['tag_id' => $this->id])->all() as $messageTag) { $messageTag->delete(); } } diff --git a/models/UserMessage.php b/models/UserMessage.php index 29a13719..002e80a9 100644 --- a/models/UserMessage.php +++ b/models/UserMessage.php @@ -93,7 +93,7 @@ public static function getNewMessageCount($userId = null) $userId = Yii::$app->user->id; } - if($userId instanceof User) { + if ($userId instanceof User) { $userId = $userId->id; } diff --git a/models/forms/ConversationTagsForm.php b/models/forms/ConversationTagsForm.php index 7491a8df..f38d82c0 100644 --- a/models/forms/ConversationTagsForm.php +++ b/models/forms/ConversationTagsForm.php @@ -20,7 +20,7 @@ class ConversationTagsForm extends Model public function init() { parent::init(); - if(empty($this->tags)) { + if (empty($this->tags)) { $this->tags = MessageTag::findByMessage(Yii::$app->user->id, $this->message)->all(); } } diff --git a/models/forms/InboxFilterForm.php b/models/forms/InboxFilterForm.php index 6776cb84..bf7c548f 100644 --- a/models/forms/InboxFilterForm.php +++ b/models/forms/InboxFilterForm.php @@ -92,7 +92,7 @@ public function init() */ public function apply() { - if(!empty($this->term)) { + if (!empty($this->term)) { $messageEntryContentSubQuery = MessageEntry::find()->where('message_entry.message_id = message.id') ->andWhere($this->createTermLikeCondition('message_entry.content')); @@ -102,7 +102,7 @@ public function apply() ])); } - if(!empty($this->participants)) { + if (!empty($this->participants)) { foreach ($this->participants as $userGuid) { $participantsExistsSubQuery = UserMessage::find()->joinWith('user')->where('user_message.message_id = message.id') ->andWhere(['user.guid' => $userGuid]); @@ -111,7 +111,7 @@ public function apply() } - if(!empty($this->tags)) { + if (!empty($this->tags)) { foreach ($this->tags as $tag) { $participantsExistsSubQuery = UserMessageTag::find() ->where('user_message.message_id = user_message_tag.message_id') @@ -121,16 +121,16 @@ public function apply() } } - if(!empty($this->from)) { + if (!empty($this->from)) { $message = Message::findOne(['id' => $this->from]); - if(!$message) { + if (!$message) { throw new InvalidCallException(); } $this->query->andWhere(['<=', 'message.updated_at', $message->updated_at]); $this->query->andWhere(['<>', 'message.id', $message->id]); } - if(!empty($this->ids)) { + if (!empty($this->ids)) { $this->query->andWhere(['IN', 'user_message.message_id', $this->ids]); } } @@ -155,7 +155,7 @@ public function getPage() public function wasLastPage() { - if($this->wasLastPage === null) { + if ($this->wasLastPage === null) { throw new InvalidCallException(); } diff --git a/models/forms/InviteParticipantForm.php b/models/forms/InviteParticipantForm.php index 8d3d6040..6e9cfaa4 100644 --- a/models/forms/InviteParticipantForm.php +++ b/models/forms/InviteParticipantForm.php @@ -72,9 +72,9 @@ public function checkRecipient($attribute, $params) $name = Html::encode($user->getDisplayName()); if (Yii::$app->user->identity->is($user)) { $this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "You cannot send a email to yourself!")); - } elseif($this->message->isParticipant($user)) { + } elseif ($this->message->isParticipant($user)) { $this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "User {name} is already participating!", ['name' => $name])); - } elseif(!$user->can(SendMail::class) && !Yii::$app->user->isAdmin()) { + } elseif (!$user->can(SendMail::class) && !Yii::$app->user->isAdmin()) { $this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "You are not allowed to send user {name} is already!", ['name' => $name])); } else { $this->recipientUsers[] = $user; @@ -95,7 +95,7 @@ public function getUrl() public function save() { - if(!$this->validate()) { + if (!$this->validate()) { return false; } diff --git a/tests/codeception/unit/InboxFilterFormTest.php b/tests/codeception/unit/InboxFilterFormTest.php index 2a3fb748..57fad9f0 100644 --- a/tests/codeception/unit/InboxFilterFormTest.php +++ b/tests/codeception/unit/InboxFilterFormTest.php @@ -21,7 +21,7 @@ private function createMessage($title, $message, $users = null, $tags = []) { $this->becomeUser('User1'); - if(!$users) { + if (!$users) { $user2 = User::findOne(['id' => 3]); $users = [$user2->guid]; } diff --git a/widgets/Messages.php b/widgets/Messages.php index 2c4fe045..995c3929 100644 --- a/widgets/Messages.php +++ b/widgets/Messages.php @@ -58,7 +58,7 @@ public function run() */ private function getEntries() { - if($this->entries) { + if ($this->entries) { return $this->entries; } diff --git a/widgets/NewMessageButton.php b/widgets/NewMessageButton.php index a1a73617..cd7b40f7 100644 --- a/widgets/NewMessageButton.php +++ b/widgets/NewMessageButton.php @@ -51,15 +51,15 @@ public function run() { $button = ModalButton::defaultType($this->getLabel())->load(Url::toCreateConversation($this->guid))->id($this->id); - if($this->icon) { + if ($this->icon) { $button->icon($this->icon); } - if($this->right) { + if ($this->right) { $button->right(); } - if($this->cssClass) { + if ($this->cssClass) { $button->cssClass($this->cssClass); } @@ -83,7 +83,7 @@ public function run() public function getLabel() { - if($this->label !== null) { + if ($this->label !== null) { return $this->label; } diff --git a/widgets/TimeAgo.php b/widgets/TimeAgo.php index 9770a321..b218d021 100644 --- a/widgets/TimeAgo.php +++ b/widgets/TimeAgo.php @@ -12,7 +12,7 @@ public function renderDateTime($elapsed) { // TODO: From HumHub 1.7 the timeAgoHideTimeAfter can be configured within the widget // Assure time is always set - if(isset(Yii::$app->params['formatter']['timeAgoHideTimeAfter'])) { + if (isset(Yii::$app->params['formatter']['timeAgoHideTimeAfter'])) { $timeAgoHideTimeAfter = Yii::$app->params['formatter']['timeAgoHideTimeAfter']; Yii::$app->params['formatter']['timeAgoHideTimeAfter'] = false; @@ -29,7 +29,7 @@ public function renderTimeAgo() { $result = parent::renderTimeAgo(); - if($this->badge) { + if ($this->badge) { $result = '' . $result . ''; }