Commit 4693b06a authored by Susanne Moog's avatar Susanne Moog Committed by Wouter Wolters
Browse files

[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: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
parent ad815edd
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Backend\Configuration;
/*
......
<?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);
......
<?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
......
<?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;
}
......
<?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(),
......
<?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) {
......
<?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);
}
}
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Frontend\PageErrorHandler;
/*
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Frontend\PageErrorHandler;
/*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment