[TASK] Clean-up in site handling 02/56602/4
authorSusanne Moog <susanne.moog@typo3.org>
Sun, 8 Apr 2018 08:29:35 +0000 (10:29 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 9 Apr 2018 18:47:34 +0000 (20:47 +0200)
- 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>
typo3/sysext/backend/Classes/Configuration/SiteTcaConfiguration.php
typo3/sysext/backend/Classes/Form/FormDataProvider/SiteTcaInline.php
typo3/sysext/backend/Classes/Routing/PageUriBuilder.php
typo3/sysext/core/Classes/Site/Entity/Site.php
typo3/sysext/core/Classes/Site/Entity/SiteLanguage.php
typo3/sysext/core/Classes/Site/SiteFinder.php
typo3/sysext/frontend/Classes/PageErrorHandler/DefaultPHPErrorHandler.php [deleted file]
typo3/sysext/frontend/Classes/PageErrorHandler/FluidPageErrorHandler.php
typo3/sysext/frontend/Classes/PageErrorHandler/PageContentErrorHandler.php

index 9b6e540..c4cf7d3 100644 (file)
@@ -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);
index 13e5cca..b1242da 100644 (file)
@@ -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
index 908009a..36205a0 100644 (file)
@@ -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;
         }
index 2fc49c8..126155a 100644 (file)
@@ -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(),
index 3c92524..48f9503 100644 (file)
@@ -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 (file)
index 9c6b37a..0000000
+++ /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);
-    }
-}