From 882dba94a10d8cb849591770f1332a4ca8e243a7 Mon Sep 17 00:00:00 2001
From: Alexander Schnitzler <git@alexanderschnitzler.de>
Date: Sat, 26 Sep 2020 17:59:21 +0200
Subject: [PATCH] [TASK] Fix phpstan checkFunctionArgumentTypes errors in
 ext:recycler

This patch fixes incompatible type usage in function arguments
and is preparatory work for introducing native type hints and
strict mode in all core files.

Releases: master, 10.4
Resolves: #92173
Change-Id: I7cfd566e0dbaf0b7f2d48664a4451b8892b2aa1c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65904
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Guido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../recycler/Classes/Controller/RecyclerAjaxController.php   | 5 +++--
 .../recycler/Classes/Controller/RecyclerModuleController.php | 2 +-
 .../sysext/recycler/Classes/Domain/Model/DeletedRecords.php  | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php
index 2181f7345fdb..6b3d2b8b015e 100644
--- a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php
+++ b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php
@@ -144,7 +144,7 @@ class RecyclerAjaxController
                 $messageKey = 'flashmessage.undo.' . ($affectedRecords !== false ? 'success' : 'failure') . '.' . ((int)$affectedRecords === 1 ? 'singular' : 'plural');
                 $content = [
                     'success' => true,
-                    'message' => sprintf(LocalizationUtility::translate($messageKey, 'recycler'), $affectedRecords)
+                    'message' => sprintf((string)LocalizationUtility::translate($messageKey, 'recycler'), $affectedRecords)
                 ];
                 break;
             case 'deleteRecords':
@@ -162,7 +162,7 @@ class RecyclerAjaxController
                 $messageKey = 'flashmessage.delete.' . ($success ? 'success' : 'failure') . '.' . ($affectedRecords === 1 ? 'singular' : 'plural');
                 $content = [
                     'success' => true,
-                    'message' => sprintf(LocalizationUtility::translate($messageKey, 'recycler'), $affectedRecords)
+                    'message' => sprintf((string)LocalizationUtility::translate($messageKey, 'recycler'), $affectedRecords)
                 ];
                 break;
         }
@@ -171,6 +171,7 @@ class RecyclerAjaxController
 
     /**
      * Transforms the rows for the deleted records
+     * @param array<string, array> $deletedRowsArray
      */
     protected function transform(array $deletedRowsArray): array
     {
diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php
index a3677d0b3703..c89edcc8ec83 100644
--- a/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php
+++ b/typo3/sysext/recycler/Classes/Controller/RecyclerModuleController.php
@@ -186,7 +186,7 @@ class RecyclerModuleController
             'startUid' => $this->id,
             'isSSL' => $normalizedParams->isHttps(),
             'deleteDisable' => !$this->allowDelete,
-            'depthSelection' => $this->getDataFromSession('depthSelection', 0),
+            'depthSelection' => $this->getDataFromSession('depthSelection', '0'),
             'tableSelection' => $this->getDataFromSession('tableSelection', ''),
             'States' => $this->getBackendUser()->uc['moduleData']['web_recycler']['States']
         ];
diff --git a/typo3/sysext/recycler/Classes/Domain/Model/DeletedRecords.php b/typo3/sysext/recycler/Classes/Domain/Model/DeletedRecords.php
index ce35885dab4e..8571b264497c 100644
--- a/typo3/sysext/recycler/Classes/Domain/Model/DeletedRecords.php
+++ b/typo3/sysext/recycler/Classes/Domain/Model/DeletedRecords.php
@@ -386,6 +386,7 @@ class DeletedRecords
             $cmd = [];
             foreach ($recordsArray as $record) {
                 [$table, $uid] = explode(':', $record);
+                $uid = (int)$uid;
                 // get all parent pages and cover them
                 $pid = RecyclerUtility::getPidOfUid($uid, $table);
                 if ($pid > 0) {
-- 
GitLab