From 64f76e63791c84276d70a0a0e0096ec31ad48230 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Fri, 23 Feb 2024 08:26:50 +0100 Subject: [PATCH] Code Quality --- src/EventListener/AbstractTableListener.php | 4 +--- .../BackendView/ParentChildViewListener.php | 8 ++++---- .../DataContainer/MissingLanguageIconListener.php | 3 ++- .../DataContainer/PageFieldsListener.php | 11 ++--------- .../Navigation/AbstractNavigationListener.php | 3 ++- src/Helper/LanguageText.php | 2 ++ src/Navigation/UrlParameterBag.php | 2 -- 7 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/EventListener/AbstractTableListener.php b/src/EventListener/AbstractTableListener.php index d58e964..b60d91b 100644 --- a/src/EventListener/AbstractTableListener.php +++ b/src/EventListener/AbstractTableListener.php @@ -15,10 +15,8 @@ public function __construct(string $table) /** * Register necessary callbacks for this listener. - * - * @return void */ - abstract public function register(); + abstract public function register(): void; /** * Gets the table name for this listener. diff --git a/src/EventListener/BackendView/ParentChildViewListener.php b/src/EventListener/BackendView/ParentChildViewListener.php index b185bea..24baf09 100644 --- a/src/EventListener/BackendView/ParentChildViewListener.php +++ b/src/EventListener/BackendView/ParentChildViewListener.php @@ -24,10 +24,10 @@ class ParentChildViewListener extends AbstractViewListener protected function isSupported() { return $this->getTable() === Input::get('table') && ( - ('news' === Input::get('do') && InstalledVersions::isInstalled('contao/news-bundle')) - || ('calendar' === Input::get('do') && InstalledVersions::isInstalled('contao/calendar-bundle')) - || ('faq' === Input::get('do') && InstalledVersions::isInstalled('contao/faq-bundle')) - ); + ('news' === Input::get('do') && InstalledVersions::isInstalled('contao/news-bundle')) + || ('calendar' === Input::get('do') && InstalledVersions::isInstalled('contao/calendar-bundle')) + || ('faq' === Input::get('do') && InstalledVersions::isInstalled('contao/faq-bundle')) + ); } protected function getCurrentPage() diff --git a/src/EventListener/DataContainer/MissingLanguageIconListener.php b/src/EventListener/DataContainer/MissingLanguageIconListener.php index 36a71f5..f0e2106 100644 --- a/src/EventListener/DataContainer/MissingLanguageIconListener.php +++ b/src/EventListener/DataContainer/MissingLanguageIconListener.php @@ -211,7 +211,8 @@ private function generateLabelWithWarning($label, $imgStyle = '') ); } - private static function getCallbacks(): array { + private static function getCallbacks(): array + { if (null !== self::$callbacks) { return self::$callbacks; } diff --git a/src/EventListener/DataContainer/PageFieldsListener.php b/src/EventListener/DataContainer/PageFieldsListener.php index 35e58d8..1fef8c3 100644 --- a/src/EventListener/DataContainer/PageFieldsListener.php +++ b/src/EventListener/DataContainer/PageFieldsListener.php @@ -16,10 +16,6 @@ class PageFieldsListener /** * Sets rootNodes when initializing the languageMain field. * - * @param mixed $value - * - * @return mixed - * * @Callback(table="tl_page", target="fields.languageMain.load") */ public function onLoadLanguageMain($value, DataContainer $dc) @@ -55,15 +51,12 @@ public function onLoadLanguageMain($value, DataContainer $dc) /** * Validate input value when saving tl_page.languageMain field. * - * @param mixed $value - * - * @return mixed - * * @Callback(table="tl_page", target="fields.languageMain.save") */ public function onSaveLanguageMain($value, DataContainer $dc) { - // Validate that there is no other page in the current page tree with the same languageMain assigned + // Validate that there is no other page in the current page tree with the same + // languageMain assigned if ($value > 0) { $currentPage = PageModel::findWithDetails($dc->id); $childIds = Database::getInstance()->getChildRecords($currentPage->rootId, 'tl_page'); diff --git a/src/EventListener/Navigation/AbstractNavigationListener.php b/src/EventListener/Navigation/AbstractNavigationListener.php index 468f05f..0932ace 100644 --- a/src/EventListener/Navigation/AbstractNavigationListener.php +++ b/src/EventListener/Navigation/AbstractNavigationListener.php @@ -42,7 +42,8 @@ public function onChangelanguageNavigation(ChangelanguageNavigationEvent $event) return; } - // Remove the news/event/faq alias from the URL if there is no actual reader page assigned + // Remove the news/event/faq alias from the URL if there is no actual + // reader page assigned if (!$navigationItem->isDirectFallback()) { $event->getUrlParameterBag()->removeUrlAttribute($this->getUrlKey()); } diff --git a/src/Helper/LanguageText.php b/src/Helper/LanguageText.php index 4fb4235..b6afcc4 100644 --- a/src/Helper/LanguageText.php +++ b/src/Helper/LanguageText.php @@ -84,6 +84,8 @@ static function (NavigationItem $a, NavigationItem $b) use ($languages) { /** * Create instance from serialized data of optionsWizard widget. + * + * @param string|array|null $config */ public static function createFromOptionWizard($config): self { diff --git a/src/Navigation/UrlParameterBag.php b/src/Navigation/UrlParameterBag.php index 73867c2..a10e82b 100644 --- a/src/Navigation/UrlParameterBag.php +++ b/src/Navigation/UrlParameterBag.php @@ -168,8 +168,6 @@ public function generateQueryString(): ?string /** * Makes sure the given value is scalar or an array of scalar values. - * - * @param mixed $value */ private function validateScalar($value): void {