From 4d63f7efdaa0c5b11ef5e9c8918cd018cc077676 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Wed, 13 Mar 2024 10:10:33 +0100
Subject: [PATCH] [TASK] Clean up code inconsistencies detected by phpstan
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Various places in smaller extensions were
reported in phpstan that had some inconsistencies
in their code style, which were unnecessary and are
now avoided.

Resolves: #103383
Releases: main
Change-Id: I1d9653e62e753c87e20bf8f2f9ff299a85c8726e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83449
Tested-by: Benjamin Franzke <ben@bnf.dev>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benjamin Franzke <ben@bnf.dev>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Stefan Bürk <stefan@buerk.tech>
---
 Build/phpstan/phpstan-baseline.neon           | 165 ------------------
 .../View/BackendLayout/ContentFetcher.php     |   4 +-
 .../Controller/BackendUserController.php      |  13 +-
 .../Repository/BackendUserRepository.php      |   2 +-
 .../Service/UserInformationService.php        |   2 +-
 .../Utility/File/ExtendedFileUtility.php      |  10 +-
 .../Controller/File/EditFileController.php    |   6 +-
 typo3/sysext/filelist/Classes/FileList.php    |  12 +-
 .../ContentObject/ContentObjectRenderer.php   |  17 +-
 .../FluidTemplateContentObject.php            |   2 +-
 .../ContentObject/ImageContentObject.php      |   2 +-
 .../sysext/indexed_search/Classes/Indexer.php |   2 +-
 .../ServerResponse/FileDeclaration.php        |   2 +-
 .../DatabaseIntegrityController.php           |  43 ++---
 .../Integrity/DatabaseIntegrityCheck.php      |   5 +-
 .../Service/RedirectServiceTest.php           |   5 +-
 .../Controller/BrowseLinksController.php      |   8 +-
 .../Tests/Functional/WebhookExecutionTest.php |   6 +-
 18 files changed, 65 insertions(+), 241 deletions(-)

diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon
index 29c38a368f28..be83c6f424e9 100644
--- a/Build/phpstan/phpstan-baseline.neon
+++ b/Build/phpstan/phpstan-baseline.neon
@@ -180,36 +180,11 @@ parameters:
 			count: 1
 			path: ../../typo3/sysext/backend/Classes/Utility/BackendUtility.php
 
-		-
-			message: "#^Method TYPO3\\\\CMS\\\\Backend\\\\View\\\\BackendLayout\\\\ContentFetcher\\:\\:getRuntimeCache\\(\\) should return TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Frontend\\\\VariableFrontend but returns TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Frontend\\\\FrontendInterface\\.$#"
-			count: 1
-			path: ../../typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php
-
 		-
 			message: "#^Parameter \\#2 \\$attributeValue of method TYPO3Fluid\\\\Fluid\\\\Core\\\\ViewHelper\\\\TagBuilder\\:\\:addAttribute\\(\\) expects array\\|string\\|Traversable\\|null, TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\ImageManipulation\\\\Area given\\.$#"
 			count: 1
 			path: ../../typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php
 
-		-
-			message: "#^Negated boolean expression is always false\\.$#"
-			count: 1
-			path: ../../typo3/sysext/beuser/Classes/Controller/BackendUserController.php
-
-		-
-			message: "#^Comparison operation \"\\>\\=\" between int\\<2, max\\> and 2 is always true\\.$#"
-			count: 1
-			path: ../../typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php
-
-		-
-			message: "#^Offset 'tables_modify' on array\\{tables_select\\: array\\<non\\-empty\\-string, mixed\\>, tables_modify\\: array\\<non\\-empty\\-string, mixed\\>\\} on left side of \\?\\? always exists and is not nullable\\.$#"
-			count: 1
-			path: ../../typo3/sysext/beuser/Classes/Service/UserInformationService.php
-
-		-
-			message: "#^Offset 'tables_select' on array\\{tables_select\\: array\\<non\\-empty\\-string, mixed\\>, tables_modify\\: array\\<non\\-empty\\-string, mixed\\>\\} on left side of \\?\\? always exists and is not nullable\\.$#"
-			count: 1
-			path: ../../typo3/sysext/beuser/Classes/Service/UserInformationService.php
-
 		-
 			message: "#^Property TYPO3\\\\CMS\\\\Core\\\\Authentication\\\\AbstractUserAuthentication\\:\\:\\$writeAttemptLog \\(bool\\) on left side of \\?\\? is not nullable\\.$#"
 			count: 1
@@ -675,11 +650,6 @@ parameters:
 			count: 1
 			path: ../../typo3/sysext/core/Classes/Utility/ArrayUtility.php
 
-		-
-			message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface\\:\\:getCombinedIdentifier\\(\\)\\.$#"
-			count: 1
-			path: ../../typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
-
 		-
 			message: "#^Dead catch \\- TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Exception\\\\ExistingTargetFileNameException is never thrown in the try block\\.$#"
 			count: 1
@@ -700,36 +670,6 @@ parameters:
 			count: 1
 			path: ../../typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
 
-		-
-			message: "#^Dead catch \\- TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Exception\\\\ResourceDoesNotExistException is never thrown in the try block\\.$#"
-			count: 1
-			path: ../../typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
-
-		-
-			message: "#^Method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\File\\\\ExtendedFileUtility\\:\\:func_newfile\\(\\) should return string but returns TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|null\\.$#"
-			count: 1
-			path: ../../typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
-
-		-
-			message: "#^Method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\File\\\\ExtendedFileUtility\\:\\:func_newfile\\(\\) should return string but returns false\\.$#"
-			count: 1
-			path: ../../typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
-
-		-
-			message: "#^Method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\File\\\\ExtendedFileUtility\\:\\:func_rename\\(\\) should return TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File but returns TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder\\|null\\.$#"
-			count: 1
-			path: ../../typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
-
-		-
-			message: "#^Parameter \\#2 \\$targetFolder of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:addUploadedFile\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder\\|null, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface given\\.$#"
-			count: 1
-			path: ../../typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
-
-		-
-			message: "#^Parameter \\#2 \\$targetFolder of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:moveFile\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface given\\.$#"
-			count: 1
-			path: ../../typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
-
 		-
 			message: "#^Binary operation \"&\" between string and string\\|false results in an error\\.$#"
 			count: 1
@@ -1370,16 +1310,6 @@ parameters:
 			count: 2
 			path: ../../typo3/sysext/extensionmanager/Tests/Unit/Utility/EmConfUtilityTest.php
 
-		-
-			message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface\\:\\:getCombinedIdentifier\\(\\)\\.$#"
-			count: 1
-			path: ../../typo3/sysext/filelist/Classes/Controller/File/EditFileController.php
-
-		-
-			message: "#^Unreachable statement \\- code above always terminates\\.$#"
-			count: 1
-			path: ../../typo3/sysext/filelist/Classes/FileList.php
-
 		-
 			message: "#^Method TYPO3\\\\CMS\\\\Fluid\\\\ViewHelpers\\\\Be\\\\Menus\\\\ActionMenuViewHelper\\:\\:compile\\(\\) should return string but returns null\\.$#"
 			count: 1
@@ -1410,11 +1340,6 @@ parameters:
 			count: 1
 			path: ../../typo3/sysext/fluid/Tests/Functional/ViewHelpers/Link/FileViewHelperTest.php
 
-		-
-			message: "#^Parameter \\#1 \\$fileObject of method TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer\\:\\:setCurrentFile\\(\\) expects string\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileReference\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder\\|null, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface given\\.$#"
-			count: 1
-			path: ../../typo3/sysext/fluid_styled_content/Classes/ViewHelpers/Link/ClickEnlargeViewHelper.php
-
 		-
 			message: "#^Parameter \\#2 \\$imageFile of method TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer\\:\\:imageLinkWrap\\(\\) expects string\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileReference, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface given\\.$#"
 			count: 1
@@ -1640,11 +1565,6 @@ parameters:
 			count: 1
 			path: ../../typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
 
-		-
-			message: "#^Parameter \\#1 \\$uid of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceFactory\\:\\:getFileObject\\(\\) expects int, string given\\.$#"
-			count: 2
-			path: ../../typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
-
 		-
 			message: "#^Variable \\$conf on left side of \\?\\? always exists and is not nullable\\.$#"
 			count: 14
@@ -1660,26 +1580,6 @@ parameters:
 			count: 1
 			path: ../../typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
 
-		-
-			message: "#^Variable \\$temp in empty\\(\\) always exists and is not falsy\\.$#"
-			count: 1
-			path: ../../typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
-
-		-
-			message: "#^Variable \\$valArr in empty\\(\\) always exists and is not falsy\\.$#"
-			count: 2
-			path: ../../typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
-
-		-
-			message: "#^Property TYPO3\\\\CMS\\\\Frontend\\\\ContentObject\\\\ContentObjectRenderer\\:\\:\\$currentValKey \\(string\\) on left side of \\?\\? is not nullable\\.$#"
-			count: 1
-			path: ../../typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
-
-		-
-			message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
-			count: 1
-			path: ../../typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php
-
 		-
 			message: "#^Negated boolean expression is always true\\.$#"
 			count: 1
@@ -1875,11 +1775,6 @@ parameters:
 			count: 2
 			path: ../../typo3/sysext/impexp/Classes/ImportExport.php
 
-		-
-			message: "#^Offset 'query' on array\\{scheme\\?\\: string, host\\?\\: string, port\\?\\: int\\<0, 65535\\>, user\\?\\: string, pass\\?\\: string, path\\?\\: string, query\\: string, fragment\\?\\: string\\} on left side of \\?\\? always exists and is not nullable\\.$#"
-			count: 1
-			path: ../../typo3/sysext/indexed_search/Classes/Indexer.php
-
 		-
 			message: "#^Offset int\\<0, max\\> does not exist on array\\{\\}\\.$#"
 			count: 1
@@ -1915,11 +1810,6 @@ parameters:
 			count: 1
 			path: ../../typo3/sysext/install/Classes/Service/LanguagePackService.php
 
-		-
-			message: "#^Unreachable statement \\- code above always terminates\\.$#"
-			count: 1
-			path: ../../typo3/sysext/install/Classes/SystemEnvironment/ServerResponse/FileDeclaration.php
-
 		-
 			message: "#^Negated boolean expression is always false\\.$#"
 			count: 1
@@ -1940,56 +1830,6 @@ parameters:
 			count: 1
 			path: ../../typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php
 
-		-
-			message: "#^Binary operation \"\\>\\>\" between string and 1 results in an error\\.$#"
-			count: 2
-			path: ../../typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
-
-		-
-			message: "#^Binary operation \"\\>\\>\" between string and 5 results in an error\\.$#"
-			count: 2
-			path: ../../typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
-
-		-
-			message: "#^Call to function is_array\\(\\) with string will always evaluate to false\\.$#"
-			count: 1
-			path: ../../typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
-
-		-
-			message: "#^Cannot assign offset 'type' to string\\.$#"
-			count: 2
-			path: ../../typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
-
-		-
-			message: "#^Offset 'userFunc' on 'user' in isset\\(\\) does not exist\\.$#"
-			count: 1
-			path: ../../typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
-
-		-
-			message: "#^Offset 0 on array\\{\\} in empty\\(\\) does not exist\\.$#"
-			count: 1
-			path: ../../typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
-
-		-
-			message: "#^Variable \\$var on left side of \\?\\? always exists and is not nullable\\.$#"
-			count: 5
-			path: ../../typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
-
-		-
-			message: "#^Negated boolean expression is always false\\.$#"
-			count: 1
-			path: ../../typo3/sysext/lowlevel/Classes/Integrity/DatabaseIntegrityCheck.php
-
-		-
-			message: "#^Offset 1 does not exist on non\\-empty\\-array\\<0, TYPO3\\\\CMS\\\\Redirects\\\\Event\\\\BeforeRedirectMatchDomainEvent\\>\\.$#"
-			count: 1
-			path: ../../typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php
-
-		-
-			message: "#^Right side of && is always true\\.$#"
-			count: 2
-			path: ../../typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
-
 		-
 			message: "#^Negated boolean expression is always true\\.$#"
 			count: 1
@@ -2004,8 +1844,3 @@ parameters:
 			message: "#^Strict comparison using \\=\\=\\= between non\\-falsy\\-string and '' will always evaluate to false\\.$#"
 			count: 1
 			path: ../../typo3/sysext/scheduler/Classes/CronCommand/NormalizeCommand.php
-
-		-
-			message: "#^Unreachable statement \\- code above always terminates\\.$#"
-			count: 1
-			path: ../../typo3/sysext/webhooks/Tests/Functional/WebhookExecutionTest.php
diff --git a/typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php b/typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php
index ef1529ffbe83..7e58ede2b235 100644
--- a/typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php
+++ b/typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php
@@ -24,7 +24,7 @@ use TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForContentEvent;
 use TYPO3\CMS\Backend\View\PageLayoutContext;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\CacheManager;
-use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
@@ -249,7 +249,7 @@ class ContentFetcher
         return $GLOBALS['LANG'];
     }
 
-    protected function getRuntimeCache(): VariableFrontend
+    protected function getRuntimeCache(): FrontendInterface
     {
         return GeneralUtility::makeInstance(CacheManager::class)->getCache('runtime');
     }
diff --git a/typo3/sysext/beuser/Classes/Controller/BackendUserController.php b/typo3/sysext/beuser/Classes/Controller/BackendUserController.php
index 6e8bf9e98784..38f44938e41e 100644
--- a/typo3/sysext/beuser/Classes/Controller/BackendUserController.php
+++ b/typo3/sysext/beuser/Classes/Controller/BackendUserController.php
@@ -301,9 +301,9 @@ class BackendUserController extends ActionController
     public function initiatePasswordResetAction(int $user): ResponseInterface
     {
         $context = GeneralUtility::makeInstance(Context::class);
-        /** @var BackendUser $user */
-        $user = $this->backendUserRepository->findByUid($user);
-        if (!$user || !$user->isPasswordResetEnabled() || !$context->getAspect('backend.user')->isAdmin()) {
+        /** @var BackendUser|null $userObject */
+        $userObject = $this->backendUserRepository->findByUid($user);
+        if (!$userObject || !$userObject->isPasswordResetEnabled() || !$context->getAspect('backend.user')->isAdmin()) {
             // Add an error message
             $this->addFlashMessage(
                 LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang.xlf:flashMessage.resetPassword.error.text', 'beuser') ?? '',
@@ -314,12 +314,11 @@ class BackendUserController extends ActionController
             GeneralUtility::makeInstance(PasswordReset::class)->initiateReset(
                 $this->request,
                 $context,
-                $user->getEmail()
+                $userObject->getEmail()
             );
             $this->addFlashMessage(
-                LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang.xlf:flashMessage.resetPassword.success.text', 'beuser', [$user->getEmail()]) ?? '',
-                LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang.xlf:flashMessage.resetPassword.success.title', 'beuser') ?? '',
-                ContextualFeedbackSeverity::OK
+                LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang.xlf:flashMessage.resetPassword.success.text', 'beuser', [$userObject->getEmail()]) ?? '',
+                LocalizationUtility::translate('LLL:EXT:beuser/Resources/Private/Language/locallang.xlf:flashMessage.resetPassword.success.title', 'beuser') ?? ''
             );
         }
         return new ForwardResponse('index');
diff --git a/typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php b/typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php
index f5d7fa3a7682..a08d9abb888d 100644
--- a/typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php
+++ b/typo3/sysext/beuser/Classes/Domain/Repository/BackendUserRepository.php
@@ -68,7 +68,7 @@ class BackendUserRepository extends Repository
             }
             if (count($searchConstraints) === 1) {
                 $constraints[] = reset($searchConstraints);
-            } elseif (count($searchConstraints) >= 2) {
+            } else {
                 $constraints[] = $query->logicalOr(...$searchConstraints);
             }
         }
diff --git a/typo3/sysext/beuser/Classes/Service/UserInformationService.php b/typo3/sysext/beuser/Classes/Service/UserInformationService.php
index 8251b21cc25e..72f4f7143aa8 100644
--- a/typo3/sysext/beuser/Classes/Service/UserInformationService.php
+++ b/typo3/sysext/beuser/Classes/Service/UserInformationService.php
@@ -144,7 +144,7 @@ class UserInformationService
                 }
             }
         }
-        $data['tables']['all'] = array_replace($data['tables']['tables_select'] ?? [], $data['tables']['tables_modify'] ?? []);
+        $data['tables']['all'] = array_replace($data['tables']['tables_select'], $data['tables']['tables_modify']);
 
         // DB mounts
         $dbMounts = GeneralUtility::trimExplode(',', $user->groupData['webmounts'] ?? '', true);
diff --git a/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php b/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
index 0f3ad2297d81..537b3e01b143 100644
--- a/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
+++ b/typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
@@ -560,13 +560,8 @@ class ExtendedFileUtility extends BasicFileUtility
 
     /**
      * Gets a File or a Folder object from an identifier [storage]:[fileId]
-     *
-     * @param string $identifier
-     * @return File|Folder
-     * @throws Exception\InsufficientFileAccessPermissionsException
-     * @throws Exception\InvalidFileException
      */
-    protected function getFileObject($identifier)
+    protected function getFileObject(string $identifier)
     {
         $object = $this->fileFactory->retrieveFileOrFolderObject($identifier);
         if ($object === null) {
@@ -894,9 +889,8 @@ class ExtendedFileUtility extends BasicFileUtility
      * + example "2:targetpath/targetfolder/"
      *
      * @param array $cmds Command details as described above
-     * @return string Returns the new filename upon success
      */
-    public function func_newfile($cmds)
+    public function func_newfile($cmds): File|false|null
     {
         $targetFolderObject = $this->getFileObject($cmds['target']);
         if (!$targetFolderObject instanceof Folder) {
diff --git a/typo3/sysext/filelist/Classes/Controller/File/EditFileController.php b/typo3/sysext/filelist/Classes/Controller/File/EditFileController.php
index 3bdc7b20884b..bb598b260110 100644
--- a/typo3/sysext/filelist/Classes/Controller/File/EditFileController.php
+++ b/typo3/sysext/filelist/Classes/Controller/File/EditFileController.php
@@ -36,6 +36,7 @@ use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException;
 use TYPO3\CMS\Core\Resource\Exception\InvalidFileException;
 use TYPO3\CMS\Core\Resource\FileInterface;
+use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -125,11 +126,14 @@ class EditFileController
             throw new InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889832);
         }
 
+        /** @var Folder $parentFolder */
+        $parentFolder = $file->getParentFolder();
+
         $returnUrl = GeneralUtility::sanitizeLocalUrl(
             $parsedBody['returnUrl']
             ?? $queryParams['returnUrl']
             ?? (string)$this->uriBuilder->buildUriFromRoute('media_management', [
-                'id' => $file->getParentFolder()->getCombinedIdentifier(),
+                'id' => $parentFolder->getCombinedIdentifier(),
             ])
         );
 
diff --git a/typo3/sysext/filelist/Classes/FileList.php b/typo3/sysext/filelist/Classes/FileList.php
index dcb7c30712d5..dfcd09962399 100644
--- a/typo3/sysext/filelist/Classes/FileList.php
+++ b/typo3/sysext/filelist/Classes/FileList.php
@@ -836,14 +836,10 @@ class FileList
      */
     protected function renderControl(ResourceView $resourceView): string
     {
-        if ($this->mode === Mode::MANAGE) {
-            return $this->renderControlManage($resourceView);
-        }
-        if ($this->mode === Mode::BROWSE) {
-            return $this->renderControlBrowse($resourceView);
-        }
-
-        return '';
+        return match ($this->mode) {
+            Mode::MANAGE => $this->renderControlManage($resourceView),
+            Mode::BROWSE => $this->renderControlBrowse($resourceView),
+        };
     }
 
     /**
diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index e0912cd35d74..5cec0ab764ba 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -56,6 +56,7 @@ use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\FileInterface;
 use TYPO3\CMS\Core\Resource\FileReference;
 use TYPO3\CMS\Core\Resource\Folder;
+use TYPO3\CMS\Core\Resource\FolderInterface;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Service\FlexFormService;
@@ -330,7 +331,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
     public ?LinkResultInterface $lastTypoLinkResult = null;
 
     /**
-     * @var File|FileReference|Folder|string|null Current file objects (during iterations over files)
+     * @var File|FileReference|Folder|FolderInterface|FileInterface|string|null Current file objects (during iterations over files)
      */
     protected $currentFile;
 
@@ -1022,7 +1023,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
     /**
      * Sets the current file object during iterations over files.
      *
-     * @param File|FileReference|Folder|string|null $fileObject The file object.
+     * @param File|FileReference|Folder|FileInterface|FolderInterface|string|null $fileObject The file object.
      */
     public function setCurrentFile($fileObject)
     {
@@ -1032,7 +1033,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
     /**
      * Gets the current file object during iterations over files.
      *
-     * @return File|FileReference|Folder|string|null The current file object.
+     * @return File|FileReference|Folder|FileInterface|FolderInterface|string|null The current file object.
      */
     public function getCurrentFile()
     {
@@ -2439,7 +2440,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
             $delimeter = chr((int)$delimeter);
         }
         $temp = explode($delimeter, $content);
-        if (empty($temp)) {
+        if ($temp === ['']) {
             return '';
         }
         $last = '' . (count($temp) - 1);
@@ -2776,13 +2777,13 @@ class ContentObjectRenderer implements LoggerAwareInterface
         $valArr = explode($conf['token'], $value);
 
         // return value directly by returnKey. No further processing
-        if (!empty($valArr) && (MathUtility::canBeInterpretedAsInteger($conf['returnKey'] ?? null) || ($conf['returnKey.'] ?? false))) {
+        if ($valArr !== [''] && (MathUtility::canBeInterpretedAsInteger($conf['returnKey'] ?? null) || ($conf['returnKey.'] ?? false))) {
             $key = (int)$this->stdWrapValue('returnKey', $conf ?? []);
             return $valArr[$key] ?? '';
         }
 
         // return the amount of elements. No further processing
-        if (!empty($valArr) && (($conf['returnCount'] ?? false) || ($conf['returnCount.'] ?? false))) {
+        if ($valArr !== [''] && (($conf['returnCount'] ?? false) || ($conf['returnCount.'] ?? false))) {
             $returnCount = (bool)$this->stdWrapValue('returnCount', $conf ?? []);
             return $returnCount ? count($valArr) : 0;
         }
@@ -3592,7 +3593,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
                             $fileReference = $this->getResourceFactory()->getFileReferenceObject((int)$file);
                             $fileObject = $fileReference->getOriginalFile();
                         } else {
-                            $fileObject = $this->getResourceFactory()->getFileObject($file);
+                            $fileObject = $this->getResourceFactory()->getFileObject((int)$file);
                         }
                     } elseif (preg_match('/^(0|[1-9][0-9]*):/', $file)) { // combined identifier
                         $fileObject = $this->getResourceFactory()->retrieveFileOrFolderObject($file);
@@ -4087,7 +4088,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
                 $fileObject = $this->getCurrentFile();
             } elseif (MathUtility::canBeInterpretedAsInteger($fileUidOrCurrentKeyword)) {
                 $fileFactory = GeneralUtility::makeInstance(ResourceFactory::class);
-                $fileObject = $fileFactory->getFileObject($fileUidOrCurrentKeyword);
+                $fileObject = $fileFactory->getFileObject((int)$fileUidOrCurrentKeyword);
             } else {
                 $fileObject = null;
             }
diff --git a/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
index 6b24b04f9157..5a44913d946f 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
@@ -282,7 +282,7 @@ class FluidTemplateContentObject extends AbstractContentObject
             }
         }
         $variables['data'] = $this->cObj->data;
-        $variables['current'] = $this->cObj->data[$this->cObj->currentValKey ?? null] ?? null;
+        $variables['current'] = $this->cObj->data[$this->cObj->currentValKey] ?? null;
         return $variables;
     }
 
diff --git a/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php
index f05561ababf9..3520a50f736f 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php
@@ -36,7 +36,7 @@ class ImageContentObject extends AbstractContentObject
     /**
      * Rendering the cObject, IMAGE
      *
-     * @param array $conf Array of TypoScript properties
+     * @param array|mixed $conf Array of TypoScript properties
      * @return string Output
      */
     public function render($conf = [])
diff --git a/typo3/sysext/indexed_search/Classes/Indexer.php b/typo3/sysext/indexed_search/Classes/Indexer.php
index b245ead8e0dc..7e89cf65a46d 100644
--- a/typo3/sysext/indexed_search/Classes/Indexer.php
+++ b/typo3/sysext/indexed_search/Classes/Indexer.php
@@ -412,7 +412,7 @@ class Indexer
             // Parse URL:
             $qParts = parse_url($linkSource);
             // Check for jumpurl (TYPO3 specific thing...)
-            if (($qParts['query'] ?? false) && str_contains($qParts['query'] ?? '', 'jumpurl=')) {
+            if (($qParts['query'] ?? false) && str_contains($qParts['query'], 'jumpurl=')) {
                 parse_str($qParts['query'], $getP);
                 $linkSource = $getP['jumpurl'];
                 $qParts = parse_url($linkSource);
diff --git a/typo3/sysext/install/Classes/SystemEnvironment/ServerResponse/FileDeclaration.php b/typo3/sysext/install/Classes/SystemEnvironment/ServerResponse/FileDeclaration.php
index 0ffc6945bed4..b572c025bfe8 100644
--- a/typo3/sysext/install/Classes/SystemEnvironment/ServerResponse/FileDeclaration.php
+++ b/typo3/sysext/install/Classes/SystemEnvironment/ServerResponse/FileDeclaration.php
@@ -68,7 +68,7 @@ class FileDeclaration
     protected $unexpectedContent;
 
     /**
-     * @var \Closure
+     * @var \Closure|null
      */
     protected $handler;
 
diff --git a/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php b/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
index ace39d675a5c..be069907b357 100644
--- a/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
+++ b/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php
@@ -1276,15 +1276,15 @@ class DatabaseIntegrityController
         $comparison = (int)($conf['comparison'] ?? 0);
         $var = $conf['inputValue' . $suffix] ?? '';
         if ($comparison >> 5 === 0 || ($comparison === 32 || $comparison === 33 || $comparison === 64 || $comparison === 65 || $comparison === 66 || $comparison === 67 || $comparison === 96 || $comparison === 97)) {
-            $inputVal = $var ?? null;
+            $inputVal = $var;
         } elseif ($comparison === 39 || $comparison === 38) {
             // in list:
-            $inputVal = implode(',', GeneralUtility::intExplode(',', (string)($var ?? '')));
+            $inputVal = implode(',', GeneralUtility::intExplode(',', (string)$var));
         } elseif ($comparison === 68 || $comparison === 69 || $comparison === 162 || $comparison === 163) {
             // in list:
-            if (is_array($var ?? false)) {
+            if (is_array($var)) {
                 $inputVal = implode(',', $var);
-            } elseif ($var ?? false) {
+            } elseif ($var) {
                 $inputVal = $var;
             } else {
                 $inputVal = 0;
@@ -1296,7 +1296,7 @@ class DatabaseIntegrityController
         } else {
             // TODO: Six eyes looked at this code and nobody understood completely what is going on here and why we
             // fallback to float casting, the whole class smells like it needs a refactoring.
-            $inputVal = (float)($var ?? 0.0);
+            $inputVal = (float)$var;
         }
 
         return $inputVal;
@@ -1483,12 +1483,10 @@ class DatabaseIntegrityController
     protected function cleanUpQueryConfig(array $queryConfig): array
     {
         // Since we don't traverse the array using numeric keys in the upcoming while-loop make sure it's fresh and clean before displaying
-        if (!empty($queryConfig) && is_array($queryConfig)) {
+        if (!empty($queryConfig)) {
             ksort($queryConfig);
-        } elseif (empty($queryConfig[0]['type'])) {
-            // Make sure queryConfig is an array
-            $queryConfig = [];
-            $queryConfig[0] = ['type' => 'FIELD_'];
+        } else {
+            $queryConfig = [['type' => 'FIELD_']];
         }
         // Traverse:
         foreach ($queryConfig as $key => $conf) {
@@ -1503,7 +1501,7 @@ class DatabaseIntegrityController
             }
             switch ($fieldType) {
                 case 'newlevel':
-                    if (!$queryConfig[$key]['nl']) {
+                    if (!isset($conf['nl'])) {
                         $queryConfig[$key]['nl'][0]['type'] = 'FIELD_';
                     }
                     $queryConfig[$key]['nl'] = $this->cleanUpQueryConfig($queryConfig[$key]['nl']);
@@ -1517,7 +1515,7 @@ class DatabaseIntegrityController
                     if ((int)($conf['comparison'] ?? 0) >> 5 !== (int)($this->comp_offsets[$fieldType] ?? 0)) {
                         $conf['comparison'] = (int)($this->comp_offsets[$fieldType] ?? 0) << 5;
                     }
-                    $queryConfig[$key]['comparison'] = $this->verifyComparison($conf['comparison'] ?? '' ? (string)$conf['comparison'] : '0', ($conf['negate'] ?? null) ? 1 : 0);
+                    $queryConfig[$key]['comparison'] = $this->verifyComparison($conf['comparison'] ?? 0 ? (int)$conf['comparison'] : 0, (bool)($conf['negate'] ?? null));
                     $queryConfig[$key]['inputValue'] = $this->cleanInputVal($queryConfig[$key]);
                     $queryConfig[$key]['inputValue1'] = $this->cleanInputVal($queryConfig[$key], '1');
             }
@@ -1541,10 +1539,7 @@ class DatabaseIntegrityController
         return $first;
     }
 
-    /**
-     * @param string $comparison
-     */
-    protected function verifyComparison($comparison, int $neg): int
+    protected function verifyComparison(int $comparison, bool $neg): int
     {
         $compOffSet = $comparison >> 5;
         $first = -1;
@@ -1560,10 +1555,7 @@ class DatabaseIntegrityController
         return $first;
     }
 
-    /**
-     * @param string $queryConfig
-     */
-    protected function getFormElements(int $subLevel = 0, $queryConfig = '', string $parent = ''): array
+    protected function getFormElements(int $subLevel = 0, string|array $queryConfig = null, string $parent = ''): array
     {
         $codeArr = [];
         if (!is_array($queryConfig)) {
@@ -1598,7 +1590,8 @@ class DatabaseIntegrityController
                 case 'ignore':
                     break;
                 case 'newlevel':
-                    if (!$queryConfig[$key]['nl']) {
+                    if (!is_array($queryConfig[$key]['nl'] ?? null)) {
+                        $queryConfig[$key]['nl'] = [];
                         $queryConfig[$key]['nl'][0]['type'] = 'FIELD_';
                     }
                     $lineHTML[] = '<input type="hidden" name="' . $fieldPrefix . '[type]" value="newlevel">';
@@ -1966,7 +1959,7 @@ class DatabaseIntegrityController
         $lineHTML[] = '</div>';
         $lineHTML[] = '<div class="form-group">';
         $lineHTML[] = '  <div class="input-group">';
-        $lineHTML[] =      $this->mkCompSelect($fieldPrefix . '[comparison]', (string)$conf['comparison'], ($conf['negate'] ?? null) ? 1 : 0);
+        $lineHTML[] =      $this->mkCompSelect($fieldPrefix . '[comparison]', (int)$conf['comparison'], ($conf['negate'] ?? null) ? 1 : 0);
         $lineHTML[] = '    <span class="input-group-text">';
         $lineHTML[] = '      <div class="form-check form-check-type-toggle">';
         $lineHTML[] = '        <input type="checkbox" class="form-check-input t3js-submit-click"' . (($conf['negate'] ?? null) ? ' checked' : '') . ' name="' . htmlspecialchars($fieldPrefix) . '[negate]">';
@@ -1978,7 +1971,7 @@ class DatabaseIntegrityController
         return implode(LF, $lineHTML);
     }
 
-    protected function mkCompSelect(string $name, string $comparison, int $neg): string
+    protected function mkCompSelect(string $name, int $comparison, int $neg): string
     {
         $compOffSet = $comparison >> 5;
         $out = [];
@@ -2242,11 +2235,11 @@ class DatabaseIntegrityController
                 $fieldConfig = $GLOBALS['TCA'][$this->table]['columns'][$fieldName] ?? [];
                 $this->fields[$fieldName] = $fieldConfig['config'] ?? [];
                 $this->fields[$fieldName]['exclude'] = $fieldConfig['exclude'] ?? '';
-                if (((($this->fields[$fieldName]['type'] ?? '') === 'user') && (!isset($this->fields[$fieldName]['type']['userFunc'])))
+                if (((($this->fields[$fieldName]['type'] ?? '') === 'user') && (!isset($this->fields[$fieldName]['renderType'])))
                     || ($this->fields[$fieldName]['type'] ?? '') === 'none'
                 ) {
                     // Do not list type=none "virtual" fields or query them from db,
-                    // and if type is user without defined userFunc
+                    // and if type=user without defined renderType
                     unset($this->fields[$fieldName]);
                     continue;
                 }
diff --git a/typo3/sysext/lowlevel/Classes/Integrity/DatabaseIntegrityCheck.php b/typo3/sysext/lowlevel/Classes/Integrity/DatabaseIntegrityCheck.php
index 15d5130b4238..e0487fddb814 100644
--- a/typo3/sysext/lowlevel/Classes/Integrity/DatabaseIntegrityCheck.php
+++ b/typo3/sysext/lowlevel/Classes/Integrity/DatabaseIntegrityCheck.php
@@ -399,8 +399,9 @@ class DatabaseIntegrityCheck
                 // The array index of $tableColumns is the lowercased column name!
                 // It is quoted for keywords
                 $column = $tableColumns[strtolower($fieldName)]
-                    ?? $tableColumns[$connection->quoteIdentifier(strtolower($fieldName))];
-                if (!$column) {
+                    ?? $tableColumns[$connection->quoteIdentifier(strtolower($fieldName))]
+                    ?? '';
+                if (empty($column)) {
                     // Throw meaningful exception if field does not exist in DB - 'none' is not filtered here since the
                     // method is only called with type=group fields
                     throw new \RuntimeException(
diff --git a/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php b/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php
index ab5655fa3bea..c9000e0668d8 100644
--- a/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php
+++ b/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php
@@ -867,14 +867,13 @@ final class RedirectServiceTest extends FunctionalTestCase
             ->withAttribute('frontend.user', $frontendUserAuthentication)
             ->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE);
 
+        /** @var BeforeRedirectMatchDomainEvent[] $dispatchedEvents */
         $dispatchedEvents = [];
         /** @var Container $container */
         $container = $this->get('service_container');
         $container->set(
             'before-redirect-match-domain-event-is-triggered',
-            static function (BeforeRedirectMatchDomainEvent $event) use (
-                &$dispatchedEvents
-            ): void {
+            static function (BeforeRedirectMatchDomainEvent $event) use (&$dispatchedEvents): void {
                 $dispatchedEvents[] = $event;
                 if ($event->getMatchDomainName() === '*') {
                     $event->setMatchedRedirect(['wildcard-manual-matched' => $event->getPath()]);
diff --git a/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php b/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
index a7ef489f2fdb..ff7ea47104e7 100644
--- a/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
+++ b/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php
@@ -206,9 +206,8 @@ class BrowseLinksController extends AbstractLinkBrowserController
                 if (
                     !in_array($class, $classesAnchor['all'], true)
                     || (
-                        isset($classesAnchor[$this->displayedLinkHandlerId])
-                        && in_array($class, $classesAnchor['all'], true)
-                        && is_array($classesAnchor[$this->displayedLinkHandlerId])
+                        in_array($class, $classesAnchor['all'], true)
+                        && is_array($classesAnchor[$this->displayedLinkHandlerId] ?? null)
                         && in_array($class, $classesAnchor[$this->displayedLinkHandlerId])
                     )
                 ) {
@@ -339,8 +338,7 @@ class BrowseLinksController extends AbstractLinkBrowserController
         $currentRel = '';
         if ($this->displayedLinkHandler === $this->currentLinkHandler
             && !empty($this->currentLinkParts)
-            && isset($this->linkAttributeValues['rel'])
-            && is_string($this->linkAttributeValues['rel'])
+            && is_string($this->linkAttributeValues['rel'] ?? null)
         ) {
             $currentRel = $this->linkAttributeValues['rel'];
         }
diff --git a/typo3/sysext/webhooks/Tests/Functional/WebhookExecutionTest.php b/typo3/sysext/webhooks/Tests/Functional/WebhookExecutionTest.php
index d4e80811d0c2..15adafdcad98 100644
--- a/typo3/sysext/webhooks/Tests/Functional/WebhookExecutionTest.php
+++ b/typo3/sysext/webhooks/Tests/Functional/WebhookExecutionTest.php
@@ -97,10 +97,12 @@ final class WebhookExecutionTest extends FunctionalTestCase
         self::assertEquals(1, $numberOfRequestsFired);
     }
 
+    /**
+     * @todo This test might not test what should be tested.
+     */
     #[Test]
     public function oneMessageWithMultipleRequestsIsTriggeredAndDispatched(): void
     {
-        self::markTestSkipped('Fails with phpunit 10 for unknown reasons. Probably broken since ever?');
         $numberOfRequestsFired = 0;
         $inspector = function (RequestInterface $request) use (&$numberOfRequestsFired) {
             $payload = json_decode($request->getBody()->getContents(), true);
@@ -125,6 +127,8 @@ final class WebhookExecutionTest extends FunctionalTestCase
 
         $userRequest = GeneralUtility::makeInstance(BackendUserAuthentication::class);
         $userRequest->start($request);
+        // second request
+        $userRequest->start($request);
         self::assertEquals(2, $numberOfRequestsFired);
     }
 
-- 
GitLab