From 4693b06ab6ab24ec95f146574ef0a94d5f8d1021 Mon Sep 17 00:00:00 2001 From: Susanne Moog <susanne.moog@typo3.org> Date: Sun, 8 Apr 2018 10:29:35 +0200 Subject: [PATCH] [TASK] Clean-up in site handling - add void return types - add access modifiers for constants - fix some null coalescing - remove superfluous comments - add newline before namespace Resolves: #84662 Releases: master Change-Id: I1288b27b1edbd99b0624a66a5fb01cd02547b5ec Reviewed-on: https://review.typo3.org/56602 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> --- .../Configuration/SiteTcaConfiguration.php | 1 + .../Form/FormDataProvider/SiteTcaInline.php | 5 +- .../Classes/Routing/PageUriBuilder.php | 5 +- .../sysext/core/Classes/Site/Entity/Site.php | 9 ++- .../core/Classes/Site/Entity/SiteLanguage.php | 3 +- typo3/sysext/core/Classes/Site/SiteFinder.php | 3 +- .../DefaultPHPErrorHandler.php | 81 ------------------- .../FluidPageErrorHandler.php | 1 + .../PageContentErrorHandler.php | 1 + 9 files changed, 17 insertions(+), 92 deletions(-) delete mode 100644 typo3/sysext/frontend/Classes/PageErrorHandler/DefaultPHPErrorHandler.php diff --git a/typo3/sysext/backend/Classes/Configuration/SiteTcaConfiguration.php b/typo3/sysext/backend/Classes/Configuration/SiteTcaConfiguration.php index 9347d2907d4b..1b32aeb37d1c 100644 --- a/typo3/sysext/backend/Classes/Configuration/SiteTcaConfiguration.php +++ b/typo3/sysext/backend/Classes/Configuration/SiteTcaConfiguration.php @@ -1,5 +1,6 @@ <?php declare(strict_types = 1); + namespace TYPO3\CMS\Backend\Configuration; /* diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php index 9b6e5400f2c0..c4cf7d380a04 100644 --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php @@ -1,5 +1,6 @@ <?php declare(strict_types = 1); + namespace TYPO3\CMS\Backend\Form\FormDataProvider; /* @@ -84,7 +85,7 @@ class SiteTcaInline extends AbstractDatabaseRecordProvider implements FormDataPr // If the parent is a page, use the uid(!) of the (new?) page as pid for the child records: if ($table === 'pages') { $liveVersionId = BackendUtility::getLiveVersionIdOfRecord('pages', $row['uid']); - $pid = $liveVersionId === null ? $row['uid'] : $liveVersionId; + $pid = $liveVersionId ?? $row['uid']; } elseif ($row['pid'] < 0) { $prevRec = BackendUtility::getRecord($table, abs($row['pid'])); $pid = $prevRec['pid']; @@ -256,7 +257,7 @@ class SiteTcaInline extends AbstractDatabaseRecordProvider implements FormDataPr 'inlineTopMostParentFieldName' => $result['inlineTopMostParentFieldName'] ?: $inlineTopMostParent['field'], ]; - if ($parentConfig['foreign_selector'] && $parentConfig['appearance']['useCombination']) { + if ($parentConfig['foreign_selector'] && ($parentConfig['appearance']['useCombination'] ?? false)) { throw new \RuntimeException('useCombination not implemented in sites module', 1522493097); } return $formDataCompiler->compile($formDataCompilerInput); diff --git a/typo3/sysext/backend/Classes/Routing/PageUriBuilder.php b/typo3/sysext/backend/Classes/Routing/PageUriBuilder.php index 13e5cca310bb..b1242da15bcd 100644 --- a/typo3/sysext/backend/Classes/Routing/PageUriBuilder.php +++ b/typo3/sysext/backend/Classes/Routing/PageUriBuilder.php @@ -1,5 +1,6 @@ <?php declare(strict_types = 1); + namespace TYPO3\CMS\Backend\Routing; /* @@ -36,12 +37,12 @@ class PageUriBuilder implements SingletonInterface /** * Generates an absolute URL */ - const ABSOLUTE_URL = 'url'; + public const ABSOLUTE_URL = 'url'; /** * Generates an absolute path */ - const ABSOLUTE_PATH = 'path'; + public const ABSOLUTE_PATH = 'path'; /** * @var SiteFinder diff --git a/typo3/sysext/core/Classes/Site/Entity/Site.php b/typo3/sysext/core/Classes/Site/Entity/Site.php index 908009a9d929..36205a03dba1 100644 --- a/typo3/sysext/core/Classes/Site/Entity/Site.php +++ b/typo3/sysext/core/Classes/Site/Entity/Site.php @@ -1,5 +1,6 @@ <?php declare(strict_types = 1); + namespace TYPO3\CMS\Core\Site\Entity; /* @@ -25,9 +26,9 @@ use TYPO3\CMS\Frontend\PageErrorHandler\PageErrorHandlerInterface; */ class Site { - const ERRORHANDLER_TYPE_PAGE = 'Page'; - const ERRORHANDLER_TYPE_FLUID = 'Fluid'; - const ERRORHANDLER_TYPE_PHP = 'PHP'; + protected const ERRORHANDLER_TYPE_PAGE = 'Page'; + protected const ERRORHANDLER_TYPE_FLUID = 'Fluid'; + protected const ERRORHANDLER_TYPE_PHP = 'PHP'; /** * @var string @@ -186,7 +187,7 @@ class Site // Check if the interface is implemented $handler = GeneralUtility::makeInstance($errorHandler['errorPhpClassFQCN'], $type, $errorHandler); if (!($handler instanceof PageErrorHandlerInterface)) { - // throw new exception + // @todo throw new exception } return $handler; } diff --git a/typo3/sysext/core/Classes/Site/Entity/SiteLanguage.php b/typo3/sysext/core/Classes/Site/Entity/SiteLanguage.php index 2fc49c87b3b5..126155a1b010 100644 --- a/typo3/sysext/core/Classes/Site/Entity/SiteLanguage.php +++ b/typo3/sysext/core/Classes/Site/Entity/SiteLanguage.php @@ -1,5 +1,6 @@ <?php declare(strict_types = 1); + namespace TYPO3\CMS\Core\Site\Entity; /* @@ -159,7 +160,7 @@ class SiteLanguage * * @return array */ - public function toArray() + public function toArray(): array { return [ 'languageId' => $this->getLanguageId(), diff --git a/typo3/sysext/core/Classes/Site/SiteFinder.php b/typo3/sysext/core/Classes/Site/SiteFinder.php index 3c92524cde13..48f9503bf619 100644 --- a/typo3/sysext/core/Classes/Site/SiteFinder.php +++ b/typo3/sysext/core/Classes/Site/SiteFinder.php @@ -1,5 +1,6 @@ <?php declare(strict_types = 1); + namespace TYPO3\CMS\Core\Site; /* @@ -21,7 +22,6 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Exception\SiteNotFoundException; use TYPO3\CMS\Core\Site\Entity\Site; -use TYPO3\CMS\Core\Site\Entity\SiteLanguage; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -73,7 +73,6 @@ class SiteFinder { $baseUrls = []; foreach ($this->sites as $site) { - /** @var SiteLanguage $language */ foreach ($site->getLanguages() as $language) { $baseUrls[$language->getBase()] = $language; if ($language->getLanguageId() === 0) { diff --git a/typo3/sysext/frontend/Classes/PageErrorHandler/DefaultPHPErrorHandler.php b/typo3/sysext/frontend/Classes/PageErrorHandler/DefaultPHPErrorHandler.php deleted file mode 100644 index 9c6b37aa751a..000000000000 --- a/typo3/sysext/frontend/Classes/PageErrorHandler/DefaultPHPErrorHandler.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php -declare(strict_types = 1); -namespace TYPO3\CMS\Frontend\PageErrorHandler; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; -use TYPO3\CMS\Core\Http\HtmlResponse; - -class DefaultPHPErrorHandler implements PageErrorHandlerInterface -{ - - /* - /$$$$$$$ -| $$__ $$ -| $$ \ $$ /$$$$$$ /$$$$$$/$$$$ /$$$$$$ /$$ /$$ /$$$$$$ -| $$$$$$$/ /$$__ $$| $$_ $$_ $$ /$$__ $$| $$ /$$//$$__ $$ -| $$__ $$| $$$$$$$$| $$ \ $$ \ $$| $$ \ $$ \ $$/$$/| $$$$$$$$ -| $$ \ $$| $$_____/| $$ | $$ | $$| $$ | $$ \ $$$/ | $$_____/ -| $$ | $$| $$$$$$$| $$ | $$ | $$| $$$$$$/ \ $/ | $$$$$$$ -|__/ |__/ \_______/|__/ |__/ |__/ \______/ \_/ \_______/ - - - - /$$ - | $$ - /$$ /$$ /$$| $$$$$$$ /$$$$$$ /$$$$$$$ -| $$ | $$ | $$| $$__ $$ /$$__ $$| $$__ $$ -| $$ | $$ | $$| $$ \ $$| $$$$$$$$| $$ \ $$ -| $$ | $$ | $$| $$ | $$| $$_____/| $$ | $$ -| $$$$$/$$$$/| $$ | $$| $$$$$$$| $$ | $$ - \_____/\___/ |__/ |__/ \_______/|__/ |__/ - - - - /$$ - | $$ - /$$$$$$/$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ -| $$_ $$_ $$ /$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ /$$__ $$ -| $$ \ $$ \ $$| $$$$$$$$| $$ \__/| $$ \ $$| $$$$$$$$| $$ | $$ -| $$ | $$ | $$| $$_____/| $$ | $$ | $$| $$_____/| $$ | $$ -| $$ | $$ | $$| $$$$$$$| $$ | $$$$$$$| $$$$$$$| $$$$$$$ -|__/ |__/ |__/ \_______/|__/ \____ $$ \_______/ \_______/ - /$$ \ $$ - | $$$$$$/ - \______/ - */ - - /** - * @var int - */ - protected $statusCode; - - public function __construct(int $statusCode, array $configuration) - { - $this->statusCode = $statusCode; - } - - /** - * @param ServerRequestInterface $request - * @param string $message - * @param array $reasons - * @return ResponseInterface - */ - public function handlePageError(ServerRequestInterface $request, string $message, array $reasons = []): ResponseInterface - { - return new HtmlResponse('go away', $this->statusCode); - } -} diff --git a/typo3/sysext/frontend/Classes/PageErrorHandler/FluidPageErrorHandler.php b/typo3/sysext/frontend/Classes/PageErrorHandler/FluidPageErrorHandler.php index 1734ac7eefa4..074af5a8f5d9 100644 --- a/typo3/sysext/frontend/Classes/PageErrorHandler/FluidPageErrorHandler.php +++ b/typo3/sysext/frontend/Classes/PageErrorHandler/FluidPageErrorHandler.php @@ -1,5 +1,6 @@ <?php declare(strict_types = 1); + namespace TYPO3\CMS\Frontend\PageErrorHandler; /* diff --git a/typo3/sysext/frontend/Classes/PageErrorHandler/PageContentErrorHandler.php b/typo3/sysext/frontend/Classes/PageErrorHandler/PageContentErrorHandler.php index 7e06cc89c4c8..3e5a32c2174a 100644 --- a/typo3/sysext/frontend/Classes/PageErrorHandler/PageContentErrorHandler.php +++ b/typo3/sysext/frontend/Classes/PageErrorHandler/PageContentErrorHandler.php @@ -1,5 +1,6 @@ <?php declare(strict_types = 1); + namespace TYPO3\CMS\Frontend\PageErrorHandler; /* -- GitLab