From 1a996aeb797a2bc7a5aa541e4108badc2f452548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Mon, 1 Jul 2024 09:05:55 +0200 Subject: [PATCH] [TASK] Avoid implicitly nullable class method parameter (#2500) 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 type to an union type definition. [[1]](https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated) This prepares the way towards PHP 8.4 compatibility. * [[1] https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated](https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated) --- Classes/Controller/CategoryController.php | 2 +- Classes/Controller/NewsController.php | 10 +++++----- Classes/Controller/TagController.php | 2 +- Classes/Domain/Model/Dto/NewsDemand.php | 2 +- Classes/Seo/NewsXmlSitemapDataProvider.php | 2 +- Classes/Utility/ClassCacheManager.php | 2 +- Classes/Utility/ClassLoader.php | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Classes/Controller/CategoryController.php b/Classes/Controller/CategoryController.php index fd43631b8d..1c2aea0761 100644 --- a/Classes/Controller/CategoryController.php +++ b/Classes/Controller/CategoryController.php @@ -20,7 +20,7 @@ class CategoryController extends NewsController /** * List categories */ - public function listAction(array $overwriteDemand = null): ResponseInterface + public function listAction(?array $overwriteDemand = null): ResponseInterface { $demand = $this->createDemandObjectFromSettings($this->settings); $demand->setActionAndClass(__METHOD__, __CLASS__); diff --git a/Classes/Controller/NewsController.php b/Classes/Controller/NewsController.php index 78e16800e2..798c0cbdf3 100644 --- a/Classes/Controller/NewsController.php +++ b/Classes/Controller/NewsController.php @@ -215,7 +215,7 @@ protected function overwriteDemandObject(NewsDemand $demand, array $overwriteDem * * @param array|null $overwriteDemand */ - public function listAction(array $overwriteDemand = null): ResponseInterface + public function listAction(?array $overwriteDemand = null): ResponseInterface { $possibleRedirect = $this->forwardToDetailActionWhenRequested(); if ($possibleRedirect) { @@ -356,7 +356,7 @@ public function selectedListAction(): ResponseInterface * @param News $news news item * @param int $currentPage current page for optional pagination */ - public function detailAction(News $news = null, $currentPage = 1): ResponseInterface + public function detailAction(?News $news = null, $currentPage = 1): ResponseInterface { if ($news === null || ($this->settings['isShortcut'] ?? false)) { $previewNewsId = (int)($this->settings['singleNews'] ?? 0); @@ -463,7 +463,7 @@ protected function isPreviewOfHiddenRecordsEnabled(): bool /** * Render a menu by dates, e.g. years, months or dates */ - public function dateMenuAction(array $overwriteDemand = null): ResponseInterface + public function dateMenuAction(?array $overwriteDemand = null): ResponseInterface { $demand = $this->createDemandObjectFromSettings($this->settings); $demand->setActionAndClass(__METHOD__, __CLASS__); @@ -512,7 +512,7 @@ public function dateMenuAction(array $overwriteDemand = null): ResponseInterface * Display the search form */ public function searchFormAction( - Search $search = null, + ?Search $search = null, array $overwriteDemand = [] ): ResponseInterface { $demand = $this->createDemandObjectFromSettings($this->settings); @@ -544,7 +544,7 @@ public function searchFormAction( * Displays the search result */ public function searchResultAction( - Search $search = null, + ?Search $search = null, array $overwriteDemand = [] ): ResponseInterface { $demand = $this->createDemandObjectFromSettings($this->settings); diff --git a/Classes/Controller/TagController.php b/Classes/Controller/TagController.php index 61995647b3..421c391484 100644 --- a/Classes/Controller/TagController.php +++ b/Classes/Controller/TagController.php @@ -17,7 +17,7 @@ */ class TagController extends NewsController { - public function listAction(array $overwriteDemand = null): ResponseInterface + public function listAction(?array $overwriteDemand = null): ResponseInterface { // Default value is wrong for tags if ($this->settings['orderBy'] === 'datetime') { diff --git a/Classes/Domain/Model/Dto/NewsDemand.php b/Classes/Domain/Model/Dto/NewsDemand.php index a7262abe60..bc37a2890b 100644 --- a/Classes/Domain/Model/Dto/NewsDemand.php +++ b/Classes/Domain/Model/Dto/NewsDemand.php @@ -580,7 +580,7 @@ public function getSearch(): ?Search * @param Search|null $search search object * @return NewsDemand */ - public function setSearch(Search $search = null): NewsDemand + public function setSearch(?Search $search = null): NewsDemand { $this->search = $search; return $this; diff --git a/Classes/Seo/NewsXmlSitemapDataProvider.php b/Classes/Seo/NewsXmlSitemapDataProvider.php index e33de7b5ef..daa8282712 100644 --- a/Classes/Seo/NewsXmlSitemapDataProvider.php +++ b/Classes/Seo/NewsXmlSitemapDataProvider.php @@ -41,7 +41,7 @@ class NewsXmlSitemapDataProvider extends AbstractXmlSitemapDataProvider * @param ContentObjectRenderer|null $cObj * @throws MissingConfigurationException */ - public function __construct(ServerRequestInterface $request, string $key, array $config = [], ContentObjectRenderer $cObj = null) + public function __construct(ServerRequestInterface $request, string $key, array $config = [], ?ContentObjectRenderer $cObj = null) { parent::__construct($request, $key, $config, $cObj); diff --git a/Classes/Utility/ClassCacheManager.php b/Classes/Utility/ClassCacheManager.php index dee3389063..8a7fd11140 100644 --- a/Classes/Utility/ClassCacheManager.php +++ b/Classes/Utility/ClassCacheManager.php @@ -35,7 +35,7 @@ class ClassCacheManager /** * @param PhpFrontend $classCache */ - public function __construct(PhpFrontend $classCache = null) + public function __construct(?PhpFrontend $classCache = null) { if ($classCache === null) { $cacheManager = GeneralUtility::makeInstance(CacheManager::class); diff --git a/Classes/Utility/ClassLoader.php b/Classes/Utility/ClassLoader.php index 18bb0fe696..ea71a5f621 100644 --- a/Classes/Utility/ClassLoader.php +++ b/Classes/Utility/ClassLoader.php @@ -36,7 +36,7 @@ class ClassLoader implements SingletonInterface * * @param PhpFrontend $classCache */ - public function __construct(PhpFrontend $classCache = null, ClassCacheManager $classCacheManager = null) + public function __construct(?PhpFrontend $classCache = null, ?ClassCacheManager $classCacheManager = null) { $versionInformation = GeneralUtility::makeInstance(Typo3Version::class); if ($versionInformation->getMajorVersion() === 10) {