From 825f4fd9d407844bcd9cae1c2320905917feff3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Mon, 24 Jun 2024 16:18:05 +0200
Subject: [PATCH] [TASK] Avoid implicitly nullable class method parameter in
 `EXT:seo`
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. [1]

This prepares the way towards PHP 8.4 compatibility.

[1] https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated

Resolves: #104197
Releases: main, 12.4, 11.5
Change-Id: Ie2fbd6369e6c59c275939c42daa8c45c22334e48
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84888
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
---
 typo3/sysext/seo/Classes/Canonical/CanonicalGenerator.php       | 2 +-
 .../seo/Classes/XmlSitemap/AbstractXmlSitemapDataProvider.php   | 2 +-
 .../seo/Classes/XmlSitemap/PagesXmlSitemapDataProvider.php      | 2 +-
 .../seo/Classes/XmlSitemap/RecordsXmlSitemapDataProvider.php    | 2 +-
 .../seo/Classes/XmlSitemap/XmlSitemapDataProviderInterface.php  | 2 +-
 typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php      | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/typo3/sysext/seo/Classes/Canonical/CanonicalGenerator.php b/typo3/sysext/seo/Classes/Canonical/CanonicalGenerator.php
index 9ce7216871fc..4088b3f03921 100644
--- a/typo3/sysext/seo/Classes/Canonical/CanonicalGenerator.php
+++ b/typo3/sysext/seo/Classes/Canonical/CanonicalGenerator.php
@@ -47,7 +47,7 @@ class CanonicalGenerator
      */
     protected $eventDispatcher;
 
-    public function __construct(TypoScriptFrontendController $typoScriptFrontendController = null, EventDispatcherInterface $eventDispatcher = null)
+    public function __construct(?TypoScriptFrontendController $typoScriptFrontendController = null, ?EventDispatcherInterface $eventDispatcher = null)
     {
         $this->eventDispatcher = $eventDispatcher ?? GeneralUtility::makeInstance(EventDispatcherInterface::class);
         $this->typoScriptFrontendController = $typoScriptFrontendController ?? $this->getTypoScriptFrontendController();
diff --git a/typo3/sysext/seo/Classes/XmlSitemap/AbstractXmlSitemapDataProvider.php b/typo3/sysext/seo/Classes/XmlSitemap/AbstractXmlSitemapDataProvider.php
index 738e12a3467c..6f9630a24d75 100644
--- a/typo3/sysext/seo/Classes/XmlSitemap/AbstractXmlSitemapDataProvider.php
+++ b/typo3/sysext/seo/Classes/XmlSitemap/AbstractXmlSitemapDataProvider.php
@@ -69,7 +69,7 @@ abstract class AbstractXmlSitemapDataProvider implements XmlSitemapDataProviderI
      * @param array $config
      * @param ContentObjectRenderer $cObj
      */
-    public function __construct(ServerRequestInterface $request, string $key, array $config = [], ContentObjectRenderer $cObj = null)
+    public function __construct(ServerRequestInterface $request, string $key, array $config = [], ?ContentObjectRenderer $cObj = null)
     {
         $this->key = $key;
         $this->config = $config;
diff --git a/typo3/sysext/seo/Classes/XmlSitemap/PagesXmlSitemapDataProvider.php b/typo3/sysext/seo/Classes/XmlSitemap/PagesXmlSitemapDataProvider.php
index 05647bbe2353..fd296db6fb2c 100644
--- a/typo3/sysext/seo/Classes/XmlSitemap/PagesXmlSitemapDataProvider.php
+++ b/typo3/sysext/seo/Classes/XmlSitemap/PagesXmlSitemapDataProvider.php
@@ -32,7 +32,7 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
  */
 class PagesXmlSitemapDataProvider extends AbstractXmlSitemapDataProvider
 {
-    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/typo3/sysext/seo/Classes/XmlSitemap/RecordsXmlSitemapDataProvider.php b/typo3/sysext/seo/Classes/XmlSitemap/RecordsXmlSitemapDataProvider.php
index c663f1f5229f..7ecda970e81f 100644
--- a/typo3/sysext/seo/Classes/XmlSitemap/RecordsXmlSitemapDataProvider.php
+++ b/typo3/sysext/seo/Classes/XmlSitemap/RecordsXmlSitemapDataProvider.php
@@ -40,7 +40,7 @@ class RecordsXmlSitemapDataProvider 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/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapDataProviderInterface.php b/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapDataProviderInterface.php
index c64f7b34b3fb..cde22d666436 100644
--- a/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapDataProviderInterface.php
+++ b/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapDataProviderInterface.php
@@ -25,7 +25,7 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
  */
 interface XmlSitemapDataProviderInterface
 {
-    public function __construct(ServerRequestInterface $request, string $name, array $config = [], ContentObjectRenderer $cObj = null);
+    public function __construct(ServerRequestInterface $request, string $name, array $config = [], ?ContentObjectRenderer $cObj = null);
     public function getKey(): string;
     public function getItems(): array;
     public function getLastModified(): int;
diff --git a/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php b/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php
index a0da0aeeb0d1..240ba7a1cedd 100644
--- a/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php
+++ b/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php
@@ -173,7 +173,7 @@ class XmlSitemapRenderer
      * @param string|null $sitemap
      * @return string
      */
-    protected function getXslFilePath(string $sitemapType = null, string $sitemap = null): string
+    protected function getXslFilePath(?string $sitemapType = null, ?string $sitemap = null): string
     {
         $path = $this->configuration['config']['xslFile'] ?? 'EXT:seo/Resources/Public/CSS/Sitemap.xsl';
         $path = ($sitemapType !== null) ? ($this->configuration['config'][$sitemapType]['sitemaps']['xslFile'] ?? $path) : $path;
-- 
GitLab