From 323a63d7e3826419258e2bd65805d055c499d0de Mon Sep 17 00:00:00 2001
From: Alexander Schnitzler <git@alexanderschnitzler.de>
Date: Sat, 26 Sep 2020 19:08:47 +0200
Subject: [PATCH] [TASK] Fix phpstan checkFunctionArgumentTypes errors in
 ext:info

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.

Resolves: #92170
Releases: master, 10.4
Change-Id: Ifdb8283844b1133224619447c4477a33186ca161
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65908
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../Controller/InfoPageTyposcriptConfigController.php       | 5 +++--
 .../info/Classes/Controller/PageInformationController.php   | 6 +++---
 .../info/Classes/Controller/TranslationStatusController.php | 4 ++--
 typo3/sysext/info/ext_tables.php                            | 6 +++---
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/typo3/sysext/info/Classes/Controller/InfoPageTyposcriptConfigController.php b/typo3/sysext/info/Classes/Controller/InfoPageTyposcriptConfigController.php
index a1582fcedcf6..f93f7fe28882 100644
--- a/typo3/sysext/info/Classes/Controller/InfoPageTyposcriptConfigController.php
+++ b/typo3/sysext/info/Classes/Controller/InfoPageTyposcriptConfigController.php
@@ -92,6 +92,7 @@ class InfoPageTyposcriptConfigController
         } else {
             if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
                 $rootLine = BackendUtility::BEgetRootLine($this->id, '', true);
+                /** @var array<string, string> $TSparts */
                 $TSparts = GeneralUtility::makeInstance(PageTsConfigLoader::class)->collect($rootLine);
                 $lines = [];
                 $pUids = [];
@@ -147,7 +148,7 @@ class InfoPageTyposcriptConfigController
                 }
 
                 $this->view->assign('tsconfParts99', 1);
-                $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_edit', null, '|'));
+                $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_edit', '', '|'));
                 $this->view->assign('lines', $lines);
                 $this->view->assign('editIcon', $editIcon);
                 $this->view->assign('editTitle', $editTitle);
@@ -200,7 +201,7 @@ class InfoPageTyposcriptConfigController
                         // Entire array
                 }
 
-                $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_hierarchy', null, '|'));
+                $this->view->assign('csh', BackendUtility::cshItem('_MOD_web_info', 'tsconfig_hierarchy', '', '|'));
                 $this->view->assign('tree', $tmpl->ext_getObjTree($pageTsConfig, '', '', '', '', $this->pObj->MOD_SETTINGS['tsconf_alphaSort']));
             }
             $this->view->assign('alphaSort', BackendUtility::getFuncCheck($this->id, 'SET[tsconf_alphaSort]', $this->pObj->MOD_SETTINGS['tsconf_alphaSort'], '', '', 'id="checkTsconf_alphaSort"'));
diff --git a/typo3/sysext/info/Classes/Controller/PageInformationController.php b/typo3/sysext/info/Classes/Controller/PageInformationController.php
index ab5465c8b2fc..13b93a1e44b9 100644
--- a/typo3/sysext/info/Classes/Controller/PageInformationController.php
+++ b/typo3/sysext/info/Classes/Controller/PageInformationController.php
@@ -101,7 +101,7 @@ class PageInformationController
         $theOutput .= '<div class="form-inline form-inline-spaced">'
             . $h_func
             . '<div class="form-group">'
-            . BackendUtility::cshItem('_MOD_web_info', 'func_' . $this->pObj->MOD_SETTINGS['pages'], null, '<span class="btn btn-default btn-sm">|</span>')
+            . BackendUtility::cshItem('_MOD_web_info', 'func_' . $this->pObj->MOD_SETTINGS['pages'], '', '<span class="btn btn-default btn-sm">|</span>')
             . '</div>'
             . '</div>'
             . $this->getTable_pages($this->id, (int)$this->pObj->MOD_SETTINGS['depth']);
@@ -385,7 +385,7 @@ class PageInformationController
             switch ($field) {
                 case 'title':
                     $showPageId = !empty($userTsConfig['options.']['pageTree.']['showPageIdWithTitle']);
-                    $pTitle = htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field], 20));
+                    $pTitle = htmlspecialchars((string)BackendUtility::getProcessedValue('pages', $field, $row[$field], 20));
                     $theData[$field] = $row['treeIcons'] . $theIcon . ($showPageId ? '[' . $row['uid'] . '] ' : '') . $pTitle;
                     break;
                 case 'php_tree_stop':
@@ -471,7 +471,7 @@ class PageInformationController
      */
     protected function getPagesTableFieldValue($field, array $row)
     {
-        return htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field]));
+        return htmlspecialchars((string)BackendUtility::getProcessedValue('pages', $field, $row[$field]));
     }
 
     /**
diff --git a/typo3/sysext/info/Classes/Controller/TranslationStatusController.php b/typo3/sysext/info/Classes/Controller/TranslationStatusController.php
index 0f47782e84c0..2783ae8f810e 100644
--- a/typo3/sysext/info/Classes/Controller/TranslationStatusController.php
+++ b/typo3/sysext/info/Classes/Controller/TranslationStatusController.php
@@ -91,7 +91,7 @@ class TranslationStatusController
             $h_func .= BackendUtility::getDropdownMenu($this->id, 'SET[lang]', $this->pObj->MOD_SETTINGS['lang'], $this->pObj->MOD_MENU['lang']);
             $theOutput .= $h_func;
             // Add CSH:
-            $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'lang', null, '<div class="form-group"><span class="btn btn-default btn-sm">|</span></div><br />');
+            $theOutput .= BackendUtility::cshItem('_MOD_web_info', 'lang', '', '<div class="form-group"><span class="btn btn-default btn-sm">|</span></div><br />');
             $theOutput .= '</div>';
             // Showing the tree:
             // Initialize starting point of page tree:
@@ -264,7 +264,7 @@ class TranslationStatusController
                             ],
                             'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
                         ]);
-                        $info = str_replace('###LANG_UID###', $languageId, $viewPageLink);
+                        $info = str_replace('###LANG_UID###', (string)$languageId, $viewPageLink);
                         $info .= '<a href="' . htmlspecialchars($editUrl)
                             . '" class="btn btn-default" title="' . $lang->sL(
                                 'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_editLanguageOverlayRecord'
diff --git a/typo3/sysext/info/ext_tables.php b/typo3/sysext/info/ext_tables.php
index c06a313b3d03..e93361461048 100644
--- a/typo3/sysext/info/ext_tables.php
+++ b/typo3/sysext/info/ext_tables.php
@@ -21,18 +21,18 @@ defined('TYPO3_MODE') or die();
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
     'web_info',
     \TYPO3\CMS\Info\Controller\PageInformationController::class,
-    null,
+    '',
     'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:mod_tx_cms_webinfo_page'
 );
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
     'web_info',
     \TYPO3\CMS\Info\Controller\TranslationStatusController::class,
-    null,
+    '',
     'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:mod_tx_cms_webinfo_lang'
 );
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
     'web_info',
     \TYPO3\CMS\Info\Controller\InfoPageTyposcriptConfigController::class,
-    null,
+    '',
     'LLL:EXT:info/Resources/Private/Language/InfoPageTsConfig.xlf:mod_pagetsconfig'
 );
-- 
GitLab