Skip to content

Commit

Permalink
Use PHP CS Fixer (#397)
Browse files Browse the repository at this point in the history
* Use PHP CS Fixer

* Autocommit PHP CS Fixer
  • Loading branch information
yurabakhtin authored Jun 27, 2024
1 parent d7b96ca commit 0f85030
Show file tree
Hide file tree
Showing 91 changed files with 248 additions and 304 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: PHP CS Fixer

on: push

jobs:
tests:
uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main
11 changes: 5 additions & 6 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
class Module extends \humhub\components\Module
{

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -82,11 +81,11 @@ public function getPermissions($contentContainer = null)
{
if (!$contentContainer) {
return [
new StartConversation()
new StartConversation(),
];
} else if ($contentContainer instanceof User) {
} elseif ($contentContainer instanceof User) {
return [
new SendMail()
new SendMail(),
];
}

Expand All @@ -97,14 +96,14 @@ public function getNotifications()
{
return [
MailNotification::class,
ConversationNotification::class
ConversationNotification::class,
];
}

/**
* Determines showInTopNav is enabled or not
*
* @return boolean is showInTopNav enabled
* @return bool is showInTopNav enabled
*/
public function hideInTopNav()
{
Expand Down
2 changes: 1 addition & 1 deletion assets/MailMessengerAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class MailMessengerAsset extends AssetBundle
];

public $depends = [
MailNotificationAsset::class
MailNotificationAsset::class,
];
}
8 changes: 4 additions & 4 deletions assets/MailNotificationAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MailNotificationAsset extends AssetBundle
];

public $depends = [
MailStyleAsset::class
MailStyleAsset::class,
];

public static function register($view)
Expand All @@ -34,10 +34,10 @@ public static function register($view)
'url' => [
'count' => Url::toMessageCountUpdate(),
'list' => Url::toNotificationList(),
]
]
],
],
]);

return parent::register($view);
}
}
}
4 changes: 2 additions & 2 deletions assets/MailStyleAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class MailStyleAsset extends AssetBundle
];

public $css = [
'humhub.mail.min.css'
'humhub.mail.min.css',
];
}
}
3 changes: 0 additions & 3 deletions controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
class ConfigController extends \humhub\modules\admin\components\Controller
{

/**
* Configuration action for super admins.
*/
Expand All @@ -35,5 +34,3 @@ public function actionIndex()
return $this->render('index', ['model' => $form]);
}
}

?>
7 changes: 3 additions & 4 deletions controllers/InboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
*/
class InboxController extends Controller
{

/**
* @inheritdoc
*/
protected function getAccessRules()
{
return [
[ControllerAccess::RULE_LOGGED_IN_ONLY]
[ControllerAccess::RULE_LOGGED_IN_ONLY],
];
}

Expand All @@ -37,7 +36,7 @@ protected function getAccessRules()
public function actionIndex()
{
return ConversationInbox::widget([
'filter' => new InboxFilterForm()
'filter' => new InboxFilterForm(),
]);
}

Expand All @@ -57,7 +56,7 @@ public function actionLoadMore()

return $this->asJson([
'result' => $result,
'isLast' => $filter->wasLastPage()
'isLast' => $filter->wasLastPage(),
]);

}
Expand Down
43 changes: 21 additions & 22 deletions controllers/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
*/
class MailController extends Controller
{

/**
* @inheritdoc
*/
Expand All @@ -51,7 +50,7 @@ protected function getAccessRules()
{
return [
[ControllerAccess::RULE_LOGGED_IN_ONLY],
[ControllerAccess::RULE_PERMISSION => StartConversation::class, 'actions' => ['create', 'add-user']]
[ControllerAccess::RULE_PERMISSION => StartConversation::class, 'actions' => ['create', 'add-user']],
];
}

Expand Down Expand Up @@ -98,7 +97,7 @@ public function actionSeen()
}

return $this->asJson([
'messageCount' => UserMessage::getNewMessageCount()
'messageCount' => UserMessage::getNewMessageCount(),
]);
}

Expand All @@ -111,7 +110,7 @@ public function actionUpdate($id, $from = null)
return $this->renderAjaxContent(Messages::widget([
'message' => $message,
'entries' => $message->getEntryUpdates($from)->all(),
'showDateBadge' => false
'showDateBadge' => false,
]));
}

Expand All @@ -127,7 +126,7 @@ public function actionLoadMore($id, $from)

return $this->asJson([
'result' => $result,
'isLast' => (count($entries) < Module::getModuleInstance()->conversationUpdatePageSize)
'isLast' => (count($entries) < Module::getModuleInstance()->conversationUpdatePageSize),
]);
}

Expand All @@ -142,15 +141,15 @@ public function actionReply($id)
if ($replyForm->load(Yii::$app->request->post()) && $replyForm->save()) {
return $this->asJson([
'success' => true,
'content' => ConversationEntry::widget(['entry' => $replyForm->reply, 'showDateBadge' => $replyForm->reply->isFirstToday()])
'content' => ConversationEntry::widget(['entry' => $replyForm->reply, 'showDateBadge' => $replyForm->reply->isFirstToday()]),
]);
}

return $this->asJson([
'success' => false,
'error' => [
'message' => $replyForm->getFirstError('message')
]
'message' => $replyForm->getFirstError('message'),
],
]);
}

Expand All @@ -163,7 +162,7 @@ public function actionUserList($id)
{
return $this->renderAjaxContent(UserListBox::widget([
'query' => $this->getMessage($id, true)->getUsers(),
'title' => '<strong>' . Yii::t('MailModule.base', 'Participants') . '</strong>'
'title' => '<strong>' . Yii::t('MailModule.base', 'Participants') . '</strong>',
]));
}

Expand All @@ -184,15 +183,15 @@ public function actionAddUser($id)
if ($inviteForm->load(Yii::$app->request->post())) {
if ($inviteForm->save()) {
return $this->asJson([
'result' => ConversationHeader::widget(['message' => $message])
'result' => ConversationHeader::widget(['message' => $message]),
]);
}

return $this->asJson([
'success' => false,
'error' => [
'message' => $inviteForm->getFirstError('recipients')
]
'message' => $inviteForm->getFirstError('recipients'),
],
]);
}

Expand Down Expand Up @@ -232,7 +231,7 @@ public function actionSearchUser($keyword, $id = null)
'keyword' => $keyword,
'permission' => (!Yii::$app->user->isAdmin()) ? new SendMail() : null,
'disableFillUser' => true,
'disabledText' => Yii::t('MailModule.base', 'You are not allowed to start a conversation with this user.')
'disabledText' => Yii::t('MailModule.base', 'You are not allowed to start a conversation with this user.'),
]);

// Disable already participating users
Expand Down Expand Up @@ -266,7 +265,7 @@ private function checkMessagePermissions($message)
*
* @param type $message
* @param type $user
* @return boolean
* @return bool
*/
private function isParticipant($message, $user)
{
Expand Down Expand Up @@ -355,7 +354,7 @@ public function actionMarkUnread($id)

return $this->asJson([
'success' => true,
'redirect' => $nextReadMessage ? Url::toMessenger($nextReadMessage) : Url::to(['/dashboard'])
'redirect' => $nextReadMessage ? Url::toMessenger($nextReadMessage) : Url::to(['/dashboard']),
]);
}

Expand All @@ -372,7 +371,7 @@ public function actionPin($id)

return $this->asJson([
'success' => true,
'redirect' => Url::toMessenger($message)
'redirect' => Url::toMessenger($message),
]);
}

Expand All @@ -389,7 +388,7 @@ public function actionUnpin($id)

return $this->asJson([
'success' => true,
'redirect' => Url::toMessenger($message)
'redirect' => Url::toMessenger($message),
]);
}

Expand All @@ -411,7 +410,7 @@ public function actionLeave($id)

return $this->asJson([
'success' => true,
'redirect' => Url::toMessenger()
'redirect' => Url::toMessenger(),
]);
}

Expand Down Expand Up @@ -439,8 +438,8 @@ public function actionEditEntry($id)
'success' => true,
'content' => ConversationEntry::widget([
'entry' => $entry,
'showDateBadge' => false
])
'showDateBadge' => false,
]),
]);
}

Expand Down Expand Up @@ -472,7 +471,7 @@ public function actionDeleteEntry($id)
$entry->message->deleteEntry($entry);

return $this->asJson([
'success' => true
'success' => true,
]);
}

Expand Down Expand Up @@ -520,7 +519,7 @@ private function getNextReadMessage($id): ?Message
->andWhere('user_message.last_viewed >= message.updated_at')
->orderBy([
'user_message.pinned' => SORT_DESC,
'message.updated_at' => SORT_DESC
'message.updated_at' => SORT_DESC,
])
->one();
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TagController extends Controller
protected function getAccessRules()
{
return [
[ControllerAccess::RULE_LOGGED_IN_ONLY]
[ControllerAccess::RULE_LOGGED_IN_ONLY],
];
}

Expand Down Expand Up @@ -117,7 +117,7 @@ public function actionEditConversation($messageId)

if ($model->load(Yii::$app->request->post()) && $model->save()) {
return ModalClose::widget([
'script' => '$("#' . ConversationTags::ID . '").replaceWith(\'' . ConversationTags::widget(['message' => $message]) . '\');'
'script' => '$("#' . ConversationTags::ID . '").replaceWith(\'' . ConversationTags::widget(['message' => $message]) . '\');',
]);
}

Expand Down
6 changes: 2 additions & 4 deletions controllers/rest/EntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
use Yii;
use yii\web\HttpException;


/**
* Class EntryController
*/
class EntryController extends BaseController
{

/**
* Get all entries of the conversation
*
Expand Down Expand Up @@ -151,7 +149,7 @@ protected function getMessageEntry($messageId, $entryId)

$entry = MessageEntry::findOne([
'id' => $entryId,
'message_id' => $message->id
'message_id' => $message->id,
]);

if (!$entry) {
Expand All @@ -160,4 +158,4 @@ protected function getMessageEntry($messageId, $entryId)

return $entry;
}
}
}
4 changes: 1 addition & 3 deletions controllers/rest/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
use yii\web\ForbiddenHttpException;
use yii\web\HttpException;


/**
* Class MessageController
*/
class MessageController extends BaseController
{

/**
* Get list of mail conversations
*
Expand Down Expand Up @@ -102,4 +100,4 @@ public static function getMessage($id)

return $message;
}
}
}
Loading

0 comments on commit 0f85030

Please sign in to comment.