From 23fbc68f9869707301647698c135162b183fa915 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Thu, 3 Oct 2024 13:31:57 +0200 Subject: [PATCH 1/2] Use PHP CS Fixer --- .github/workflows/php-cs-fixer.yml | 7 +++++++ docs/CHANGELOG.md | 4 ++++ module.json | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/php-cs-fixer.yml diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..2d37e13 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,7 @@ +name: PHP CS Fixer + +on: push + +jobs: + fixers: + uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3b21fbf..211e387 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +2.0.8 (Unreleased) +------------------------- +- Enh #52: Use PHP CS Fixer + 2.0.7 (September 2, 2024) ------------------------- - Fix #48: Fix go service for multiline links diff --git a/module.json b/module.json index 6da4c72..efdc95f 100644 --- a/module.json +++ b/module.json @@ -11,7 +11,7 @@ "humhub": { "minVersion": "1.14" }, - "version": "2.0.7", + "version": "2.0.8", "screenshots": [ "resources/screenshot1.PNG", "resources/screenshot2.PNG" From cd397d70732722d9dddbb71fa5f4836cad803a99 Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Thu, 3 Oct 2024 11:32:18 +0000 Subject: [PATCH 2/2] Autocommit PHP CS Fixer --- Events.php | 5 +- Module.php | 1 - commands/SendController.php | 5 +- components/NotificationTargetProvider.php | 2 +- components/SendReport.php | 6 +- components/UrlRule.php | 80 +++++++++++------------ config.php | 1 - controllers/AdminController.php | 3 +- controllers/MobileAppController.php | 2 - controllers/StatusController.php | 6 +- controllers/TokenController.php | 26 ++++---- driver/DriverInterface.php | 2 +- driver/Fcm.php | 4 +- driver/FcmLegacy.php | 8 +-- driver/Proxy.php | 4 +- helpers/MobileAppHelper.php | 2 +- migrations/m190819_210853_initial.php | 2 +- models/FcmUser.php | 3 +- services/DriverService.php | 2 +- services/MessagingService.php | 4 +- services/TokenService.php | 2 +- widgets/PushNotificationInfoWidget.php | 4 +- 22 files changed, 83 insertions(+), 91 deletions(-) diff --git a/Events.php b/Events.php index 1f52407..720e048 100644 --- a/Events.php +++ b/Events.php @@ -2,7 +2,6 @@ namespace humhub\modules\fcmPush; - use humhub\components\mail\Message; use humhub\modules\fcmPush\assets\FcmPushAsset; use humhub\modules\fcmPush\assets\FirebaseAsset; @@ -21,7 +20,6 @@ class Events { - private const SESSION_VAR_LOGOUT = 'mobileAppHandleLogout'; private const SESSION_VAR_LOGIN = 'mobileAppHandleLogin'; @@ -133,7 +131,8 @@ public static function onAfterLogin() Yii::$app->session->set(self::SESSION_VAR_LOGIN, 1); } - public static function onAuthChoiceBeforeRun(Event $event) { + public static function onAuthChoiceBeforeRun(Event $event) + { /** @var AuthChoice $sender */ $sender = $event->sender; diff --git a/Module.php b/Module.php index 50788d3..d02bb7f 100644 --- a/Module.php +++ b/Module.php @@ -10,7 +10,6 @@ class Module extends \humhub\components\Module { - /** * @inheritdoc */ diff --git a/commands/SendController.php b/commands/SendController.php index 4980bf5..3a06a82 100644 --- a/commands/SendController.php +++ b/commands/SendController.php @@ -9,7 +9,6 @@ class SendController extends \yii\console\Controller { - public function actionSendToUser($userId, $title, $message) { /** @var Module $module */ @@ -23,7 +22,7 @@ public function actionSendToUser($userId, $title, $message) $message, null, null, - null + null, ); } -} \ No newline at end of file +} diff --git a/components/NotificationTargetProvider.php b/components/NotificationTargetProvider.php index 2a91b59..f186ede 100644 --- a/components/NotificationTargetProvider.php +++ b/components/NotificationTargetProvider.php @@ -61,4 +61,4 @@ public function isActive(User $user = null) return true; } -} \ No newline at end of file +} diff --git a/components/SendReport.php b/components/SendReport.php index 87a133e..8309e01 100644 --- a/components/SendReport.php +++ b/components/SendReport.php @@ -4,8 +4,8 @@ class SendReport { - const STATE_SUCCESS = 1; - const STATE_ERROR = 2; + public const STATE_SUCCESS = 1; + public const STATE_ERROR = 2; public $failedTokens = []; @@ -13,4 +13,4 @@ public function __construct($state, $failedTokens = []) { } -} \ No newline at end of file +} diff --git a/components/UrlRule.php b/components/UrlRule.php index ef774ef..2153d8f 100644 --- a/components/UrlRule.php +++ b/components/UrlRule.php @@ -1,40 +1,40 @@ -getPathInfo(); - if (str_starts_with($path, WellKnownService::URL_PREFIX)) { - return WellKnownService::instance($path)->getRuleRoute() ?? false; - } - - return false; - } -} +getPathInfo(); + if (str_starts_with($path, WellKnownService::URL_PREFIX)) { + return WellKnownService::instance($path)->getRuleRoute() ?? false; + } + + return false; + } +} diff --git a/config.php b/config.php index 20353ef..4216cf3 100644 --- a/config.php +++ b/config.php @@ -5,7 +5,6 @@ use humhub\modules\fcmPush\Events; use humhub\components\Controller; - //use humhub\modules\notification\widgets\NotificationInfoWidget; use humhub\modules\user\widgets\AuthChoice; use humhub\widgets\LayoutAddons; diff --git a/controllers/AdminController.php b/controllers/AdminController.php index df2e21b..b072f02 100644 --- a/controllers/AdminController.php +++ b/controllers/AdminController.php @@ -13,7 +13,6 @@ */ class AdminController extends Controller { - public function actionIndex() { @@ -27,4 +26,4 @@ public function actionIndex() return $this->render('index', ['model' => $model]); } -} \ No newline at end of file +} diff --git a/controllers/MobileAppController.php b/controllers/MobileAppController.php index 3a40a7a..068d498 100644 --- a/controllers/MobileAppController.php +++ b/controllers/MobileAppController.php @@ -2,7 +2,6 @@ namespace humhub\modules\fcmPush\controllers; - use humhub\modules\admin\components\Controller; use humhub\modules\admin\notifications\NewVersionAvailable; use humhub\modules\fcmPush\models\FcmUser; @@ -11,7 +10,6 @@ class MobileAppController extends Controller { - /** * Renders the index view for the module * diff --git a/controllers/StatusController.php b/controllers/StatusController.php index 0f219f9..a4b38e7 100644 --- a/controllers/StatusController.php +++ b/controllers/StatusController.php @@ -15,14 +15,14 @@ class StatusController extends Controller public function actionIndex() { if (!$this->module->isActivated) { - return $this->returnStatus(404,'FCM Module is not installed'); + return $this->returnStatus(404, 'FCM Module is not installed'); } if (!$this->module->getDriverService()->hasConfiguredDriver()) { - return $this->returnStatus(501,'Push Proxy is not configured'); + return $this->returnStatus(501, 'Push Proxy is not configured'); } - return $this->returnStatus(200,'OK, Push (Proxy) is correctly configured'); + return $this->returnStatus(200, 'OK, Push (Proxy) is correctly configured'); } private function returnStatus(int $code, string $message): Response diff --git a/controllers/TokenController.php b/controllers/TokenController.php index 7780b87..11de51c 100644 --- a/controllers/TokenController.php +++ b/controllers/TokenController.php @@ -40,11 +40,11 @@ public function actionUpdate() return $this->asJson([ 'success' => ( - (new TokenService())->storeTokenForUser( - Yii::$app->user->getIdentity(), - $driver, - Yii::$app->request->post('token') - ) + (new TokenService())->storeTokenForUser( + Yii::$app->user->getIdentity(), + $driver, + Yii::$app->request->post('token'), + ) ), ]); } @@ -63,11 +63,11 @@ public function actionUpdateMobileApp() return $this->asJson([ 'success' => ( - (new TokenService())->storeTokenForUser( - Yii::$app->user->getIdentity(), - $driver, - Yii::$app->request->post('token') - ) + (new TokenService())->storeTokenForUser( + Yii::$app->user->getIdentity(), + $driver, + Yii::$app->request->post('token'), + ) ), ]); } @@ -89,9 +89,9 @@ public function actionDeleteMobileApp() return $this->asJson([ 'success' => ( - (new TokenService())->deleteToken( - Yii::$app->request->post('token') - ) + (new TokenService())->deleteToken( + Yii::$app->request->post('token'), + ) ), ]); } diff --git a/driver/DriverInterface.php b/driver/DriverInterface.php index 2515725..03ade0f 100644 --- a/driver/DriverInterface.php +++ b/driver/DriverInterface.php @@ -15,4 +15,4 @@ public function processCloudMessage(array $tokens, string $title, string $body, public function getSenderId(): string; public function isConfigured(): bool; -} \ No newline at end of file +} diff --git a/driver/Fcm.php b/driver/Fcm.php index 2bae861..0af8ab3 100644 --- a/driver/Fcm.php +++ b/driver/Fcm.php @@ -29,7 +29,7 @@ public function processCloudMessage(array $tokens, string $title, string $body, if ($this->messaging === null) { Module::registerAutoloader(); - $factory = (new Factory)->withServiceAccount($this->config->getJsonAsArray()); + $factory = (new Factory())->withServiceAccount($this->config->getJsonAsArray()); $this->messaging = $factory->createMessaging(); } @@ -67,4 +67,4 @@ public function isConfigured(): bool { return (!empty($this->config->json) && !empty($this->config->senderId)); } -} \ No newline at end of file +} diff --git a/driver/FcmLegacy.php b/driver/FcmLegacy.php index 1b2f564..63bcf8e 100644 --- a/driver/FcmLegacy.php +++ b/driver/FcmLegacy.php @@ -35,15 +35,15 @@ public function processCloudMessage(array $tokens, string $title, string $body, "title" => $title, "body" => $body, "icon" => SiteIcon::getUrl(180), - "click_action" => $url + "click_action" => $url, ], "data" => [ "title" => $title, "body" => $body, "icon" => SiteIcon::getUrl(180), - "url" => $url + "url" => $url, ], - "registration_ids" => $tokens + "registration_ids" => $tokens, ]; $response = $this->post('send', $data)->send(); @@ -64,4 +64,4 @@ public function getSenderId(): string { return $this->config->senderId; } -} \ No newline at end of file +} diff --git a/driver/Proxy.php b/driver/Proxy.php index 9b5a8b0..ac903ed 100644 --- a/driver/Proxy.php +++ b/driver/Proxy.php @@ -38,7 +38,7 @@ public function processCloudMessage(array $tokens, string $title, string $body, 'imageUrl' => $imageUrl, 'iconUrl' => SiteIcon::getUrl(180), 'url' => $url, - 'notificationCount' => $notificationCount + 'notificationCount' => $notificationCount, ]; $response = $this->post('/push', $data)->send(); @@ -63,4 +63,4 @@ public function getSenderId(): string return $module->humhubProxySenderId; } -} \ No newline at end of file +} diff --git a/helpers/MobileAppHelper.php b/helpers/MobileAppHelper.php index 277847d..df9ed5f 100644 --- a/helpers/MobileAppHelper.php +++ b/helpers/MobileAppHelper.php @@ -73,7 +73,7 @@ public static function isAppWithCustomFcm(): bool Yii::$app->request->headers->has('x-humhub-app-bundle-id') && !str_contains( Yii::$app->request->headers->get('x-humhub-app-bundle-id', '', true), - 'com.humhub.app' + 'com.humhub.app', ) ); diff --git a/migrations/m190819_210853_initial.php b/migrations/m190819_210853_initial.php index cca05d1..bb51de6 100644 --- a/migrations/m190819_210853_initial.php +++ b/migrations/m190819_210853_initial.php @@ -17,7 +17,7 @@ public function safeUp() 'token' => $this->string(255), 'user_id' => $this->integer()->notNull(), 'created_at' => $this->dateTime()->defaultValue(new \yii\db\Expression('NOW()')), - 'updated_at' => $this->dateTime() + 'updated_at' => $this->dateTime(), ]); $this->addForeignKey('f_user', 'fcmpush_user', 'user_id', 'user', 'id', 'CASCADE', 'CASCADE'); diff --git a/models/FcmUser.php b/models/FcmUser.php index abbc2ff..581fd9f 100644 --- a/models/FcmUser.php +++ b/models/FcmUser.php @@ -19,7 +19,6 @@ */ class FcmUser extends ActiveRecord { - /** * @inheritDoc */ @@ -63,4 +62,4 @@ public function getUser() return $this->hasOne(User::class, ['id' => 'user_id']); } -} \ No newline at end of file +} diff --git a/services/DriverService.php b/services/DriverService.php index baf1dc5..1ee4789 100644 --- a/services/DriverService.php +++ b/services/DriverService.php @@ -103,4 +103,4 @@ private function getConfiguredDriverByType(string $class): ?DriverInterface } -} \ No newline at end of file +} diff --git a/services/MessagingService.php b/services/MessagingService.php index c7823ef..401c9af 100644 --- a/services/MessagingService.php +++ b/services/MessagingService.php @@ -31,7 +31,7 @@ public function processNotification(BaseNotification $baseNotification, User $us $baseNotification->text(), Url::to(['/notification/entry', 'id' => $baseNotification->record->id], true), null, - NotificationHumHub::findUnseen($user)->count() + NotificationHumHub::findUnseen($user)->count(), ); } @@ -47,4 +47,4 @@ public function processMessage(User $user, string $title, string $body, ?string } } -} \ No newline at end of file +} diff --git a/services/TokenService.php b/services/TokenService.php index 38a1e9b..7a51131 100644 --- a/services/TokenService.php +++ b/services/TokenService.php @@ -52,4 +52,4 @@ public function deleteToken(string $token): bool return false; } -} \ No newline at end of file +} diff --git a/widgets/PushNotificationInfoWidget.php b/widgets/PushNotificationInfoWidget.php index 7ba846c..812f32c 100644 --- a/widgets/PushNotificationInfoWidget.php +++ b/widgets/PushNotificationInfoWidget.php @@ -1,12 +1,12 @@ render('push-notification-info'); } -} \ No newline at end of file +}