From 1dddd4713d75013ec91d3ed91a827fb358589a2a Mon Sep 17 00:00:00 2001 From: cgoIT Date: Wed, 4 Sep 2024 20:48:55 +0200 Subject: [PATCH] chore: fix ecs bugs --- src/Classes/Utils.php | 24 +++++++++---------- .../DataContainer/CalendarEventsCallbacks.php | 4 ---- src/Widget/TimePeriodExt.php | 6 ++--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/Classes/Utils.php b/src/Classes/Utils.php index ec8d44a..cb1ab5f 100644 --- a/src/Classes/Utils.php +++ b/src/Classes/Utils.php @@ -76,12 +76,12 @@ public static function getUntilAndRecurring(CalendarEventsModel $objEvent, PageM $arrFixedDates = StringUtil::deserialize($objEvent->repeatFixedDates); if (!empty($arrFixedDates) && \is_array($arrFixedDates)) { - $until = ' '.sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); + $until = ' '.\sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); $arrFixedDates = array_map(static fn ($val) => Date::parse($objPage->dateFormat, $val), array_column($arrFixedDates, 'new_repeat')); $strDates = self::implodeFixedDates($arrFixedDates); - $recurring = sprintf($GLOBALS['TL_LANG']['tl_calendar_events']['cal_repeat_fixed_dates'], $strDates, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : '')); + $recurring = \sprintf($GLOBALS['TL_LANG']['tl_calendar_events']['cal_repeat_fixed_dates'], $strDates, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : '')); } } elseif (!empty($objEvent->recurringExt)) { $arrRange = StringUtil::deserialize($objEvent->repeatEachExt, true); @@ -92,15 +92,15 @@ public static function getUntilAndRecurring(CalendarEventsModel $objEvent, PageM $repeat = $GLOBALS['TL_LANG']['tl_calendar_events'][$arg].' '.$GLOBALS['TL_LANG']['tl_calendar_events'][$unit]; if ($objEvent->recurrences > 0) { - $until = ' '.sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); + $until = ' '.\sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); } if ($objEvent->recurrences > 0 && $objEvent->repeatEnd <= time()) { - $recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat_ended'], $repeat, $until); + $recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat_ended'], $repeat, $until); } elseif ($objEvent->addTime) { - $recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : '')); + $recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : '')); } else { - $recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d', $intStartTime), $strDate); + $recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d', $intStartTime), $strDate); } } } elseif (!empty($objEvent->recurring)) { @@ -110,19 +110,19 @@ public static function getUntilAndRecurring(CalendarEventsModel $objEvent, PageM if (1 === $arrRange['value']) { $repeat = $GLOBALS['TL_LANG']['MSC']['cal_single_'.$arrRange['unit']]; } else { - $repeat = sprintf($GLOBALS['TL_LANG']['MSC']['cal_multiple_'.$arrRange['unit']], $arrRange['value']); + $repeat = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_multiple_'.$arrRange['unit']], $arrRange['value']); } if ($objEvent->recurrences > 0) { - $until = ' '.sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); + $until = ' '.\sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd)); } if ($objEvent->recurrences > 0 && $objEvent->repeatEnd <= time()) { - $recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat_ended'], $repeat, $until); + $recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat_ended'], $repeat, $until); } elseif ($objEvent->addTime) { - $recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : '')); + $recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : '')); } else { - $recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d', $intStartTime), $strDate); + $recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d', $intStartTime), $strDate); } } } @@ -194,7 +194,7 @@ private static function implodeFixedDates(array|null $arrFixedDates): string $arrFixedDates = \array_slice($arrFixedDates, 0, 4); return implode(', ', $arrFixedDates).' '. - sprintf($cntOtherDates > 1 ? $GLOBALS['TL_LANG']['MSC']['count_other_dates_plural'] : $GLOBALS['TL_LANG']['MSC']['count_other_dates_singular'], $cntOtherDates); + \sprintf($cntOtherDates > 1 ? $GLOBALS['TL_LANG']['MSC']['count_other_dates_plural'] : $GLOBALS['TL_LANG']['MSC']['count_other_dates_singular'], $cntOtherDates); } if (1 === \count($arrFixedDates)) { return $arrFixedDates[0]; diff --git a/src/EventListener/DataContainer/CalendarEventsCallbacks.php b/src/EventListener/DataContainer/CalendarEventsCallbacks.php index 3e3444d..5d8bdff 100644 --- a/src/EventListener/DataContainer/CalendarEventsCallbacks.php +++ b/src/EventListener/DataContainer/CalendarEventsCallbacks.php @@ -206,8 +206,6 @@ public function checkRecurring(mixed $value, DataContainer $dc): mixed $activeRecord->recurring = false; // @phpstan-ignore-line $this->redirect($this->addToUrl($this->requestStack->getCurrentRequest()->getUri())); - - return false; } return $value; @@ -227,8 +225,6 @@ public function checkRecurringExt(mixed $value, DataContainer $dc): mixed $activeRecord->recurringExt = false; // @phpstan-ignore-line $this->redirect($this->addToUrl($this->requestStack->getCurrentRequest()->getUri())); - - return false; } return $value; diff --git a/src/Widget/TimePeriodExt.php b/src/Widget/TimePeriodExt.php index f020f8e..97ce8ac 100644 --- a/src/Widget/TimePeriodExt.php +++ b/src/Widget/TimePeriodExt.php @@ -100,7 +100,7 @@ public function generate() } foreach ($this->arrValues as $arrValue) { - $arrValues[] = sprintf( + $arrValues[] = \sprintf( '', StringUtil::specialchars($arrValue['value']), $this->isSelectedExt($arrValue, 'value'), @@ -113,7 +113,7 @@ public function generate() } foreach ($this->arrUnits as $arrUnit) { - $arrUnits[] = sprintf( + $arrUnits[] = \sprintf( '', StringUtil::specialchars($arrUnit['value']), $this->isSelectedExt($arrUnit, 'unit'), @@ -125,7 +125,7 @@ public function generate() $this->varValue = ['value' => $this->varValue]; } - return sprintf( + return \sprintf( ' %s', $this->strName, $this->getAttribute('disabled'),