From 8b6609aa84174db5be2900659b5c102806f72d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech> Date: Thu, 27 Jun 2024 23:08:01 +0200 Subject: [PATCH] [TASK] Avoid implicitly nullable class method parameter in `EXT:frontend` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With PHP 8.4 marking method parameter implicitly nullable is deprecated and will emit a `E_DEPRECATED` warning. One recommended way to resolve this, is making it explicitly nullable using the `?` nullable operator or adding a null tyype to an union type definition. [1] This prepares the way towards PHP 8.4 compatibility. [1] https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated Resolves: #104237 Releases: main, 12.4, 11.5 Change-Id: Ieb8d05b2e44dc448f7a2142c5ad6a91e68cf98c0 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84975 Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Stefan Bürk <stefan@buerk.tech> --- .../FrontendUserAuthentication.php | 2 +- .../ConditionMatching/ConditionMatcher.php | 2 +- .../ContentObject/ContentObjectRenderer.php | 2 +- .../Exception/ExceptionHandlerInterface.php | 2 +- .../Exception/ProductionExceptionHandler.php | 2 +- .../Controller/TypoScriptFrontendController.php | 16 ++++++++-------- .../Classes/DataProcessing/SiteProcessor.php | 2 +- .../Middleware/SiteBaseRedirectResolver.php | 2 +- .../Classes/Page/CacheHashCalculator.php | 2 +- .../Classes/Page/CacheHashConfiguration.php | 2 +- .../frontend/Classes/Plugin/AbstractPlugin.php | 2 +- .../Classes/Typolink/AbstractTypolinkBuilder.php | 2 +- .../Classes/Typolink/PageLinkBuilder.php | 2 +- .../Classes/Typolink/UnableToLinkException.php | 2 +- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php index 04180ba65853..2c044fd24a7b 100644 --- a/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php +++ b/typo3/sysext/frontend/Classes/Authentication/FrontendUserAuthentication.php @@ -267,7 +267,7 @@ class FrontendUserAuthentication extends AbstractUserAuthentication * * @param ServerRequestInterface|null $request (will become a requirement in v12.0) */ - public function fetchGroupData(ServerRequestInterface $request = null) + public function fetchGroupData(?ServerRequestInterface $request = null) { $this->TSdataArray = []; $this->userTS = []; diff --git a/typo3/sysext/frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php b/typo3/sysext/frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php index 17640efb384f..c20f1a75608a 100644 --- a/typo3/sysext/frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php +++ b/typo3/sysext/frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php @@ -47,7 +47,7 @@ class ConditionMatcher extends AbstractConditionMatcher * @param array|null $rootLine * @param array<int, array<string, mixed>>|null $fullRootLine */ - public function __construct(Context $context = null, int $pageId = null, array $rootLine = null, array $fullRootLine = null) + public function __construct(?Context $context = null, ?int $pageId = null, ?array $rootLine = null, ?array $fullRootLine = null) { $this->context = $context ?? GeneralUtility::makeInstance(Context::class); $this->pageId = $pageId; diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index f03324cc2394..65df510b96a6 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -473,7 +473,7 @@ class ContentObjectRenderer implements LoggerAwareInterface * @param TypoScriptFrontendController $typoScriptFrontendController * @param ContainerInterface $container */ - public function __construct(TypoScriptFrontendController $typoScriptFrontendController = null, ContainerInterface $container = null) + public function __construct(?TypoScriptFrontendController $typoScriptFrontendController = null, ?ContainerInterface $container = null) { $this->typoScriptFrontendController = $typoScriptFrontendController; $this->contentObjectClassMap = $GLOBALS['TYPO3_CONF_VARS']['FE']['ContentObjects'] ?? []; diff --git a/typo3/sysext/frontend/Classes/ContentObject/Exception/ExceptionHandlerInterface.php b/typo3/sysext/frontend/Classes/ContentObject/Exception/ExceptionHandlerInterface.php index 6bf2143de5a3..cb899f0bbf42 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/Exception/ExceptionHandlerInterface.php +++ b/typo3/sysext/frontend/Classes/ContentObject/Exception/ExceptionHandlerInterface.php @@ -32,7 +32,7 @@ interface ExceptionHandlerInterface * @param array $contentObjectConfiguration * @return string */ - public function handle(\Exception $exception, AbstractContentObject $contentObject = null, $contentObjectConfiguration = []); + public function handle(\Exception $exception, ?AbstractContentObject $contentObject = null, $contentObjectConfiguration = []); /** * @todo Will be activated in TYPO3 v12 diff --git a/typo3/sysext/frontend/Classes/ContentObject/Exception/ProductionExceptionHandler.php b/typo3/sysext/frontend/Classes/ContentObject/Exception/ProductionExceptionHandler.php index 85d202fd2526..860ad6c76d5f 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/Exception/ProductionExceptionHandler.php +++ b/typo3/sysext/frontend/Classes/ContentObject/Exception/ProductionExceptionHandler.php @@ -59,7 +59,7 @@ class ProductionExceptionHandler implements ExceptionHandlerInterface * @return string * @throws \Exception */ - public function handle(\Exception $exception, AbstractContentObject $contentObject = null, $contentObjectConfiguration = []): string + public function handle(\Exception $exception, ?AbstractContentObject $contentObject = null, $contentObjectConfiguration = []): string { // ImmediateResponseException (and the derived PropagateResponseException) should work similar to // exit / die and must therefore not be handled by this ExceptionHandler. diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php index a9c1bdf908e6..4981ae5a751c 100644 --- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php +++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php @@ -739,7 +739,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface * * @param ServerRequestInterface|null $request */ - public function determineId(ServerRequestInterface $request = null) + public function determineId(?ServerRequestInterface $request = null) { $request = $request ?? $GLOBALS['TYPO3_REQUEST'] ?? ServerRequestFactory::fromGlobals(); // Call pre processing function for id determination @@ -963,7 +963,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface * @internal * @param ServerRequestInterface|null $request */ - protected function fetch_the_id(ServerRequestInterface $request = null) + protected function fetch_the_id(?ServerRequestInterface $request = null) { $request = $request ?? $GLOBALS['TYPO3_REQUEST'] ?? ServerRequestFactory::fromGlobals(); $timeTracker = $this->getTimeTracker(); @@ -1464,7 +1464,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface * @param string $failureReasonCode the error code to be attached (optional), see PageAccessFailureReasons list for details * @return array Summary of why page access was not allowed. */ - public function getPageAccessFailureReasons(string $failureReasonCode = null) + public function getPageAccessFailureReasons(?string $failureReasonCode = null) { $output = []; if ($failureReasonCode) { @@ -1577,7 +1577,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface * @param ServerRequestInterface|null $request if given this is used to determine values in headerNoCache() instead of the superglobal $_SERVER * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException */ - public function getFromCache(ServerRequestInterface $request = null) + public function getFromCache(?ServerRequestInterface $request = null) { // clearing the content-variable, which will hold the pagecontent $this->content = ''; @@ -1730,7 +1730,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface * @param ServerRequestInterface|null $request * @return bool If shift-reload in client browser has been clicked, disable getting cached page (and regenerate it). */ - public function headerNoCache(ServerRequestInterface $request = null) + public function headerNoCache(?ServerRequestInterface $request = null) { if ($request instanceof ServerRequestInterface) { $serverParams = $request->getServerParams(); @@ -1830,7 +1830,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface * @throws \TYPO3\CMS\Core\Error\Http\InternalServerErrorException * @throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException */ - public function getConfigArray(ServerRequestInterface $request = null) + public function getConfigArray(?ServerRequestInterface $request = null) { $request = $request ?? $GLOBALS['TYPO3_REQUEST'] ?? ServerRequestFactory::fromGlobals(); if (!$this->tmpl instanceof TemplateService) { @@ -2759,7 +2759,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface * * @param ServerRequestInterface|null $request */ - public function INTincScript(ServerRequestInterface $request = null) + public function INTincScript(?ServerRequestInterface $request = null) { $request = $request ?? $GLOBALS['TYPO3_REQUEST']; $this->additionalHeaderData = $this->config['INTincScript_ext']['additionalHeaderData'] ?? []; @@ -3027,7 +3027,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface * * @param ServerRequestInterface|null $request */ - public function newCObj(ServerRequestInterface $request = null) + public function newCObj(?ServerRequestInterface $request = null) { $this->cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class, $this); $this->cObj->start($this->page, 'pages', $request); diff --git a/typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php b/typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php index 9602415d01ee..56def4d9ba3d 100644 --- a/typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php +++ b/typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php @@ -38,7 +38,7 @@ class SiteProcessor implements DataProcessorInterface { protected ?TypoScriptFrontendController $tsfe; - public function __construct(TypoScriptFrontendController $tsfe = null) + public function __construct(?TypoScriptFrontendController $tsfe = null) { $this->tsfe = $tsfe ?? $GLOBALS['TSFE'] ?? null; } diff --git a/typo3/sysext/frontend/Classes/Middleware/SiteBaseRedirectResolver.php b/typo3/sysext/frontend/Classes/Middleware/SiteBaseRedirectResolver.php index 825dd95d6105..97100782e013 100644 --- a/typo3/sysext/frontend/Classes/Middleware/SiteBaseRedirectResolver.php +++ b/typo3/sysext/frontend/Classes/Middleware/SiteBaseRedirectResolver.php @@ -101,7 +101,7 @@ class SiteBaseRedirectResolver implements MiddlewareInterface * @param BackendUserAuthentication|null $user * @return bool */ - protected function isLanguageEnabled(SiteLanguage $language, BackendUserAuthentication $user = null): bool + protected function isLanguageEnabled(SiteLanguage $language, ?BackendUserAuthentication $user = null): bool { // language is hidden, check if a possible backend user is allowed to access the language if ($language->enabled() || ($user instanceof BackendUserAuthentication && $user->checkLanguageAccess($language->getLanguageId()))) { diff --git a/typo3/sysext/frontend/Classes/Page/CacheHashCalculator.php b/typo3/sysext/frontend/Classes/Page/CacheHashCalculator.php index fec164706cdc..cc096ddda96a 100644 --- a/typo3/sysext/frontend/Classes/Page/CacheHashCalculator.php +++ b/typo3/sysext/frontend/Classes/Page/CacheHashCalculator.php @@ -33,7 +33,7 @@ class CacheHashCalculator implements SingletonInterface * * @param CacheHashConfiguration|null $configuration */ - public function __construct(CacheHashConfiguration $configuration = null) + public function __construct(?CacheHashConfiguration $configuration = null) { $this->configuration = $configuration ?? GeneralUtility::makeInstance(CacheHashConfiguration::class); } diff --git a/typo3/sysext/frontend/Classes/Page/CacheHashConfiguration.php b/typo3/sysext/frontend/Classes/Page/CacheHashConfiguration.php index 09721b1bc836..b2d1643d24d6 100644 --- a/typo3/sysext/frontend/Classes/Page/CacheHashConfiguration.php +++ b/typo3/sysext/frontend/Classes/Page/CacheHashConfiguration.php @@ -67,7 +67,7 @@ class CacheHashConfiguration */ protected $data = []; - public function __construct(array $configuration = null) + public function __construct(?array $configuration = null) { $configuration = $configuration ?? $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash'] ?? []; $this->configuration = array_filter($configuration, [$this, 'isAllowedProperty'], ARRAY_FILTER_USE_KEY); diff --git a/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php b/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php index ac7a6cca3ef4..1a2b84cc4205 100644 --- a/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php +++ b/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php @@ -232,7 +232,7 @@ class AbstractPlugin * @param null $_ unused, * @param TypoScriptFrontendController $frontendController */ - public function __construct($_ = null, TypoScriptFrontendController $frontendController = null) + public function __construct($_ = null, ?TypoScriptFrontendController $frontendController = null) { $this->frontendController = $frontendController ?: $GLOBALS['TSFE']; $this->templateService = GeneralUtility::makeInstance(MarkerBasedTemplateService::class); diff --git a/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php index 0f080ce693c1..e34e85430f43 100644 --- a/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php +++ b/typo3/sysext/frontend/Classes/Typolink/AbstractTypolinkBuilder.php @@ -55,7 +55,7 @@ abstract class AbstractTypolinkBuilder * @param ContentObjectRenderer $contentObjectRenderer * @param TypoScriptFrontendController $typoScriptFrontendController */ - public function __construct(ContentObjectRenderer $contentObjectRenderer, TypoScriptFrontendController $typoScriptFrontendController = null) + public function __construct(ContentObjectRenderer $contentObjectRenderer, ?TypoScriptFrontendController $typoScriptFrontendController = null) { $this->contentObjectRenderer = $contentObjectRenderer; $this->typoScriptFrontendController = $typoScriptFrontendController ?? $GLOBALS['TSFE'] ?? null; diff --git a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php index 9706abda2bac..17932a52da9d 100644 --- a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php +++ b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php @@ -769,7 +769,7 @@ class PageLinkBuilder extends AbstractTypolinkBuilder * Builds PageRepository instance without depending on global context, e.g. * not automatically overlaying records based on current request language. */ - protected function buildPageRepository(LanguageAspect $languageAspect = null): PageRepository + protected function buildPageRepository(?LanguageAspect $languageAspect = null): PageRepository { // clone global context object (singleton) $context = clone GeneralUtility::makeInstance(Context::class); diff --git a/typo3/sysext/frontend/Classes/Typolink/UnableToLinkException.php b/typo3/sysext/frontend/Classes/Typolink/UnableToLinkException.php index 12d7d5ad0c40..97794ff923c2 100644 --- a/typo3/sysext/frontend/Classes/Typolink/UnableToLinkException.php +++ b/typo3/sysext/frontend/Classes/Typolink/UnableToLinkException.php @@ -37,7 +37,7 @@ class UnableToLinkException extends Exception * @param \Throwable $previous [optional] The previous throwable used for the exception chaining. * @param LinkResult|string $linkText [optional] */ - public function __construct($message = '', $code = 0, \Throwable $previous = null, $linkText = '') + public function __construct($message = '', $code = 0, ?\Throwable $previous = null, $linkText = '') { parent::__construct($message, $code, $previous); if ($linkText instanceof LinkResult) { -- GitLab