From 06043aeb52c3bd8c8183189ae781c480c6c210ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Sun, 23 Jun 2024 05:11:39 +0200
Subject: [PATCH] [TASK] Avoid implicitly nullable class method parameter in
 tests
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 depreacted and will emit a `E_DEPRECATED` warning. One
recommended way to resolve this, is making it explicitly
nullable using the `?` nullable operator. [1]

In cases, where are implicitly nullable parameter exists
before not-nullable parameters in a method or constructor,
making it explicitly nullable will emit a

  Optional parameter <paramname> declared before required
  parameter <paramname> is implicitly treated as a required
  parameter

since PHP 8.0 [2].

This change adds the `?` nullable operator [1] and removes
the null default value when one or more non-optional argument
follows [2] to mitigate both issues.

Note that the second case is a edge case in this change.

This prepares the way towards PHP 8.4 compatibility and
unifies towards using `?` nullable operator over union
null type when possible.

[1] https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated
[2] https://php.watch/versions/8.0/deprecate-required-param-after-optional

Resolves: #104182
Releases: main, 12.4, 11.5
Change-Id: I68362a89458117eca4f0488c67a0b9ed17e7b929
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84859
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
---
 .../ConditionMatching/ConditionMatcherTest.php       |  2 +-
 .../Unit/Controller/File/ThumbnailControllerTest.php |  4 ++--
 .../core/Tests/Acceptance/Support/Helper/Config.php  |  6 +++---
 .../AbstractDataHandlerActionTestCase.php            |  2 +-
 .../Classes/Controller/ContentController.php         |  2 +-
 .../Tests/Functional/Imaging/ImageMagickFileTest.php |  2 +-
 .../Functional/SiteHandling/SiteBasedTestTrait.php   |  2 +-
 .../Schema/Parser/ColumnDefinitionAttributesTest.php |  6 +++---
 .../Schema/Parser/DataTypes/DateTimeTypesTest.php    |  2 +-
 .../Schema/Parser/DataTypes/FixedPointTypesTest.php  |  4 ++--
 .../Parser/DataTypes/FloatingPointTypesTest.php      |  4 ++--
 .../Schema/Parser/ReferenceDefinitionTest.php        |  6 +++---
 .../DependencyInjection/FailsafeContainerTest.php    |  2 +-
 .../ServiceProviderCompilationPassTest.php           |  2 +-
 .../Unit/EventDispatcher/ListenerProviderTest.php    |  6 +++---
 .../Unit/Mail/Fixtures/FakeValidSpoolFixture.php     |  2 +-
 .../core/Tests/Unit/Resource/ResourceStorageTest.php |  6 +++---
 .../ExtensionManagementUtilityAccessibleProxy.php    |  2 +-
 .../Unit/Utility/IpAnonymizationUtilityTest.php      |  2 +-
 .../Classes/Controller/BlogController.php            |  2 +-
 .../Mvc/Controller/ActionControllerArgumentTest.php  |  2 +-
 .../Tests/Functional/Property/PropertyMapperTest.php | 12 ++++++------
 .../ContainerConstructorInjectionTestFixtures.php    |  8 ++++----
 .../TypeConverter/Fixtures/DateTimeSubFixture.php    |  2 +-
 .../Tests/Unit/Reflection/ClassSchemaTest.php        |  2 +-
 .../Tests/Unit/Utility/LocalizationUtilityTest.php   |  4 ++--
 .../Functional/SiteHandling/AbstractTestCase.php     |  2 +-
 .../SiteHandling/EnhancerSiteRequest/RouteTest.php   |  2 +-
 .../SiteHandling/Fixtures/LinkHandlingController.php |  2 +-
 .../SiteHandling/Framework/Builder/TestSet.php       |  2 +-
 .../SiteHandling/Framework/Builder/VariableValue.php |  6 +++---
 .../Php/Matcher/Fixtures/Subject.php                 |  2 +-
 .../Unit/Controller/Remote/RemoteServerTest.php      |  2 +-
 33 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/typo3/sysext/backend/Tests/Functional/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php b/typo3/sysext/backend/Tests/Functional/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
index b51aa99d774e..6b80f5b04f35 100644
--- a/typo3/sysext/backend/Tests/Functional/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
+++ b/typo3/sysext/backend/Tests/Functional/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
@@ -433,7 +433,7 @@ class ConditionMatcherTest extends FunctionalTestCase
      * @param int|null $pageId
      * @return ConditionMatcher
      */
-    protected function getConditionMatcher(int $pageId = null): ConditionMatcher
+    protected function getConditionMatcher(?int $pageId = null): ConditionMatcher
     {
         $conditionMatcher = new ConditionMatcher(null, $pageId);
         $conditionMatcher->setLogger($this->prophesize(Logger::class)->reveal());
diff --git a/typo3/sysext/backend/Tests/Unit/Controller/File/ThumbnailControllerTest.php b/typo3/sysext/backend/Tests/Unit/Controller/File/ThumbnailControllerTest.php
index ebbc51c44efb..578a865f1eb5 100644
--- a/typo3/sysext/backend/Tests/Unit/Controller/File/ThumbnailControllerTest.php
+++ b/typo3/sysext/backend/Tests/Unit/Controller/File/ThumbnailControllerTest.php
@@ -62,7 +62,7 @@ class ThumbnailControllerTest extends UnitTestCase
      * @test
      * @dataProvider exceptionIsThrownOnInvalidHMACDataProvider
      */
-    public function exceptionIsThrownOnInvalidHMAC(string $hmac = null): void
+    public function exceptionIsThrownOnInvalidHMAC(?string $hmac = null): void
     {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode(1534484203);
@@ -95,7 +95,7 @@ class ThumbnailControllerTest extends UnitTestCase
      * @test
      * @dataProvider generateThumbnailIsInvokedDataProvider
      */
-    public function generateThumbnailIsInvoked(array $parameters = null): void
+    public function generateThumbnailIsInvoked(?array $parameters = null): void
     {
         $this->subject->expects(self::once())
             ->method('generateThumbnail')
diff --git a/typo3/sysext/core/Tests/Acceptance/Support/Helper/Config.php b/typo3/sysext/core/Tests/Acceptance/Support/Helper/Config.php
index 6fbe69d20934..17ce12360305 100644
--- a/typo3/sysext/core/Tests/Acceptance/Support/Helper/Config.php
+++ b/typo3/sysext/core/Tests/Acceptance/Support/Helper/Config.php
@@ -59,7 +59,7 @@ class Config extends Module
      * @return array|string|null
      * @throws \Codeception\Exception\ModuleException
      */
-    public function grabConfig(string $parameter = null)
+    public function grabConfig(?string $parameter = null)
     {
         return $this->grab($parameter);
     }
@@ -72,7 +72,7 @@ class Config extends Module
      * @return array|string|null
      * @throws \Codeception\Exception\ModuleException
      */
-    public function grabModuleConfig(string $moduleName, string $parameter = null)
+    public function grabModuleConfig(string $moduleName, ?string $parameter = null)
     {
         return $this->grab($parameter, $moduleName);
     }
@@ -85,7 +85,7 @@ class Config extends Module
      * @return array|string|null
      * @throws \Codeception\Exception\ModuleException
      */
-    protected function grab(string $parameter = null, string $moduleName = null)
+    protected function grab(?string $parameter = null, ?string $moduleName = null)
     {
         $module = is_string($moduleName) ? $this->getModule($moduleName) : $this;
         return $module->_getConfig($parameter);
diff --git a/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php b/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php
index 22fd8a93cffe..3114afb3bd7d 100644
--- a/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php
+++ b/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php
@@ -178,7 +178,7 @@ abstract class AbstractDataHandlerActionTestCase extends FunctionalTestCase
      *
      * @param string[]|null $expectedMessages
      */
-    protected function assertErrorLogEntries(array $expectedMessages = null): void
+    protected function assertErrorLogEntries(?array $expectedMessages = null): void
     {
         if ($this->expectedErrorLogEntries === null && $expectedMessages === null) {
             return;
diff --git a/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield/Classes/Controller/ContentController.php b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield/Classes/Controller/ContentController.php
index b6d924adcb9c..7858110e9647 100644
--- a/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield/Classes/Controller/ContentController.php
+++ b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_foreignfield/Classes/Controller/ContentController.php
@@ -65,7 +65,7 @@ class ContentController extends AbstractController
      * @param \TYPO3\TestIrreForeignfield\Domain\Model\Content $newContent
      * @Extbase\IgnoreValidation("newContent")
      */
-    public function newAction(Content $newContent = null): void
+    public function newAction(?Content $newContent = null): void
     {
         $this->view->assign('newContent', $newContent);
     }
diff --git a/typo3/sysext/core/Tests/Functional/Imaging/ImageMagickFileTest.php b/typo3/sysext/core/Tests/Functional/Imaging/ImageMagickFileTest.php
index 4ce9f72fbc6b..314786f8335b 100644
--- a/typo3/sysext/core/Tests/Functional/Imaging/ImageMagickFileTest.php
+++ b/typo3/sysext/core/Tests/Functional/Imaging/ImageMagickFileTest.php
@@ -267,7 +267,7 @@ class ImageMagickFileTest extends FunctionalTestCase
      * @test
      * @dataProvider fileStatementIsDeniedDataProvider
      */
-    public function fileStatementIsDenied(string $fileName, string $mimeType = null): void
+    public function fileStatementIsDenied(string $fileName, ?string $mimeType = null): void
     {
         $this->expectException(Exception::class);
         $this->expectExceptionCode(1550060977);
diff --git a/typo3/sysext/core/Tests/Functional/SiteHandling/SiteBasedTestTrait.php b/typo3/sysext/core/Tests/Functional/SiteHandling/SiteBasedTestTrait.php
index d87df5a16368..6261f52aba2b 100644
--- a/typo3/sysext/core/Tests/Functional/SiteHandling/SiteBasedTestTrait.php
+++ b/typo3/sysext/core/Tests/Functional/SiteHandling/SiteBasedTestTrait.php
@@ -145,7 +145,7 @@ trait SiteBasedTestTrait
         string $identifier,
         string $base,
         array $fallbackIdentifiers = [],
-        string $fallbackType = null
+        ?string $fallbackType = null
     ): array {
         $preset = $this->resolveLanguagePreset($identifier);
 
diff --git a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ColumnDefinitionAttributesTest.php b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ColumnDefinitionAttributesTest.php
index 77ee3a0c6dcc..976d35011b2d 100644
--- a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ColumnDefinitionAttributesTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ColumnDefinitionAttributesTest.php
@@ -359,9 +359,9 @@ class ColumnDefinitionAttributesTest extends UnitTestCase
         bool $createIndex,
         bool $createUniqueIndex,
         bool $isPrimaryKey,
-        string $comment = null,
-        string $columnFormat = null,
-        string $storage = null
+        ?string $comment = null,
+        ?string $columnFormat = null,
+        ?string $storage = null
     ): void {
         $statement = sprintf('CREATE TABLE `aTable`(`aField` INT(11) %s);', $columnAttribute);
         $subject = $this->createSubject($statement);
diff --git a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/DateTimeTypesTest.php b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/DateTimeTypesTest.php
index 55160ed05ea6..e48e8792f636 100644
--- a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/DateTimeTypesTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/DateTimeTypesTest.php
@@ -88,7 +88,7 @@ class DateTimeTypesTest extends AbstractDataTypeBaseTestCase
      * @param string $className
      * @param int $length
      */
-    public function canParseDataType(string $columnDefinition, string $className, int $length = null): void
+    public function canParseDataType(string $columnDefinition, string $className, ?int $length = null): void
     {
         $subject = $this->createSubject($columnDefinition);
 
diff --git a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/FixedPointTypesTest.php b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/FixedPointTypesTest.php
index b47628796faa..1c13e18efc47 100644
--- a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/FixedPointTypesTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/FixedPointTypesTest.php
@@ -84,8 +84,8 @@ class FixedPointTypesTest extends AbstractDataTypeBaseTestCase
     public function canParseDataType(
         string $columnDefinition,
         string $className,
-        int $precision = null,
-        int $scale = null
+        ?int $precision = null,
+        ?int $scale = null
     ): void {
         $subject = $this->createSubject($columnDefinition);
 
diff --git a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/FloatingPointTypesTest.php b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/FloatingPointTypesTest.php
index ac3e9133af09..62dfe085c68a 100644
--- a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/FloatingPointTypesTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/DataTypes/FloatingPointTypesTest.php
@@ -103,8 +103,8 @@ class FloatingPointTypesTest extends AbstractDataTypeBaseTestCase
     public function canParseDataType(
         string $columnDefinition,
         string $className,
-        int $precision = null,
-        int $scale = null
+        ?int $precision = null,
+        ?int $scale = null
     ): void {
         $subject = $this->createSubject($columnDefinition);
 
diff --git a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ReferenceDefinitionTest.php b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ReferenceDefinitionTest.php
index a7c2dca73270..dfb44a319f2f 100644
--- a/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ReferenceDefinitionTest.php
+++ b/typo3/sysext/core/Tests/Unit/Database/Schema/Parser/ReferenceDefinitionTest.php
@@ -186,9 +186,9 @@ class ReferenceDefinitionTest extends UnitTestCase
         string $columnAttribute,
         string $table,
         array $columns,
-        string $match = null,
-        string $onDelete = null,
-        string $onUpdate = null
+        ?string $match = null,
+        ?string $onDelete = null,
+        ?string $onUpdate = null
     ): void {
         $statement = sprintf('CREATE TABLE `aTable`(`aField` INT(11) %s);', $columnAttribute);
         $subject = $this->createSubject($statement);
diff --git a/typo3/sysext/core/Tests/Unit/DependencyInjection/FailsafeContainerTest.php b/typo3/sysext/core/Tests/Unit/DependencyInjection/FailsafeContainerTest.php
index e18ce52f1547..826d95efd5d8 100644
--- a/typo3/sysext/core/Tests/Unit/DependencyInjection/FailsafeContainerTest.php
+++ b/typo3/sysext/core/Tests/Unit/DependencyInjection/FailsafeContainerTest.php
@@ -305,7 +305,7 @@ class FailsafeContainerTest extends UnitTestCase
     public function extendingNonExistingFactory(): void
     {
         $this->providerProphecy->getExtensions()->willReturn([
-            'service' => static function (ContainerInterface $c, Service $s = null) {
+            'service' => static function (ContainerInterface $c, ?Service $s = null) {
                 if ($s === null) {
                     $s = new Service();
                 }
diff --git a/typo3/sysext/core/Tests/Unit/DependencyInjection/ServiceProviderCompilationPassTest.php b/typo3/sysext/core/Tests/Unit/DependencyInjection/ServiceProviderCompilationPassTest.php
index f1c272477ac7..3a2d9e5adba6 100644
--- a/typo3/sysext/core/Tests/Unit/DependencyInjection/ServiceProviderCompilationPassTest.php
+++ b/typo3/sysext/core/Tests/Unit/DependencyInjection/ServiceProviderCompilationPassTest.php
@@ -69,7 +69,7 @@ class ServiceProviderCompilationPassTest extends UnitTestCase
         return $serviceProviderRegistryProphecy->reveal();
     }
 
-    protected function getContainer(array $serviceProviders, callable $configure = null): ContainerBuilder
+    protected function getContainer(array $serviceProviders, ?callable $configure = null): ContainerBuilder
     {
         static $id = 0;
 
diff --git a/typo3/sysext/core/Tests/Unit/EventDispatcher/ListenerProviderTest.php b/typo3/sysext/core/Tests/Unit/EventDispatcher/ListenerProviderTest.php
index 9645751db9b0..b38ee9ad0348 100644
--- a/typo3/sysext/core/Tests/Unit/EventDispatcher/ListenerProviderTest.php
+++ b/typo3/sysext/core/Tests/Unit/EventDispatcher/ListenerProviderTest.php
@@ -75,7 +75,7 @@ class ListenerProviderTest extends UnitTestCase
      * @test
      * @dataProvider listeners
      */
-    public function dispatchesEvent($listener, string $method = null): void
+    public function dispatchesEvent($listener, ?string $method = null): void
     {
         $event = new \stdClass();
         $event->invoked = 0;
@@ -94,7 +94,7 @@ class ListenerProviderTest extends UnitTestCase
      * @test
      * @dataProvider listeners
      */
-    public function associatesToEventParentClass($listener, string $method = null): void
+    public function associatesToEventParentClass($listener, ?string $method = null): void
     {
         $extendedEvent = new class () extends \stdClass {
             public $invoked = 0;
@@ -113,7 +113,7 @@ class ListenerProviderTest extends UnitTestCase
      * @test
      * @dataProvider listeners
      */
-    public function associatesToImplementedInterfaces($listener, string $method = null): void
+    public function associatesToImplementedInterfaces($listener, ?string $method = null): void
     {
         $eventImplementation = new class () implements \IteratorAggregate {
             public $invoked = 0;
diff --git a/typo3/sysext/core/Tests/Unit/Mail/Fixtures/FakeValidSpoolFixture.php b/typo3/sysext/core/Tests/Unit/Mail/Fixtures/FakeValidSpoolFixture.php
index 3c07c63da3c4..3d76fa8767a1 100644
--- a/typo3/sysext/core/Tests/Unit/Mail/Fixtures/FakeValidSpoolFixture.php
+++ b/typo3/sysext/core/Tests/Unit/Mail/Fixtures/FakeValidSpoolFixture.php
@@ -40,7 +40,7 @@ class FakeValidSpoolFixture implements DelayedTransportInterface
         return $this->settings;
     }
 
-    public function send(RawMessage $message, Envelope $envelope = null): ?SentMessage
+    public function send(RawMessage $message, ?Envelope $envelope = null): ?SentMessage
     {
         // Don't do anything
         return null;
diff --git a/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php b/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php
index 87d786a8ce55..64ca2895c979 100644
--- a/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php
+++ b/typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php
@@ -94,8 +94,8 @@ class ResourceStorageTest extends BaseTestCase
     protected function prepareSubject(
         array $configuration,
         bool $mockPermissionChecks = false,
-        AbstractDriver $driverObject = null,
-        ResourceFactory $resourceFactory = null,
+        ?AbstractDriver $driverObject = null,
+        ?ResourceFactory $resourceFactory = null,
         array $storageRecord = [],
         array $mockedMethods = []
     ): void {
@@ -162,7 +162,7 @@ class ResourceStorageTest extends BaseTestCase
      */
     protected function createDriverMock(
         array $driverConfiguration,
-        ResourceStorage $storageObject = null,
+        ?ResourceStorage $storageObject = null,
         array $mockedDriverMethods = []
     ) {
         $this->initializeVfs();
diff --git a/typo3/sysext/core/Tests/Unit/Utility/AccessibleProxies/ExtensionManagementUtilityAccessibleProxy.php b/typo3/sysext/core/Tests/Unit/Utility/AccessibleProxies/ExtensionManagementUtilityAccessibleProxy.php
index 0d8d6b3ec416..3b4dd73ceb19 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/AccessibleProxies/ExtensionManagementUtilityAccessibleProxy.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/AccessibleProxies/ExtensionManagementUtilityAccessibleProxy.php
@@ -27,7 +27,7 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
  */
 class ExtensionManagementUtilityAccessibleProxy extends ExtensionManagementUtility
 {
-    public static function setCacheManager(CacheManager $cacheManager = null): void
+    public static function setCacheManager(?CacheManager $cacheManager = null): void
     {
         static::$cacheManager = $cacheManager;
     }
diff --git a/typo3/sysext/core/Tests/Unit/Utility/IpAnonymizationUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/IpAnonymizationUtilityTest.php
index c21cb38450ee..7a2e02c5f9eb 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/IpAnonymizationUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/IpAnonymizationUtilityTest.php
@@ -56,7 +56,7 @@ class IpAnonymizationUtilityTest extends UnitTestCase
      * @param int|null $mask
      * @param string $expected
      */
-    public function anonymizeIpReturnsCorrectValue(string $address, int $mask = null, string $expected): void
+    public function anonymizeIpReturnsCorrectValue(string $address, ?int $mask, string $expected): void
     {
         // set the default if $mask is null
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['ipAnonymization'] = 1;
diff --git a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Classes/Controller/BlogController.php b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Classes/Controller/BlogController.php
index f6a7a9ec750b..647bcc4762c8 100644
--- a/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Classes/Controller/BlogController.php
+++ b/typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Classes/Controller/BlogController.php
@@ -66,7 +66,7 @@ class BlogController extends ActionController
         return $this->htmlResponse();
     }
 
-    public function detailsAction(Blog $blog = null): ResponseInterface
+    public function detailsAction(?Blog $blog = null): ResponseInterface
     {
         return $this->htmlResponse($blog ? $blog->getTitle() : '');
     }
diff --git a/typo3/sysext/extbase/Tests/Functional/Mvc/Controller/ActionControllerArgumentTest.php b/typo3/sysext/extbase/Tests/Functional/Mvc/Controller/ActionControllerArgumentTest.php
index 7e5e6ecb7e49..f4337f71b4b1 100644
--- a/typo3/sysext/extbase/Tests/Functional/Mvc/Controller/ActionControllerArgumentTest.php
+++ b/typo3/sysext/extbase/Tests/Functional/Mvc/Controller/ActionControllerArgumentTest.php
@@ -207,7 +207,7 @@ class ActionControllerArgumentTest extends FunctionalTestCase
         return $document;
     }
 
-    private function buildRequest(string $actionName, array $arguments = null): Request
+    private function buildRequest(string $actionName, ?array $arguments = null): Request
     {
         $request = new Request();
         $request->setPluginName($this->pluginName);
diff --git a/typo3/sysext/extbase/Tests/Functional/Property/PropertyMapperTest.php b/typo3/sysext/extbase/Tests/Functional/Property/PropertyMapperTest.php
index ec8345e00b89..1b1d6dbb3e8b 100644
--- a/typo3/sysext/extbase/Tests/Functional/Property/PropertyMapperTest.php
+++ b/typo3/sysext/extbase/Tests/Functional/Property/PropertyMapperTest.php
@@ -145,7 +145,7 @@ class PropertyMapperTest extends FunctionalTestCase
             protected $sourceTypes = ['integer'];
             protected $targetType = \Countable::class;
 
-            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null): bool
+            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], ?PropertyMappingConfigurationInterface $configuration = null): bool
             {
                 return true;
             }
@@ -156,7 +156,7 @@ class PropertyMapperTest extends FunctionalTestCase
             protected $sourceTypes = ['integer'];
             protected $targetType = ExtendedCountableInterface::class;
 
-            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null): bool
+            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], ?PropertyMappingConfigurationInterface $configuration = null): bool
             {
                 return true;
             }
@@ -199,7 +199,7 @@ class PropertyMapperTest extends FunctionalTestCase
     public function findTypeConverterReturnsTheConverterFromThePropertyMappingConfiguration(): void
     {
         $class = new class () extends IntegerConverter {
-            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null): int
+            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], ?PropertyMappingConfigurationInterface $configuration = null): int
             {
                 return 1575648246;
             }
@@ -259,7 +259,7 @@ class PropertyMapperTest extends FunctionalTestCase
             protected $sourceTypes = ['string'];
             protected $targetType = Cat::class;
 
-            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null): Cat
+            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], ?PropertyMappingConfigurationInterface $configuration = null): Cat
             {
                 return new Cat();
             }
@@ -282,7 +282,7 @@ class PropertyMapperTest extends FunctionalTestCase
             protected $sourceTypes = ['string'];
             protected $targetType = Animal::class;
 
-            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null): Animal
+            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], ?PropertyMappingConfigurationInterface $configuration = null): Animal
             {
                 return new Animal();
             }
@@ -305,7 +305,7 @@ class PropertyMapperTest extends FunctionalTestCase
             protected $sourceTypes = ['integer'];
             protected $targetType = \Countable::class;
 
-            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null): array
+            public function convertFrom($source, string $targetType, array $convertedChildProperties = [], ?PropertyMappingConfigurationInterface $configuration = null): array
             {
                 return [];
             }
diff --git a/typo3/sysext/extbase/Tests/Unit/Object/Container/Fixtures/ContainerConstructorInjectionTestFixtures.php b/typo3/sysext/extbase/Tests/Unit/Object/Container/Fixtures/ContainerConstructorInjectionTestFixtures.php
index f7844e8075ad..4cf0f1f5828d 100644
--- a/typo3/sysext/extbase/Tests/Unit/Object/Container/Fixtures/ContainerConstructorInjectionTestFixtures.php
+++ b/typo3/sysext/extbase/Tests/Unit/Object/Container/Fixtures/ContainerConstructorInjectionTestFixtures.php
@@ -54,7 +54,7 @@ class OptionalConstructorArgument
     /**
      * @param ArgumentTestClass|null $argumentTestClass
      */
-    public function __construct(ArgumentTestClass $argumentTestClass = null)
+    public function __construct(?ArgumentTestClass $argumentTestClass = null)
     {
         $this->argumentTestClass = $argumentTestClass;
     }
@@ -85,7 +85,7 @@ class TwoConstructorArgumentsSecondOptional
      * @param ArgumentTestClass $argumentTestClass
      * @param ArgumentTestClass|null $argumentTestClassTwo
      */
-    public function __construct(ArgumentTestClass $argumentTestClass, ArgumentTestClass $argumentTestClassTwo = null)
+    public function __construct(ArgumentTestClass $argumentTestClass, ?ArgumentTestClass $argumentTestClassTwo = null)
     {
         $this->argumentTestClass = $argumentTestClass;
         $this->argumentTestClassTwo = $argumentTestClassTwo;
@@ -109,7 +109,7 @@ class TwoConstructorArgumentsFirstOptional
      * @param ArgumentTestClass|null $argumentTestClass
      * @param ArgumentTestClass $argumentTestClassTwo
      */
-    public function __construct(ArgumentTestClass $argumentTestClass = null, ArgumentTestClass $argumentTestClassTwo)
+    public function __construct(?ArgumentTestClass $argumentTestClass, ArgumentTestClass $argumentTestClassTwo)
     {
         $this->argumentTestClass = $argumentTestClass;
         $this->argumentTestClassTwo = $argumentTestClassTwo;
@@ -125,7 +125,7 @@ class TwoConstructorArgumentsBothOptional
      * @param ArgumentTestClass|null $argumentTestClass
      * @param ArgumentTestClass|null $argumentTestClassTwo
      */
-    public function __construct(ArgumentTestClass $argumentTestClass = null, ArgumentTestClass $argumentTestClassTwo = null)
+    public function __construct(?ArgumentTestClass $argumentTestClass = null, ?ArgumentTestClass $argumentTestClassTwo = null)
     {
         $this->argumentTestClass = $argumentTestClass;
         $this->argumentTestClassTwo = $argumentTestClassTwo;
diff --git a/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/Fixtures/DateTimeSubFixture.php b/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/Fixtures/DateTimeSubFixture.php
index be801d63cdd9..73a58838829e 100644
--- a/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/Fixtures/DateTimeSubFixture.php
+++ b/typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/Fixtures/DateTimeSubFixture.php
@@ -28,7 +28,7 @@ class DateTimeSubFixture extends \DateTime
      * @param \DateTimeZone|null $timezone
      * @return DateTimeSubFixture
      */
-    public static function createFromFormat($format, $time, \DateTimeZone $timezone = null): DateTimeSubFixture
+    public static function createFromFormat($format, $time, ?\DateTimeZone $timezone = null): DateTimeSubFixture
     {
         return new self();
     }
diff --git a/typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchemaTest.php b/typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchemaTest.php
index cf0d8a677037..26942406d48f 100644
--- a/typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchemaTest.php
+++ b/typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchemaTest.php
@@ -276,7 +276,7 @@ class ClassSchemaTest extends UnitTestCase
     public function classSchemaCanHandleSelfMethodReturnTypes(): void
     {
         $class = new class () {
-            public function __construct(self $copy = null) {}
+            public function __construct(?self $copy = null) {}
             public function injectCopy(self $copy): void {}
             public function foo($copy): self
             {
diff --git a/typo3/sysext/extbase/Tests/Unit/Utility/LocalizationUtilityTest.php b/typo3/sysext/extbase/Tests/Unit/Utility/LocalizationUtilityTest.php
index 17116fe0fc5b..e02f84c985c4 100644
--- a/typo3/sysext/extbase/Tests/Unit/Utility/LocalizationUtilityTest.php
+++ b/typo3/sysext/extbase/Tests/Unit/Utility/LocalizationUtilityTest.php
@@ -327,7 +327,7 @@ class LocalizationUtilityTest extends UnitTestCase
      * @dataProvider translateDataProvider
      * @test
      */
-    public function translateTestWithBackendUserLanguage($key, $languageKey, $expected, array $altLanguageKeys = [], array $arguments = null): void
+    public function translateTestWithBackendUserLanguage($key, $languageKey, $expected, array $altLanguageKeys = [], ?array $arguments = null): void
     {
         $this->configurationManagerInterfaceProphecy
             ->getConfiguration('Framework', 'core', null)
@@ -359,7 +359,7 @@ class LocalizationUtilityTest extends UnitTestCase
      * @dataProvider translateDataProvider
      * @test
      */
-    public function translateTestWithExplicitLanguageParameters($key, $languageKey, $expected, array $altLanguageKeys = [], array $arguments = null): void
+    public function translateTestWithExplicitLanguageParameters($key, $languageKey, $expected, array $altLanguageKeys = [], ?array $arguments = null): void
     {
         $packageManagerProphecy = $this->prophesize(PackageManager::class);
         $this->configurationManagerInterfaceProphecy
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/AbstractTestCase.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/AbstractTestCase.php
index f8efe2ae861f..49784181417f 100644
--- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/AbstractTestCase.php
+++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/AbstractTestCase.php
@@ -100,7 +100,7 @@ abstract class AbstractTestCase extends FunctionalTestCase
      * @param callable|null $callback
      * @return array
      */
-    protected function keysFromTemplate(array $array, string $template, callable $callback = null): array
+    protected function keysFromTemplate(array $array, string $template, ?callable $callback = null): array
     {
         $keys = array_unique(
             array_map(
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequest/RouteTest.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequest/RouteTest.php
index cb2551a6112c..355e04f27ba7 100644
--- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequest/RouteTest.php
+++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequest/RouteTest.php
@@ -465,7 +465,7 @@ class RouteTest extends AbstractEnhancerSiteRequestTest
      * @test
      * @dataProvider routeIdentifiersAreResolvedDataProvider
      */
-    public function routeIdentifiersAreResolved(string $namespace, string $argumentName, string $queryPath, string $failureReason = null): void
+    public function routeIdentifiersAreResolved(string $namespace, string $argumentName, string $queryPath, ?string $failureReason = null): void
     {
         $query = [];
         $routeValue = 'route-value';
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkHandlingController.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkHandlingController.php
index 0c3a11534cd4..81830dcb6ac2 100644
--- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkHandlingController.php
+++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkHandlingController.php
@@ -62,7 +62,7 @@ class LinkHandlingController
      * @param array|null $configuration
      * @return string
      */
-    public function dumpPageArgumentsAction(?string $content, array $configuration = null): string
+    public function dumpPageArgumentsAction(?string $content, ?array $configuration = null): string
     {
         /** @var ServerRequestInterface $request */
         $request = $GLOBALS['TYPO3_REQUEST'];
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/TestSet.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/TestSet.php
index 5c6c5616771a..e00d990c1e1f 100644
--- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/TestSet.php
+++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/TestSet.php
@@ -67,7 +67,7 @@ class TestSet
      * @param string $type
      * @return Applicable[]
      */
-    public function getApplicables(string $type = null): array
+    public function getApplicables(?string $type = null): array
     {
         if ($type === null) {
             return $this->applicables;
diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/VariableValue.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/VariableValue.php
index 09a632e191ff..3122bf444323 100644
--- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/VariableValue.php
+++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/Framework/Builder/VariableValue.php
@@ -41,21 +41,21 @@ class VariableValue
      */
     private array $requiredDefinedVariableNames;
 
-    public static function create(string $value, Variables $defaultVariables = null): self
+    public static function create(string $value, ?Variables $defaultVariables = null): self
     {
         return new static($value, $defaultVariables);
     }
 
     public static function createUrlEncodedParams(
         string $value,
-        Variables $defaultVariables = null,
+        ?Variables $defaultVariables = null,
         string $prefix = '&'
     ): self {
         $value = self::urlEncodeParams($value, $prefix);
         return self::create($value, $defaultVariables);
     }
 
-    private function __construct(string $value, Variables $defaultVariables = null)
+    private function __construct(string $value, ?Variables $defaultVariables = null)
     {
         $variableNames = self::extractVariableNames($value);
         if ($variableNames === []) {
diff --git a/typo3/sysext/install/Tests/Unit/ExtensionScanner/Php/Matcher/Fixtures/Subject.php b/typo3/sysext/install/Tests/Unit/ExtensionScanner/Php/Matcher/Fixtures/Subject.php
index 04db96958e92..8ad491ce7c32 100644
--- a/typo3/sysext/install/Tests/Unit/ExtensionScanner/Php/Matcher/Fixtures/Subject.php
+++ b/typo3/sysext/install/Tests/Unit/ExtensionScanner/Php/Matcher/Fixtures/Subject.php
@@ -22,5 +22,5 @@ namespace TYPO3\CMS\Install\Tests\Unit\ExtensionScanner\Php\Matcher\Fixtures;
  */
 class Subject
 {
-    public function __construct(string $a = null, string $b = null, string $c = null) {}
+    public function __construct(?string $a = null, ?string $b = null, ?string $c = null) {}
 }
diff --git a/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php b/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php
index 21825be47ede..0e62f3104c01 100644
--- a/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php
+++ b/typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php
@@ -112,7 +112,7 @@ class RemoteServerTest extends UnitTestCase
      * @dataProvider prepareFileReferenceDifferencesAreCorrectDataProvider
      * @test
      */
-    public function prepareFileReferenceDifferencesAreCorrect(string $fileFileReferenceList, string $versionFileReferenceList, bool $useThumbnails, array $expected = null): void
+    public function prepareFileReferenceDifferencesAreCorrect(string $fileFileReferenceList, string $versionFileReferenceList, bool $useThumbnails, ?array $expected = null): void
     {
         $liveFileReferences = $this->getFileReferenceMocks($fileFileReferenceList);
         $versionFileReferences = $this->getFileReferenceMocks($versionFileReferenceList);
-- 
GitLab