Skip to content

Commit

Permalink
Merge pull request #52 from humhub/enh/php-cs-fixer
Browse files Browse the repository at this point in the history
Use PHP CS Fixer
  • Loading branch information
luke- authored Oct 3, 2024
2 parents 74258c9 + cd397d7 commit 95ec401
Show file tree
Hide file tree
Showing 25 changed files with 95 additions and 92 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:
fixers:
uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main
5 changes: 2 additions & 3 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +20,6 @@

class Events
{

private const SESSION_VAR_LOGOUT = 'mobileAppHandleLogout';
private const SESSION_VAR_LOGIN = 'mobileAppHandleLogin';

Expand Down Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

class Module extends \humhub\components\Module
{

/**
* @inheritdoc
*/
Expand Down
5 changes: 2 additions & 3 deletions commands/SendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class SendController extends \yii\console\Controller
{

public function actionSendToUser($userId, $title, $message)
{
/** @var Module $module */
Expand All @@ -23,7 +22,7 @@ public function actionSendToUser($userId, $title, $message)
$message,
null,
null,
null
null,
);
}
}
}
2 changes: 1 addition & 1 deletion components/NotificationTargetProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ public function isActive(User $user = null)

return true;
}
}
}
6 changes: 3 additions & 3 deletions components/SendReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

class SendReport
{
const STATE_SUCCESS = 1;
const STATE_ERROR = 2;
public const STATE_SUCCESS = 1;
public const STATE_ERROR = 2;

public $failedTokens = [];

public function __construct($state, $failedTokens = [])
{

}
}
}
80 changes: 40 additions & 40 deletions components/UrlRule.php
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\fcmPush\components;

use humhub\modules\fcmPush\services\WellKnownService;
use yii\base\Component;
use yii\web\UrlRuleInterface;

class UrlRule extends Component implements UrlRuleInterface
{
/**
* @inheritdoc
*/
public function createUrl($manager, $route, $params)
{
if ($route === trim(WellKnownService::URL_ROUTE, '/') && isset($params['file'])) {
return WellKnownService::URL_PREFIX . $params['file'];
}

return false;
}

/**
* @inheritdoc
*/
public function parseRequest($manager, $request)
{
$path = $request->getPathInfo();
if (str_starts_with($path, WellKnownService::URL_PREFIX)) {
return WellKnownService::instance($path)->getRuleRoute() ?? false;
}

return false;
}
}
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\fcmPush\components;

use humhub\modules\fcmPush\services\WellKnownService;
use yii\base\Component;
use yii\web\UrlRuleInterface;

class UrlRule extends Component implements UrlRuleInterface
{
/**
* @inheritdoc
*/
public function createUrl($manager, $route, $params)
{
if ($route === trim(WellKnownService::URL_ROUTE, '/') && isset($params['file'])) {
return WellKnownService::URL_PREFIX . $params['file'];
}

return false;
}

/**
* @inheritdoc
*/
public function parseRequest($manager, $request)
{
$path = $request->getPathInfo();
if (str_starts_with($path, WellKnownService::URL_PREFIX)) {
return WellKnownService::instance($path)->getRuleRoute() ?? false;
}

return false;
}
}
1 change: 0 additions & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
class AdminController extends Controller
{

public function actionIndex()
{

Expand All @@ -27,4 +26,4 @@ public function actionIndex()
return $this->render('index', ['model' => $model]);
}

}
}
2 changes: 0 additions & 2 deletions controllers/MobileAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,7 +10,6 @@

class MobileAppController extends Controller
{

/**
* Renders the index view for the module
*
Expand Down
6 changes: 3 additions & 3 deletions controllers/StatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions controllers/TokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
)
),
]);
}
Expand All @@ -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'),
)
),
]);
}
Expand All @@ -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'),
)
),
]);
}
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public function processCloudMessage(array $tokens, string $title, string $body,
public function getSenderId(): string;

public function isConfigured(): bool;
}
}
4 changes: 2 additions & 2 deletions driver/Fcm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -67,4 +67,4 @@ public function isConfigured(): bool
{
return (!empty($this->config->json) && !empty($this->config->senderId));
}
}
}
8 changes: 4 additions & 4 deletions driver/FcmLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -64,4 +64,4 @@ public function getSenderId(): string
{
return $this->config->senderId;
}
}
}
4 changes: 2 additions & 2 deletions driver/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -63,4 +63,4 @@ public function getSenderId(): string

return $module->humhubProxySenderId;
}
}
}
2 changes: 1 addition & 1 deletion helpers/MobileAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
);

Expand Down
2 changes: 1 addition & 1 deletion migrations/m190819_210853_initial.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 1 addition & 2 deletions models/FcmUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
class FcmUser extends ActiveRecord
{

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -63,4 +62,4 @@ public function getUser()
return $this->hasOne(User::class, ['id' => 'user_id']);
}

}
}
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"humhub": {
"minVersion": "1.14"
},
"version": "2.0.7",
"version": "2.0.8",
"screenshots": [
"resources/screenshot1.PNG",
"resources/screenshot2.PNG"
Expand Down
2 changes: 1 addition & 1 deletion services/DriverService.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ private function getConfiguredDriverByType(string $class): ?DriverInterface
}


}
}
Loading

0 comments on commit 95ec401

Please sign in to comment.