Skip to content

Commit

Permalink
[TASK] Clean-up in site handling
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
susannemoog authored and wouter90 committed Apr 9, 2018
1 parent ad815ed commit 4693b06
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 92 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Backend\Configuration;

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Backend\Form\FormDataProvider;

/*
Expand Down Expand Up @@ -84,7 +85,7 @@ protected function addInlineFirstPid(array $result): array
// 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'];
Expand Down Expand Up @@ -256,7 +257,7 @@ protected function compileChild(array $result, string $parentFieldName, int $chi
'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);
Expand Down
5 changes: 3 additions & 2 deletions typo3/sysext/backend/Classes/Routing/PageUriBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Backend\Routing;

/*
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions typo3/sysext/core/Classes/Site/Entity/Site.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Core\Site\Entity;

/*
Expand All @@ -25,9 +26,9 @@
*/
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
Expand Down Expand Up @@ -186,7 +187,7 @@ public function getErrorHandler(int $type): PageErrorHandlerInterface
// 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;
}
Expand Down
3 changes: 2 additions & 1 deletion typo3/sysext/core/Classes/Site/Entity/SiteLanguage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Core\Site\Entity;

/*
Expand Down Expand Up @@ -159,7 +160,7 @@ public function __construct(Site $site, int $languageId, string $locale, string
*
* @return array
*/
public function toArray()
public function toArray(): array
{
return [
'languageId' => $this->getLanguageId(),
Expand Down
3 changes: 1 addition & 2 deletions typo3/sysext/core/Classes/Site/SiteFinder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Core\Site;

/*
Expand All @@ -21,7 +22,6 @@
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;

/**
Expand Down Expand Up @@ -73,7 +73,6 @@ public function getBaseUris(): array
{
$baseUrls = [];
foreach ($this->sites as $site) {
/** @var SiteLanguage $language */
foreach ($site->getLanguages() as $language) {
$baseUrls[$language->getBase()] = $language;
if ($language->getLanguageId() === 0) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Frontend\PageErrorHandler;

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Frontend\PageErrorHandler;

/*
Expand Down

0 comments on commit 4693b06

Please sign in to comment.