From ce5a0e640651b87da15c718edf8a059279375b35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Tue, 25 Jun 2024 13:37:12 +0200
Subject: [PATCH] [TASK] Avoid implicitly nullable class method parameter in
 `EXT:scheduler`
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]

In case of union type the null is added as additional type.

This prepares the way towards PHP 8.4 compatibility.

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

Resolves: #104203
Releases: main, 12.4, 11.5
Change-Id: I1e264d242e53e4d258abe82831e612ee43234d0d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84900
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
---
 typo3/sysext/scheduler/Classes/Task/AbstractTask.php        | 2 +-
 .../Task/FileStorageExtractionAdditionalFieldProvider.php   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/typo3/sysext/scheduler/Classes/Task/AbstractTask.php b/typo3/sysext/scheduler/Classes/Task/AbstractTask.php
index 53743fd0d8b6..d7e3bd3d950c 100644
--- a/typo3/sysext/scheduler/Classes/Task/AbstractTask.php
+++ b/typo3/sysext/scheduler/Classes/Task/AbstractTask.php
@@ -471,7 +471,7 @@ abstract class AbstractTask implements LoggerAwareInterface
      * @param int $executionID Id of the execution to remove.
      * @param \Throwable $e An exception to signal a failed execution
      */
-    public function unmarkExecution($executionID, \Throwable $e = null)
+    public function unmarkExecution($executionID, ?\Throwable $e = null)
     {
         // Get the executions for the task
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
diff --git a/typo3/sysext/scheduler/Classes/Task/FileStorageExtractionAdditionalFieldProvider.php b/typo3/sysext/scheduler/Classes/Task/FileStorageExtractionAdditionalFieldProvider.php
index fe66c2099210..6e48df6ea5b7 100644
--- a/typo3/sysext/scheduler/Classes/Task/FileStorageExtractionAdditionalFieldProvider.php
+++ b/typo3/sysext/scheduler/Classes/Task/FileStorageExtractionAdditionalFieldProvider.php
@@ -57,7 +57,7 @@ class FileStorageExtractionAdditionalFieldProvider implements AdditionalFieldPro
      * @param FileStorageExtractionTask|null $task When editing, reference to the current task object. NULL when adding.
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getAllStoragesField(FileStorageExtractionTask $task = null)
+    protected function getAllStoragesField(?FileStorageExtractionTask $task = null)
     {
         /** @var ResourceStorage[] $storages */
         $storages = GeneralUtility::makeInstance(StorageRepository::class)->findAll();
@@ -89,7 +89,7 @@ class FileStorageExtractionAdditionalFieldProvider implements AdditionalFieldPro
      * @param FileStorageExtractionTask|null $task When editing, reference to the current task object. NULL when adding.
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getFileCountField(FileStorageExtractionTask $task = null)
+    protected function getFileCountField(?FileStorageExtractionTask $task = null)
     {
         $fieldName = 'tx_scheduler[scheduler_fileStorageIndexing_fileCount]';
         $fieldId = 'scheduler_fileStorageIndexing_fileCount';
@@ -111,7 +111,7 @@ class FileStorageExtractionAdditionalFieldProvider implements AdditionalFieldPro
      * @param FileStorageExtractionTask|null $task When editing, reference to the current task object. NULL when adding.
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getRegisteredExtractorsField(FileStorageExtractionTask $task = null)
+    protected function getRegisteredExtractorsField(?FileStorageExtractionTask $task = null)
     {
         $extractors = GeneralUtility::makeInstance(ExtractorRegistry::class)->getExtractors();
 
-- 
GitLab