Skip to content

Commit

Permalink
chore: updating code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavs-gutmanis committed May 21, 2022
1 parent fe8e8ad commit 97d842e
Show file tree
Hide file tree
Showing 36 changed files with 166 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
if (class_exists('craft\feedme\base\Element')) {
class CalendarIntegration extends Element
{
const RRULE_MAP = [
public const RRULE_MAP = [
'BYMONTH' => 'byMonth',
'BYYEARDAY' => 'byYearDay',
'BYMONTHDAY' => 'byMonthDay',
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Bundles/GraphQL/GqlPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class GqlPermissions extends Gql
{
const CATEGORY_CALENDARS = 'Calendars';
public const CATEGORY_CALENDARS = 'Calendars';

public static function canQueryCalendars(): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public static function getType($fields = null): Type

/**
* Return conditional fields for this type.
*
* @return array
*/
*/
protected static function getConditionalFields(): array
{
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Solspace\Calendar\Bundles\GraphQL\Types\Generators;

use craft\gql\GqlEntityRegistry;
use craft\gql\TypeManager;
use craft\helpers\Gql;
use Solspace\Calendar\Bundles\GraphQL\Arguments\EventArguments;
use Solspace\Calendar\Bundles\GraphQL\Interfaces\EventInterface;
Expand Down
50 changes: 23 additions & 27 deletions packages/plugin/src/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,36 @@
*/
class Calendar extends Plugin
{
const TRANSLATION_CATEGORY = 'calendar';
public const TRANSLATION_CATEGORY = 'calendar';

const FIELD_LAYOUT_TYPE = 'Calendar_Event';
public const FIELD_LAYOUT_TYPE = 'Calendar_Event';

const VIEW_MONTH = 'month';
const VIEW_WEEK = 'week';
const VIEW_DAY = 'day';
const VIEW_EVENTS = 'events';
const VIEW_CALENDARS = 'calendars';
const VIEW_RESOURCES = 'resources';
public const VIEW_MONTH = 'month';
public const VIEW_WEEK = 'week';
public const VIEW_DAY = 'day';
public const VIEW_EVENTS = 'events';
public const VIEW_CALENDARS = 'calendars';
public const VIEW_RESOURCES = 'resources';

const PERMISSION_CALENDARS = 'calendar-manageCalendars';
const PERMISSION_CREATE_CALENDARS = 'calendar-createCalendars';
const PERMISSION_EDIT_CALENDARS = 'calendar-editCalendars';
const PERMISSION_DELETE_CALENDARS = 'calendar-deleteCalendars';
const PERMISSION_EVENTS = 'calendar-manageEvents';
const PERMISSION_EVENTS_FOR = 'calendar-manageEventsFor';
const PERMISSION_EVENTS_FOR_ALL = 'calendar-manageEventsFor:all';
const PERMISSION_SETTINGS = 'calendar-settings';
const PERMISSION_RESOURCES = 'calendar-resources';
public const PERMISSION_CALENDARS = 'calendar-manageCalendars';
public const PERMISSION_CREATE_CALENDARS = 'calendar-createCalendars';
public const PERMISSION_EDIT_CALENDARS = 'calendar-editCalendars';
public const PERMISSION_DELETE_CALENDARS = 'calendar-deleteCalendars';
public const PERMISSION_EVENTS = 'calendar-manageEvents';
public const PERMISSION_EVENTS_FOR = 'calendar-manageEventsFor';
public const PERMISSION_EVENTS_FOR_ALL = 'calendar-manageEventsFor:all';
public const PERMISSION_SETTINGS = 'calendar-settings';
public const PERMISSION_RESOURCES = 'calendar-resources';

const PERMISSIONS_HELP_LINK = 'https://docs.solspace.com/craft/calendar/v2/setup/demo-templates.html';
public const PERMISSIONS_HELP_LINK = 'https://docs.solspace.com/craft/calendar/v2/setup/demo-templates.html';

const EDITION_LITE = 'lite';
const EDITION_PRO = 'pro';
public const EDITION_LITE = 'lite';
public const EDITION_PRO = 'pro';

const CONFIG_PATH_ROOT = 'solspace.calendar';
const CONFIG_CALENDAR_PATH = 'solspace.calendar.calendars';
const CONFIG_CALENDAR_SITES_PATH = 'solspace.calendar.calendar-sites';
public const CONFIG_PATH_ROOT = 'solspace.calendar';
public const CONFIG_CALENDAR_PATH = 'solspace.calendar.calendars';
public const CONFIG_CALENDAR_SITES_PATH = 'solspace.calendar.calendar-sites';

/** @var bool */
public bool $hasCpSettings = true;

/** @var array */
Expand Down Expand Up @@ -242,9 +241,6 @@ public static function getInstance(): self
return parent::getInstance();
}

/**
* @return null|array
*/
public function getCpNavItem(): ?array
{
$navItem = parent::getCpNavItem();
Expand Down
14 changes: 7 additions & 7 deletions packages/plugin/src/Controllers/CalendarsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use craft\records\Field;
use Solspace\Calendar\Calendar;
use Solspace\Calendar\Elements\Event;
use Solspace\Calendar\Library\ColorHelper;
use Solspace\Calendar\Library\DateHelper;
use Solspace\Calendar\Models\CalendarModel;
use Solspace\Calendar\Models\CalendarSiteSettingsModel;
Expand Down Expand Up @@ -113,13 +112,13 @@ public function actionDuplicate(): Response
$oldLayoutTabs = $oldLayout->getTabs();

foreach ($oldLayoutTabs as $oldLayoutTab) {
$newLayoutTab = new FieldLayoutTab();
$newLayoutTab->name = $oldLayoutTab->name;
$newLayoutTab->sortOrder = $oldLayoutTab->sortOrder;
$newLayoutTab->setLayout($newLayout);
$newLayoutTab->setElements($oldLayoutTab->getElements());
$newLayoutTab = new FieldLayoutTab();
$newLayoutTab->name = $oldLayoutTab->name;
$newLayoutTab->sortOrder = $oldLayoutTab->sortOrder;
$newLayoutTab->setLayout($newLayout);
$newLayoutTab->setElements($oldLayoutTab->getElements());

$newLayoutTabs[] = $newLayoutTab;
$newLayoutTabs[] = $newLayoutTab;
}

$newLayout->setTabs($newLayoutTabs);
Expand Down Expand Up @@ -210,6 +209,7 @@ public function actionSaveCalendar(): Response

if ($fieldLayout) {
$fieldHandles = [];

/** @var Field $field */
foreach ($fieldLayout->getCustomFields() as $field) {
$fieldHandles[] = $field->handle;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Controllers/CodePackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class CodePackController extends BaseController
{
const FLASH_VAR_KEY = 'codepack_prefix';
public const FLASH_VAR_KEY = 'codepack_prefix';

/**
* @throws \yii\web\ForbiddenHttpException
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin/src/Controllers/EventsApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class EventsApiController extends BaseController
{
const EVENT_FIELD_NAME = 'calendarEvent';
public const EVENT_FIELD_NAME = 'calendarEvent';

public array|bool|int $allowAnonymous = true;

Expand All @@ -35,7 +35,7 @@ public function actionModifyDate(): Response
* @var int $deltaSeconds
* @var bool $isAllDay
*/
list($event, $deltaSeconds, $isAllDay) = $this->validateAndReturnModificationData();
[$event, $deltaSeconds, $isAllDay] = $this->validateAndReturnModificationData();

$eventsService = $this->getEventsService();

Expand Down Expand Up @@ -146,7 +146,7 @@ public function actionModifyDuration(): Response
* @var Event $event
* @var \DateInterval $interval
*/
list($event, $deltaSeconds) = $this->validateAndReturnModificationData();
[$event, $deltaSeconds] = $this->validateAndReturnModificationData();

$event->getEndDate()->addSeconds($deltaSeconds);

Expand Down
8 changes: 4 additions & 4 deletions packages/plugin/src/Controllers/EventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

class EventsController extends BaseController
{
const EVENT_FIELD_NAME = 'calendarEvent';
const EVENT_PREVIEW_EVENT = 'previewEvent';
public const EVENT_FIELD_NAME = 'calendarEvent';
public const EVENT_PREVIEW_EVENT = 'previewEvent';

protected array|bool|int $allowAnonymous = ['save-event', 'view-shared-event'];

Expand Down Expand Up @@ -288,7 +288,7 @@ public function actionDeleteEvent()

$event = $this->getEventsService()->getEventById($eventId, null, true);

if (! $event) {
if (!$event) {
return false;
}

Expand Down Expand Up @@ -428,7 +428,7 @@ private function renderEditForm(Event $event, string $title): Response

// Enable Live Preview?
$showPreviewButton = false;
if (!\Craft::$app->getRequest()->isMobileBrowser(true) && $this->getCalendarService()->isEventTemplateValid($calendar, $event->siteId) && ! is_null($event->id)) {
if (!\Craft::$app->getRequest()->isMobileBrowser(true) && $this->getCalendarService()->isEventTemplateValid($calendar, $event->siteId) && null !== $event->id) {
$previewUrl = $event->getUrl();
$this->getView()->registerJs('Craft.LivePreview.init('.Json::encode([
'fields' => '#title-field, #event-builder-data, #event-builder, #fields .calendar-event-wrapper > .field, #fields > .field > .field, #fields > .flex-fields > .field',
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Controllers/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function actionTargetTime(
$month = null,
$day = null
): Response {
$view = $view ?? Calendar::VIEW_MONTH;
$view ??= Calendar::VIEW_MONTH;
$calendarView = $view;

if (Calendar::VIEW_WEEK === $calendarView) {
Expand Down
23 changes: 9 additions & 14 deletions packages/plugin/src/Elements/Db/EventQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

class EventQuery extends ElementQuery implements \Countable
{
const MAX_EVENT_LENGTH_DAYS = 365;
public const MAX_EVENT_LENGTH_DAYS = 365;

const TARGET_MONTH = 'Month';
const TARGET_WEEK = 'Week';
const TARGET_DAY = 'Day';
public const TARGET_MONTH = 'Month';
public const TARGET_WEEK = 'Week';
public const TARGET_DAY = 'Day';

/** @var int */
public $typeId;
Expand Down Expand Up @@ -539,12 +539,7 @@ public function all($db = null): array
return $this->events;
}

/**
* @param int $n
* @param Connection|null $db
* @return array|\yii\base\Model|null
*/
public function nth(int $n, ?\yii\db\Connection $db = null): array|null|\yii\base\Model
public function nth(int $n, ?Connection $db = null): array|null|\yii\base\Model
{
$this->all($db);

Expand All @@ -556,7 +551,7 @@ public function nth(int $n, ?\yii\db\Connection $db = null): array|null|\yii\bas
*
* @return int[]
*/
public function ids(?\yii\db\Connection $db = null): array
public function ids(?Connection $db = null): array
{
$events = $this->all($db);

Expand Down Expand Up @@ -1002,7 +997,7 @@ private function cacheRecurringEvents(array $foundIds)
* @var Carbon $occurrenceStartDate
* @var Carbon $occurrenceEndDate
*/
list($occurrenceStartDate, $occurrenceEndDate) = DateHelper::getRelativeEventDates(
[$occurrenceStartDate, $occurrenceEndDate] = DateHelper::getRelativeEventDates(
$startDateCarbon,
$endDateCarbon,
$date
Expand Down Expand Up @@ -1057,7 +1052,7 @@ private function cacheRecurringEvents(array $foundIds)
* @var Carbon $occurrenceStartDate
* @var Carbon $occurrenceEndDate
*/
list($occurrenceStartDate, $occurrenceEndDate) = DateHelper::getRelativeEventDates(
[$occurrenceStartDate, $occurrenceEndDate] = DateHelper::getRelativeEventDates(
$startDateCarbon,
$endDateCarbon,
$occurrence
Expand Down Expand Up @@ -1229,7 +1224,7 @@ function ($data) {
* @var Carbon $date
* @var int $eventId
*/
foreach ($this->eventCache as list($date, $eventId)) {
foreach ($this->eventCache as [$date, $eventId]) {
if (!isset($eventsById[$eventId])) {
continue;
}
Expand Down
Loading

0 comments on commit 97d842e

Please sign in to comment.