Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PHP CS Fixer #489

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public static function onCronRun($event)
} catch (\Throwable $e) {
Yii::error($e);
$controller->stdout('error.' . PHP_EOL, Console::FG_RED);
$controller->stderr("\n".$e->getTraceAsString()."\n", Console::BOLD);
$controller->stderr("\n" . $e->getTraceAsString() . "\n", Console::BOLD);
}
$module->settings->set('lastReminderRunTS', time());
}
Expand Down
1 change: 0 additions & 1 deletion activities/ResponseAttend.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
class ResponseAttend extends BaseActivity implements ConfigurableActivityInterface
{

public $viewName = 'response_attend';
public $moduleId = 'calendar';

Expand Down
1 change: 0 additions & 1 deletion activities/ResponseDeclined.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
class ResponseDeclined extends BaseActivity implements ConfigurableActivityInterface
{

public $viewName = 'response_declined';
public $moduleId = 'calendar';

Expand Down
1 change: 0 additions & 1 deletion activities/ResponseInvited.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
class ResponseInvited extends BaseActivity implements ConfigurableActivityInterface
{

public $viewName = 'response_invited';
public $moduleId = 'calendar';

Expand Down
10 changes: 5 additions & 5 deletions assets/CalendarAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ class CalendarAsset extends AssetBundle
public $defer = true;

public $publishOptions = [
'forceCopy' => false
'forceCopy' => false,
];

public $sourcePath = '@calendar/resources/js';

public $js = [
'humhub.calendar.Calendar.min.js'
'humhub.calendar.Calendar.min.js',
];

public $depends = [
FullCalendarAssets::class,
CalendarBaseAssets::class
CalendarBaseAssets::class,
];

/**
Expand All @@ -44,7 +44,7 @@ public static function register($view)
'button.week' => Yii::t('CalendarModule.calendar', 'Week'),
'button.day' => Yii::t('CalendarModule.calendar', 'Day'),
'button.list' => Yii::t('CalendarModule.calendar', 'List'),
]
],
]);
return parent::register($view);
}
Expand Down
6 changes: 3 additions & 3 deletions assets/CalendarBaseAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class CalendarBaseAssets extends AssetBundle
public $defer = true;

public $publishOptions = [
'forceCopy' => false
'forceCopy' => false,
];

public $sourcePath = '@calendar/resources';

public $css = [
'css/calendar.min.css',
];

public $js = [
'js/humhub.calendar.min.js'
'js/humhub.calendar.min.js',
];
}
2 changes: 1 addition & 1 deletion assets/FullCalendarAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FullCalendarAssets extends AssetBundle
public $defer = true;

public $publishOptions = ['forceCopy' => false];

public $sourcePath = '@calendar/resources';

public $css = ['css/fullcalendar.bundle.min.css'];
Expand Down
2 changes: 1 addition & 1 deletion assets/ParticipationFormAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ParticipationFormAssets extends AssetBundle
* @inheritdoc
*/
public $publishOptions = [
'forceCopy' => false
'forceCopy' => false,
];

/**
Expand Down
4 changes: 2 additions & 2 deletions assets/RecurrenceFormAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class RecurrenceFormAssets extends AssetBundle
public $defer = true;

public $publishOptions = [
'forceCopy' => false
'forceCopy' => false,
];

public $sourcePath = '@calendar/resources';

public $js = [
Expand Down
4 changes: 2 additions & 2 deletions assets/ReminderFormAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class ReminderFormAssets extends AssetBundle
public $defer = true;

public $publishOptions = [
'forceCopy' => false
'forceCopy' => false,
];

public $sourcePath = '@calendar/resources';

public $js = [
Expand Down
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
['class' => ProfileMenu::class, 'event' => ProfileMenu::EVENT_INIT, 'callback' => [Events::class, 'onProfileMenuInit']],
['class' => SpaceSidebar::class, 'event' => SpaceSidebar::EVENT_INIT, 'callback' => [Events::class, 'onSpaceSidebarInit']],
['class' => ProfileSidebar::class, 'event' => ProfileSidebar::EVENT_INIT, 'callback' => [Events::class, 'onProfileSidebarInit']],
['class' => DashboardSidebar::class, 'event' =>DashboardSidebar::EVENT_INIT, 'callback' => [Events::class, 'onDashboardSidebarInit']],
['class' => DashboardSidebar::class, 'event' => DashboardSidebar::EVENT_INIT, 'callback' => [Events::class, 'onDashboardSidebarInit']],
['class' => TopMenu::class, 'event' => TopMenu::EVENT_INIT, 'callback' => [Events::class, 'onTopMenuInit']],
['class' => 'humhub\modules\calendar\interfaces\CalendarService', 'event' => 'getItemTypes', 'callback' => [Events::class, 'onGetCalendarItemTypes']],
['class' => 'humhub\modules\calendar\interfaces\CalendarService', 'event' => 'findItems', 'callback' => [Events::class, 'onFindCalendarItems']],
Expand Down
16 changes: 8 additions & 8 deletions controllers/AbstractConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
*/
abstract class AbstractConfigController extends ContentContainerController
{
const VIEW_CONFIG_DEFAULT = '@calendar/views/common/defaultConfig';
const VIEW_CONFIG_TYPE = '@calendar/views/common/typesConfig';
const VIEW_CONFIG_EDIT_TYPE_MODAL = '@calendar/views/common/editTypeModal';
const VIEW_CONFIG_CALENDARS = '@calendar/views/common/calendarsConfig';
public const VIEW_CONFIG_DEFAULT = '@calendar/views/common/defaultConfig';
public const VIEW_CONFIG_TYPE = '@calendar/views/common/typesConfig';
public const VIEW_CONFIG_EDIT_TYPE_MODAL = '@calendar/views/common/editTypeModal';
public const VIEW_CONFIG_CALENDARS = '@calendar/views/common/calendarsConfig';

/**
* @var CalendarService
Expand Down Expand Up @@ -57,7 +57,7 @@ public function actionIndex()
}

return $this->render(static::VIEW_CONFIG_DEFAULT, [
'model' => $model
'model' => $model,
]);
}

Expand All @@ -68,13 +68,13 @@ public function actionTypes()
: CalendarEntryType::findGlobal();

$typeDataProvider = new ActiveDataProvider([
'query' => $query
'query' => $query,
]);

return $this->render(static::VIEW_CONFIG_TYPE, [
'typeDataProvider' => $typeDataProvider,
'createUrl' => URL::toCreateType($this->contentContainer),
'contentContainer' => $this->contentContainer
'contentContainer' => $this->contentContainer,
]);
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public function actionCalendars()
$types = $this->calendarService->getCalendarItemTypes($this->contentContainer);
return $this->render(static::VIEW_CONFIG_CALENDARS, [
'contentContainer' => $this->contentContainer,
'calendars' => $types
'calendars' => $types,
]);
}

Expand Down
6 changes: 3 additions & 3 deletions controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function actionSnippet()
}

return $this->render('snippet', [
'model' => $model
'model' => $model,
]);
}

Expand All @@ -53,8 +53,8 @@ public function actionMenu()
}

return $this->render('menu', [
'model' => $model
'model' => $model,
]);
}

}
}
6 changes: 3 additions & 3 deletions controllers/FullCalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public function getAccessRules()
return [
['login'],
['json'],
['post']
['post'],
];
}

public function actionUpdate($id)
{
$this->forcePostRequest();
Expand Down Expand Up @@ -67,4 +67,4 @@ public function actionUpdate($id)
return $this->asJson(['success' => false, 'error' => $result]);
}

}
}
13 changes: 7 additions & 6 deletions controllers/GlobalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GlobalController extends Controller
public function getAccessRules()
{
return [
['login' => ['enable', 'select']]
['login' => ['enable', 'select']],
];
}

Expand Down Expand Up @@ -84,7 +84,7 @@ public function actionIndex()
'selectors' => $this->getSelectorSettings(),
'filters' => $this->getFilterSettings(),
'canConfigure' => $moduleEnabled,
'editUrl' => Url::to(['/calendar/entry/edit'])
'editUrl' => Url::to(['/calendar/entry/edit']),
]);
}

Expand Down Expand Up @@ -141,9 +141,10 @@ public function actionSelect($start = null, $end = null)
$calendarMemberSpaceQuery = Membership::getUserSpaceQuery(Yii::$app->user->getIdentity());

if (!ContentContainerModuleManager::getDefaultState(Space::class, 'calendar')) {
$calendarMemberSpaceQuery->leftJoin('contentcontainer_module',
$calendarMemberSpaceQuery->leftJoin(
'contentcontainer_module',
'contentcontainer_module.module_id = :calendar AND contentcontainer_module.contentcontainer_id = space.contentcontainer_id',
[':calendar' => 'calendar']
[':calendar' => 'calendar'],
)->andWhere('contentcontainer_module.module_id IS NOT NULL')
->andWhere(['contentcontainer_module.module_state' => ContentContainerModuleState::STATE_ENABLED]);
}
Expand Down Expand Up @@ -254,7 +255,7 @@ public function actionEnable($start, $end)
'header' => Yii::t('CalendarModule.base', '<strong>Add</strong> profile calendar'),
'body' => Yii::t('CalendarModule.base', 'In order to add events to your profile, you have to enable the calendar module first.'),
'footer' => $enableButton . $nextButton . $cancelButton,
'centerText' => true
'centerText' => true,
]);
}

Expand All @@ -276,7 +277,7 @@ public function actionEnableConfig()
'header' => Yii::t('CalendarModule.base', '<strong>Add</strong> profile calendar'),
'body' => Yii::t('CalendarModule.base', 'Do you want to install this module on your profile?'),
'footer' => $enableButton . $nextButton . $cancelButton,
'centerText' => true
'centerText' => true,
]);
}

Expand Down
7 changes: 3 additions & 4 deletions controllers/IcalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@
use yii\web\HttpException;
use yii\web\NotFoundHttpException;


class IcalController extends Controller
{
/**
* @var CalendarService
*/
public $calendarService;

const EXPORT_MIME = 'text/calendar';
public const EXPORT_MIME = 'text/calendar';

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

Expand Down Expand Up @@ -58,7 +57,7 @@ public function actionExport($id)

$uid = $model->getUid() ?: $this->uniqueId;

return Yii::$app->response->sendContentAsFile($ics, $uid.'.ics', ['mimeType' => static::EXPORT_MIME]);
return Yii::$app->response->sendContentAsFile($ics, $uid . '.ics', ['mimeType' => static::EXPORT_MIME]);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions controllers/ReminderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ReminderController extends ContentContainerController
public function getAccessRules()
{
return [
[ControllerAccess::RULE_LOGGED_IN_ONLY]
[ControllerAccess::RULE_LOGGED_IN_ONLY],
];
}

Expand Down Expand Up @@ -54,12 +54,12 @@ public function actionSet($id)
throw new HttpException(400);
}

$reminderSettings = new ReminderSettings(['entry' =>$model, 'user' => Yii::$app->user->getIdentity()]);
$reminderSettings = new ReminderSettings(['entry' => $model, 'user' => Yii::$app->user->getIdentity()]);

if($reminderSettings->load(Yii::$app->request->post()) && $reminderSettings->save()) {
return ModalClose::widget(['saved' => true]);
}

return $this->renderAjax('userLevelReminder', ['reminderSettings' => $reminderSettings]);
}
}
}
3 changes: 1 addition & 2 deletions controllers/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/
class ViewController extends ContentContainerController
{

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -75,7 +74,7 @@ public function actionLoadAjax($start, $end)
// Don't expand recurrence event on filter by "I'm attending" because this option is selected per each date separately
$expand = !in_array(AbstractCalendarQuery::FILTER_PARTICIPATE, $filters);

foreach ($this->calendarService->getCalendarItems( new DateTime($start), new DateTime($end), $filters, $this->contentContainer, null, $expand, $types) as $entry) {
foreach ($this->calendarService->getCalendarItems(new DateTime($start), new DateTime($end), $filters, $this->contentContainer, null, $expand, $types) as $entry) {
$result[] = FullCalendar::getFullCalendarArray($entry);
}

Expand Down
10 changes: 5 additions & 5 deletions controllers/rest/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ public function actionRespond($id)
}

if (! in_array((int)$respondType, [
CalendarEntryParticipant::PARTICIPATION_STATE_NONE,
CalendarEntryParticipant::PARTICIPATION_STATE_DECLINED,
CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE,
CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED,
], true)) {
CalendarEntryParticipant::PARTICIPATION_STATE_NONE,
CalendarEntryParticipant::PARTICIPATION_STATE_DECLINED,
CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE,
CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED,
], true)) {
return $this->returnError(400, 'Invalid respond type');
}

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
=========

1.5.13 (Unreleased)
----------------------
- Enh #489: Use PHP CS Fixer

1.5.12 (June 25, 2024)
----------------------
- Fix #487: Base event notification broken
Expand Down
Loading