From 37388f26ee035087f75b5cecad32bd48dd9e3833 Mon Sep 17 00:00:00 2001
From: Daniel Goerz <daniel.goerz@posteo.de>
Date: Fri, 5 Mar 2021 11:51:53 +0100
Subject: [PATCH] [TASK] Enable phpstan parameter checkFunctionArgumentTypes

From now on, phpstan will validate arguments passed to methods
for type integrity. This patch also resolves all remaining
issues in the core up to PHP 7.4.

Running phpstan on PHP 8 is therefore disabled temporarily and
will be enabled again with another patch that resolves all
remaining PHP 8 issues regarding argument types.

Resolves: #93652
Releases: master
Change-Id: I2cbd15c5e83ae188a4d453c71b5841d424b2eef8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68191
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Richard Haeser <richard@richardhaeser.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Richard Haeser <richard@richardhaeser.com>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 Build/gitlab-ci/nightly/integrity.yml         |  11 -
 Build/gitlab-ci/pre-merge/integrity.yml       |  14 +-
 Build/phpstan.level5.neon                     |   4 +-
 phpstan.neon                                  | 316 ++++++++++++++++++
 .../ElementInformationController.php          |   2 +-
 .../Controller/EditDocumentController.php     |   4 +-
 .../Controller/File/FileController.php        |   9 +-
 .../File/ImageProcessController.php           |   2 +-
 .../Controller/PageLayoutController.php       |   2 +-
 .../Controller/Wizard/TableController.php     |   2 +-
 .../Form/Container/InlineRecordContainer.php  |   2 +-
 .../Classes/Form/Element/FileInfoElement.php  |   2 +-
 .../Classes/Template/Components/ButtonBar.php |   2 +-
 .../Buttons/Action/ShortcutButton.php         |   2 +-
 .../Classes/Utility/BackendUtility.php        |   2 +-
 .../Controller/BackendLogController.php       |   2 +-
 .../AbstractUserAuthentication.php            |   2 +-
 .../BackendUserAuthentication.php             |   2 +-
 .../Mfa/Provider/RecoveryCodesProvider.php    |   4 +-
 .../core/Classes/Charset/CharsetConverter.php |   2 +-
 .../PasswordHashing/Pbkdf2PasswordHash.php    |   2 +-
 .../core/Classes/Database/QueryGenerator.php  |   4 +-
 .../Classes/ExpressionLanguage/Resolver.php   |   2 +
 typo3/sysext/core/Classes/Html/HtmlParser.php |   4 +-
 .../core/Classes/Imaging/IconRegistry.php     |   4 +-
 .../Collection/FileCollectionRegistry.php     |   2 +-
 .../Resource/Driver/DriverRegistry.php        |   2 +-
 .../Resource/Index/ExtractorRegistry.php      |   2 +-
 .../Resource/Rendering/RendererRegistry.php   |   2 +-
 .../FileMetadataPermissionsAspect.php         |   2 +-
 .../Service/ImageProcessingService.php        |   1 +
 .../Resource/SynchronizeFolderRelations.php   |   4 +-
 .../TextExtraction/TextExtractorRegistry.php  |   2 +-
 .../Classes/Routing/Aspect/AspectFactory.php  |   2 +-
 typo3/sysext/core/Classes/Routing/Route.php   |   2 +-
 .../ClassesConfigurationFactory.php           |   2 +-
 .../Persistence/Generic/Mapper/DataMapper.php |   2 +-
 .../Classes/Property/PropertyMapper.php       |   2 +-
 .../Classes/Validation/ValidatorResolver.php  |   2 +-
 .../Classes/Controller/ListController.php     |   2 +
 .../Classes/Domain/Model/Extension.php        |   2 +-
 .../Classes/Remote/TerExtensionRemote.php     |   4 +-
 typo3/sysext/filelist/Classes/FileFacade.php  |   2 +-
 typo3/sysext/filelist/Classes/FileList.php    |   6 +-
 .../ViewHelpers/Be/Labels/CshViewHelper.php   |   2 +-
 .../Be/Menus/ActionMenuItemViewHelper.php     |   2 +-
 .../Form/AbstractFormViewHelper.php           |   2 +-
 .../ContentObject/ContentDataProcessor.php    |   2 +-
 .../ContentObject/ContentObjectRenderer.php   |   8 +-
 .../Classes/Controller/SearchController.php   |   4 +-
 .../Controller/InstallerController.php        |   2 +-
 .../Updates/DatabaseRowsUpdateWizard.php      |   2 +-
 ...orkspaceNewPlaceholderRemovalMigration.php |   4 +-
 typo3/sysext/linkvalidator/ext_tables.php     |   2 +-
 .../Classes/RecordList/DatabaseRecordList.php |   2 +-
 .../Task/FileStorageExtractionTask.php        |   3 +
 .../Classes/Task/FileStorageIndexingTask.php  |   3 +
 .../Controller/ViewModuleController.php       |   2 +-
 .../Controller/Remote/ActionHandler.php       |   4 +
 .../Controller/Remote/RemoteServer.php        |   4 +-
 .../Classes/Controller/ReviewController.php   |   2 +-
 .../Classes/Hook/DataHandlerHook.php          |   2 +-
 62 files changed, 407 insertions(+), 94 deletions(-)

diff --git a/Build/gitlab-ci/nightly/integrity.yml b/Build/gitlab-ci/nightly/integrity.yml
index d957bf165994..e8c1b8059d92 100644
--- a/Build/gitlab-ci/nightly/integrity.yml
+++ b/Build/gitlab-ci/nightly/integrity.yml
@@ -97,14 +97,3 @@ phpstan php 7.4:
   script:
     - Build/Scripts/runTests.sh -s composerInstall -p 7.4
     - Build/Scripts/runTests.sh -s phpstan -p 7.4
-phpstan php 8.0:
-  stage: integrity
-  only:
-    - schedules
-  cache:
-    key: master-composer-phpstan-80
-    paths:
-      - .cache
-  script:
-    - Build/Scripts/runTests.sh -s composerInstall -p 8.0
-    - Build/Scripts/runTests.sh -s phpstan -p 8.0
diff --git a/Build/gitlab-ci/pre-merge/integrity.yml b/Build/gitlab-ci/pre-merge/integrity.yml
index 451512c5ae39..aefbfdbdf825 100644
--- a/Build/gitlab-ci/pre-merge/integrity.yml
+++ b/Build/gitlab-ci/pre-merge/integrity.yml
@@ -98,16 +98,4 @@ phpstan php 7.4 pre-merge:
   script:
     - Build/Scripts/runTests.sh -s composerInstall -p 7.4
     - Build/Scripts/runTests.sh -s phpstan -p 7.4
-phpstan php 8.0 pre-merge:
-  stage: main
-  except:
-    refs:
-      - schedules
-      - master
-  cache:
-    key: master-composer-phpstan-80
-    paths:
-      - .cache
-  script:
-    - Build/Scripts/runTests.sh -s composerInstall -p 8.0
-    - Build/Scripts/runTests.sh -s phpstan -p 8.0
+
diff --git a/Build/phpstan.level5.neon b/Build/phpstan.level5.neon
index 5c3636c34557..71105f2edcd0 100644
--- a/Build/phpstan.level5.neon
+++ b/Build/phpstan.level5.neon
@@ -5,8 +5,8 @@ conditionalTags:
 	PHPStan\Rules\Functions\RandomIntParametersRule:
 		phpstan.rules.rule: %featureToggles.randomIntParameters%
 
-#parameters:
-#	checkFunctionArgumentTypes: true
+parameters:
+	checkFunctionArgumentTypes: true
 #	checkArgumentsPassedByReference: true
 
 services:
diff --git a/phpstan.neon b/phpstan.neon
index 5cd6a9307c8d..b6bf8f19c59c 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -37,6 +37,7 @@ parameters:
   ignoreErrors:
     # PHP8 compatibility, as phpstan cannot detect this yet.
     - "#Class GdImage not found.#"
+    - "#^Parameter \\#1 \\$disable of function libxml_disable_entity_loader expects bool, bool\\|null given\\.$#"
 
     # ignored errors for level 0
     - '#Variable \$_EXTKEY might not be defined\.#'
@@ -261,3 +262,318 @@ parameters:
       message: "#^Parameter \\#1 \\$constraint of static method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\QueryHelper\\:\\:stripLogicalOperatorPrefix\\(\\) expects string, string\\|null given\\.$#"
       count: 1
       path: typo3/sysext/core/Classes/Database/QueryView.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagesavealpha expects resource, resource\\|false given\\.$#"
+      count: 3
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagecolorallocatealpha expects resource, resource\\|false given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagefill expects resource, resource\\|false given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#4 \\$col of function imagefill expects int, int\\|false given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#"
+      count: 11
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagefilledrectangle expects resource, resource\\|false given\\.$#"
+      count: 11
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#6 \\$col of function imagefilledrectangle expects int, int\\|false given\\.$#"
+      count: 12
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$dst_im of function imagecopyresized expects resource, resource\\|false given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#6 \\$Fcolor of method TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\GraphicalFunctions\\:\\:SpacedImageTTFText\\(\\) expects int, int\\|false given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#6 \\$color of method TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\GraphicalFunctions\\:\\:renderTTFText\\(\\) expects int, int\\|false given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$destImg of method TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\GraphicalFunctions\\:\\:ImageWrite\\(\\) expects resource, resource\\|false given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagedestroy expects resource, resource\\|false given\\.$#"
+      count: 3
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#6 \\$col of function imagettftext expects int, int\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#6 \\$color of function imagefilledellipse expects int, int\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#4 \\$green of function imagecolorset expects int, float given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#5 \\$blue of function imagecolorset expects int, float given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagegif expects resource, resource\\|false given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagestring expects resource, resource\\|false given\\.$#"
+      count: 3
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#6 \\$col of function imagestring expects int, int\\|false given\\.$#"
+      count: 3
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagepng expects resource, resource\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+
+    -
+      message: "#^Parameter \\#2 \\$id of method TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\DataHandler\\:\\:getRecordProperties\\(\\) expects int, int\\|string given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/DataHandling/DataHandler.php
+
+    -
+      message: "#^Parameter \\#5 \\$id of method TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\DataHandler\\:\\:checkValue_SW\\(\\) expects int, int\\|string given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/DataHandling/DataHandler.php
+
+    -
+      message: "#^Parameter \\#1 \\$function of function call_user_func_array expects callable\\(\\)\\: mixed, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\DataHandler\\), mixed\\) given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/DataHandling/DataHandler.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#"
+      count: 6
+      path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagettftext expects resource, resource\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
+
+    -
+      message: "#^Parameter \\#6 \\$col of function imagettftext expects int, int\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagegif expects resource, resource\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagefilledrectangle expects resource, resource\\|false given\\.$#"
+      count: 4
+      path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
+
+    -
+      message: "#^Parameter \\#6 \\$col of function imagefilledrectangle expects int, int\\|false given\\.$#"
+      count: 4
+      path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
+
+    -
+      message: "#^Parameter \\#1 \\$im of function imagedestroy expects resource, resource\\|false given\\.$#"
+      count: 3
+      path: typo3/sysext/install/Classes/SystemEnvironment/Check.php
+
+    -
+      message: "#^Parameter \\#1 \\$stageRecord of method TYPO3\\\\CMS\\\\Workspaces\\\\Controller\\\\Remote\\\\ActionHandler\\:\\:getRecipientsOfStage\\(\\) expects int\\|TYPO3\\\\CMS\\\\Workspaces\\\\Domain\\\\Record\\\\StageRecord, TYPO3\\\\CMS\\\\Workspaces\\\\Domain\\\\Record\\\\StageRecord\\|null given\\.$#"
+      count: 1
+      path: typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php
+
+    -
+      message: "#^Parameter \\#2 \\$now of function strtotime expects int, int\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/scheduler/Classes/CronCommand/NormalizeCommand.php
+
+    -
+      message: "#^Parameter \\#1 \\$name of function setcookie expects string, string\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/install/Classes/Service/SessionService.php
+
+    -
+      message: "#^Unable to resolve the template type T in call to method static method Doctrine\\\\DBAL\\\\DriverManager\\:\\:getConnection\\(\\)$#"
+      count: 4
+      path: typo3/sysext/install/Classes/Controller/InstallerController.php
+
+    -
+      message: "#^Parameter \\#1 \\$params of static method Doctrine\\\\DBAL\\\\DriverManager\\:\\:getConnection\\(\\) expects array\\(\\?'wrapperClass' \\=\\> class\\-string\\<Doctrine\\\\DBAL\\\\Connection\\>\\), array\\<string, string\\>&nonEmpty given\\.$#"
+      count: 1
+      path: typo3/sysext/install/Classes/Controller/InstallerController.php
+
+    -
+      message: "#^Parameter \\#4 \\$col of function imagefill expects int, int\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
+
+    -
+      message: "#^Parameter \\#6 \\$col of function imagefilledrectangle expects int, int\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
+
+    -
+      message: "#^Parameter \\#2 \\$col of function imagecolortransparent expects int, int\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
+
+    -
+      message: "#^Parameter \\#1 \\$node of function dom_import_simplexml expects SimpleXMLElement, SimpleXMLElement\\|false given\\.$#"
+      count: 1
+      path: typo3/sysext/frontend/Classes/ContentObject/ScalableVectorGraphicsContentObject.php
+
+    -
+      message: "#^Parameter \\#1 \\$array_arg of function current expects array, object given\\.$#"
+      count: 1
+      path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
+
+    -
+      message: "#^Parameter \\#1 \\$array_arg of function key expects array, object given\\.$#"
+      count: 1
+      path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
+
+    -
+      message: "#^Parameter \\#1 \\$array_arg of function next expects array, object given\\.$#"
+      count: 1
+      path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
+
+    -
+      message: "#^Parameter \\#1 \\$array of function reset expects array, object given\\.$#"
+      count: 1
+      path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
+
+    -
+      message: "#^Parameter \\#1 \\$currentRequest of static method TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Dispatcher\\:\\:buildRequestFromCurrentRequestAndForwardResponse\\(\\) expects TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Request, TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\RequestInterface given\\.$#"
+      count: 1
+      path: typo3/sysext/extbase/Classes/Mvc/Dispatcher.php
+
+    -
+      message: "#^Parameter \\#1 \\$node of method TYPO3\\\\CMS\\\\Core\\\\Tree\\\\TableConfiguration\\\\ArrayTreeRenderer\\:\\:renderNode\\(\\) expects TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\TreeRepresentationNode, TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\TreeNode given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Tree/TableConfiguration/ArrayTreeRenderer.php
+
+    -
+      message: "#^Parameter \\#2 \\$folder of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:checkFolderActionPermission\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder\\|null, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Resource/ResourceStorage.php
+
+    -
+      message: "#^Parameter \\#1 \\$file of class TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Event\\\\AfterFileAddedEvent constructor expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ProcessedFile\\|null given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Resource/ResourceStorage.php
+
+    -
+      message: "#^Parameter \\#1 \\$file of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:replaceFile\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ProcessedFile\\|null given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Resource/ResourceStorage.php
+
+    -
+      message: "#^Parameter \\#1 \\$folder of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:isWithinFolder\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Resource/ResourceStorage.php
+
+    -
+      message: "#^Parameter \\#1 \\$address of method TYPO3\\\\CMS\\\\Core\\\\Mail\\\\Rfc822AddressesParser\\:\\:_splitAddresses\\(\\) expects string, string\\|true given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Mail/Rfc822AddressesParser.php
+
+    -
+      message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|null given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Http/Stream.php
+
+    -
+      message: "#^Parameter \\#1 \\$exception_handler of function set_exception_handler expects \\(callable\\(Throwable\\)\\: void\\)\\|null, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\Error\\\\ProductionExceptionHandler\\), 'handleException'\\) given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Error/ProductionExceptionHandler.php
+
+    -
+      message: "#^Parameter \\#1 \\$exception_handler of function set_exception_handler expects \\(callable\\(Throwable\\)\\: void\\)\\|null, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\Error\\\\DebugExceptionHandler\\), 'handleException'\\) given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
+
+    -
+      message: "#^Parameter \\#2 \\$package of method TYPO3\\\\CMS\\\\Core\\\\DependencyInjection\\\\ServiceProviderRegistry\\:\\:create\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Package\\\\Package\\|null, TYPO3\\\\CMS\\\\Core\\\\Package\\\\PackageInterface given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/DependencyInjection/ServiceProviderRegistry.php
+
+    -
+      message: "#^Parameter \\#1 \\$name of class ReflectionFunction constructor expects Closure\\|string, callable\\(\\)\\: mixed given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/DependencyInjection/ServiceProviderCompilationPass.php
+
+    -
+      message: "#^Unable to resolve the template type T in call to method static method Doctrine\\\\DBAL\\\\DriverManager\\:\\:getConnection\\(\\)$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Database/ConnectionPool.php
+
+    -
+      message: "#^Parameter \\#2 \\$algo of function password_hash expects string\\|null, int\\|string\\|null given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Crypto/PasswordHashing/AbstractArgon2PasswordHash.php
+
+    -
+      message: "#^Parameter \\#2 \\$algo of function password_needs_rehash expects string\\|null, int\\|string\\|null given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Crypto/PasswordHashing/AbstractArgon2PasswordHash.php
+
+    -
+      message: "#^Parameter \\#1 \\$manifest of method TYPO3\\\\CMS\\\\Core\\\\Core\\\\ClassLoadingInformationGenerator\\:\\:getAutoloadSectionFromManifest\\(\\) expects stdClass, object given\\.$#"
+      count: 2
+      path: typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php
+
+    -
+      message: "#^Parameter \\#1 \\$file of method TYPO3\\\\CMS\\\\Core\\\\Controller\\\\FileDumpController\\:\\:isFileValid\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|null given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Controller/FileDumpController.php
+
+    -
+      message: "#^Parameter \\#2 \\$callback of function array_walk expects callable\\(\\)\\: mixed, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Backend\\\\AbstractBackend\\), 'flushByTag'\\) given\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php
+
+    -
+      message: "#^Parameter \\#1 \\$node of method TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\Renderer\\\\UnorderedListTreeRenderer\\:\\:renderNode\\(\\) expects TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\TreeRepresentationNode, TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\TreeNode given\\.$#"
+      count: 1
+      path: typo3/sysext/backend/Classes/Tree/Renderer/UnorderedListTreeRenderer.php
+
+    -
+      message: "#^Parameter \\#1 \\$result of method TYPO3\\\\CMS\\\\Backend\\\\Controller\\\\File\\\\FileController\\:\\:flattenResultDataValue\\(\\) expects bool\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ProcessedFile given\\.$#"
+      count: 1
+      path: typo3/sysext/backend/Classes/Controller/File/FileController.php
\ No newline at end of file
diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
index 12e59c03eaca..06a94e354cf2 100644
--- a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
+++ b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
@@ -311,7 +311,7 @@ class ElementInformationController
         } else {
             $rendererRegistry = GeneralUtility::makeInstance(RendererRegistry::class);
             $fileRenderer = $rendererRegistry->getRenderer($this->fileObject);
-            $preview['url'] = PathUtility::getAbsoluteWebPath($this->fileObject->getPublicUrl());
+            $preview['url'] = PathUtility::getAbsoluteWebPath($this->fileObject->getPublicUrl() ?? '');
 
             $width = '590m';
             $height = '400m';
diff --git a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
index 2df67d9013f3..94afe4b93e52 100644
--- a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
+++ b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
@@ -2511,7 +2511,7 @@ class EditDocumentController
         }
 
         if ($action === 'edit') {
-            $record = BackendUtility::getRecord($table, $recordId);
+            $record = BackendUtility::getRecord($table, $recordId) ?? [];
             $recordTitle = BackendUtility::getRecordTitle($table, $record) ?? '';
             if ($table === 'pages') {
                 return sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editPage'), $tableTitle, $recordTitle);
@@ -2523,7 +2523,7 @@ class EditDocumentController
             if ($pageId === 0) {
                 return sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecordRootLevel'), $tableTitle, $recordTitle);
             }
-            $pageRow = BackendUtility::getRecord('pages', $pageId);
+            $pageRow = BackendUtility::getRecord('pages', $pageId) ?? [];
             $pageTitle = BackendUtility::getRecordTitle('pages', $pageRow);
             if ($recordTitle !== '') {
                 return sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecord'), $tableTitle, $recordTitle, $pageTitle);
diff --git a/typo3/sysext/backend/Classes/Controller/File/FileController.php b/typo3/sysext/backend/Classes/Controller/File/FileController.php
index 9a2948ff6606..e7a6933041bc 100644
--- a/typo3/sysext/backend/Classes/Controller/File/FileController.php
+++ b/typo3/sysext/backend/Classes/Controller/File/FileController.php
@@ -192,7 +192,12 @@ class FileController
 
         $result = [];
         if ($fileTargetObject->hasFile($processedFileName)) {
-            $result = $this->flattenResultDataValue($fileTargetObject->getStorage()->getFileInFolder($processedFileName, $fileTargetObject));
+            $fileInFolder = $fileTargetObject->getStorage()->getFileInFolder($processedFileName, $fileTargetObject);
+            if ($fileInFolder === null) {
+                $result = [];
+            } else {
+                $result = $this->flattenResultDataValue($fileInFolder);
+            }
         }
         return (new JsonResponse())->setPayload($result);
     }
@@ -306,7 +311,7 @@ class FileController
             if ($result->isImage()) {
                 $processedFile = $result->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, []);
                 if ($processedFile) {
-                    $thumbUrl = PathUtility::getAbsoluteWebPath($processedFile->getPublicUrl());
+                    $thumbUrl = PathUtility::getAbsoluteWebPath($processedFile->getPublicUrl() ?? '');
                 }
             }
             $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
diff --git a/typo3/sysext/backend/Classes/Controller/File/ImageProcessController.php b/typo3/sysext/backend/Classes/Controller/File/ImageProcessController.php
index d08e887686d5..73bc5bbb9fd4 100644
--- a/typo3/sysext/backend/Classes/Controller/File/ImageProcessController.php
+++ b/typo3/sysext/backend/Classes/Controller/File/ImageProcessController.php
@@ -54,7 +54,7 @@ class ImageProcessController implements LoggerAwareInterface
             $processedFile = $this->imageProcessingService->process($processedFileId);
 
             return new RedirectResponse(
-                GeneralUtility::locationHeaderUrl($processedFile->getPublicUrl(true))
+                GeneralUtility::locationHeaderUrl($processedFile->getPublicUrl(true) ?? '')
             );
         } catch (\Throwable $e) {
             // Fatal error occurred, which will be responded as 404
diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
index c1fb4592df51..26a6b685c70c 100644
--- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
+++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php
@@ -1114,7 +1114,7 @@ class PageLayoutController
         return sprintf(
             '%s: %s [%d]',
             $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_mod.xlf:mlang_labels_tablabel'),
-            BackendUtility::getRecordTitle('pages', $this->pageinfo),
+            BackendUtility::getRecordTitle('pages', (array)$this->pageinfo),
             $this->id
         );
     }
diff --git a/typo3/sysext/backend/Classes/Controller/Wizard/TableController.php b/typo3/sysext/backend/Classes/Controller/Wizard/TableController.php
index b8c6873b05f4..424af1bfdd8f 100644
--- a/typo3/sysext/backend/Classes/Controller/Wizard/TableController.php
+++ b/typo3/sysext/backend/Classes/Controller/Wizard/TableController.php
@@ -336,7 +336,7 @@ class TableController extends AbstractWizardController
             GeneralUtility::implodeAttributes([
                 'id' => 'typo3-tablewizard',
                 'type' => $this->inputStyle ? 'input' : 'textarea',
-                'append-rows' => $this->numNewRows,
+                'append-rows' => (string)$this->numNewRows,
                 'table' => GeneralUtility::jsonEncodeForHtmlAttribute($configuration, false),
             ], true)
         );
diff --git a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
index f2de7c40d780..03d3449f43c2 100644
--- a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
@@ -388,7 +388,7 @@ class InlineRecordContainer extends AbstractContainer
                         $processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup);
                         // Only use a thumbnail if the processing process was successful by checking if image width is set
                         if ($processedImage->getProperty('width')) {
-                            $imageUrl = $processedImage->getPublicUrl();
+                            $imageUrl = $processedImage->getPublicUrl() ?? '';
                             $thumbnail = '<img src="' . PathUtility::getAbsoluteWebPath($imageUrl) . '" ' .
                                 'width="' . $processedImage->getProperty('width') . '" ' .
                                 'height="' . $processedImage->getProperty('height') . '" ' .
diff --git a/typo3/sysext/backend/Classes/Form/Element/FileInfoElement.php b/typo3/sysext/backend/Classes/Form/Element/FileInfoElement.php
index 7d019c9a97ad..f30c6dbfc0c3 100644
--- a/typo3/sysext/backend/Classes/Form/Element/FileInfoElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/FileInfoElement.php
@@ -89,7 +89,7 @@ class FileInfoElement extends AbstractFormElement
             $content .= ' (' . htmlspecialchars(GeneralUtility::formatSize((int)$file->getSize())) . 'bytes)<br />';
             $content .= BackendUtility::getProcessedValue('sys_file', 'type', (string)$file->getType()) . ' (' . $file->getMimeType() . ')<br />';
             $content .= htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:fileMetaDataLocation')) . ': ';
-            $content .= '<a href="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($file->getPublicUrl())) . '" target="_blank" title="' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.view') . '">' . htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '</a><br />';
+            $content .= '<a href="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($file->getPublicUrl() ?? '')) . '" target="_blank" title="' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.view') . '">' . htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '</a><br />';
             $content .= '<br />';
         } else {
             $content = '<h2>' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:fileMetaErrorInvalidRecord')) . '</h2>';
diff --git a/typo3/sysext/backend/Classes/Template/Components/ButtonBar.php b/typo3/sysext/backend/Classes/Template/Components/ButtonBar.php
index 9f035bb8c034..cca148836704 100644
--- a/typo3/sysext/backend/Classes/Template/Components/ButtonBar.php
+++ b/typo3/sysext/backend/Classes/Template/Components/ButtonBar.php
@@ -88,7 +88,7 @@ class ButtonBar
      */
     public function makeButton($button)
     {
-        if (!in_array(ButtonInterface::class, class_implements($button), true)) {
+        if (!in_array(ButtonInterface::class, class_implements($button) ?: [], true)) {
             throw new \InvalidArgumentException('A Button must implement ButtonInterface', 1441706378);
         }
         return GeneralUtility::makeInstance($button);
diff --git a/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php b/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php
index 9cb219764076..1fb67f70506c 100644
--- a/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php
+++ b/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php
@@ -326,7 +326,7 @@ class ShortcutButton implements ButtonInterface, PositionInterface
         unset($arguments['returnUrl']);
 
         // Encode arguments to be stored in the database
-        $arguments = json_encode($arguments);
+        $arguments = json_encode($arguments) ?: '';
 
         if (GeneralUtility::makeInstance(ShortcutRepository::class)->shortcutExists($routeIdentifier, $arguments)) {
             return '<a class="active btn btn-default btn-sm" title="">'
diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
index 8773731d18e1..0b35a3d07028 100644
--- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php
+++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
@@ -1061,7 +1061,7 @@ class BackendUtility
                     }
                     $processedImage = $fileObject->process($taskType, $processingConfiguration);
                     $attributes = [
-                        'src' => PathUtility::getAbsoluteWebPath($processedImage->getPublicUrl()),
+                        'src' => PathUtility::getAbsoluteWebPath($processedImage->getPublicUrl() ?? ''),
                         'width' => $processedImage->getProperty('width'),
                         'height' => $processedImage->getProperty('height'),
                         'alt' => $fileReferenceObject->getName(),
diff --git a/typo3/sysext/belog/Classes/Controller/BackendLogController.php b/typo3/sysext/belog/Classes/Controller/BackendLogController.php
index 08ffeb2d59d9..cbfa7b1380e5 100644
--- a/typo3/sysext/belog/Classes/Controller/BackendLogController.php
+++ b/typo3/sysext/belog/Classes/Controller/BackendLogController.php
@@ -227,7 +227,7 @@ class BackendLogController extends ActionController
                 $targetStructure[$pid] = [];
             }
             // Get day timestamp of log entry and create sub array if needed
-            $timestampDay = strtotime(strftime('%d.%m.%Y', $entry->getTstamp()));
+            $timestampDay = strtotime(strftime('%d.%m.%Y', $entry->getTstamp()) ?: '');
             if (!is_array($targetStructure[$pid][$timestampDay])) {
                 $targetStructure[$pid][$timestampDay] = [];
             }
diff --git a/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
index d769c22d5c22..5cb97907446f 100644
--- a/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
+++ b/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
@@ -823,7 +823,7 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface
             return null;
         }
         // Fetch the user from the DB
-        $userRecord = $this->getRawUserByUid($this->userSession->getUserId());
+        $userRecord = $this->getRawUserByUid($this->userSession->getUserId() ?? 0);
         if ($userRecord) {
             // A user was found
             $userRecord['is_online'] = $this->userSession->getLastUpdated();
diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
index c4b63ce09f0d..d089bbd1b2d1 100644
--- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
+++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
@@ -1891,7 +1891,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
 
             $workspaceWebMounts = GeneralUtility::intExplode(',', $dbMountpoints);
             $webMountsOfUser = GeneralUtility::intExplode(',', $this->groupData['webmounts']);
-            $webMountsOfUser = array_combine($webMountsOfUser, $webMountsOfUser);
+            $webMountsOfUser = array_combine($webMountsOfUser, $webMountsOfUser) ?: [];
 
             $entryPointRootLineUids = [];
             foreach ($webMountsOfUser as $webMountPageId) {
diff --git a/typo3/sysext/core/Classes/Authentication/Mfa/Provider/RecoveryCodesProvider.php b/typo3/sysext/core/Classes/Authentication/Mfa/Provider/RecoveryCodesProvider.php
index a3b0c61876a9..ed3b9ecc49cd 100644
--- a/typo3/sysext/core/Classes/Authentication/Mfa/Provider/RecoveryCodesProvider.php
+++ b/typo3/sysext/core/Classes/Authentication/Mfa/Provider/RecoveryCodesProvider.php
@@ -178,7 +178,7 @@ class RecoveryCodesProvider implements MfaProviderInterface
                 $view->assignMultiple([
                     'recoveryCodes' => implode(PHP_EOL, $codes),
                     // Generate hmac of the recovery codes to prevent them from being changed in the setup from
-                    'checksum' => GeneralUtility::hmac(json_encode($codes), 'recovery-codes-setup')
+                    'checksum' => GeneralUtility::hmac(json_encode($codes) ?: '', 'recovery-codes-setup')
                 ]);
                 break;
             case MfaViewType::EDIT:
@@ -220,7 +220,7 @@ class RecoveryCodesProvider implements MfaProviderInterface
         $recoveryCodes = GeneralUtility::trimExplode(PHP_EOL, (string)($request->getParsedBody()['recoveryCodes'] ?? ''));
         $checksum = (string)($request->getParsedBody()['checksum'] ?? '');
         if ($recoveryCodes === []
-            || !hash_equals(GeneralUtility::hmac(json_encode($recoveryCodes), 'recovery-codes-setup'), $checksum)
+            || !hash_equals(GeneralUtility::hmac(json_encode($recoveryCodes) ?: '', 'recovery-codes-setup'), $checksum)
         ) {
             // Return since the request does not contain the initially created recovery codes
             return false;
diff --git a/typo3/sysext/core/Classes/Charset/CharsetConverter.php b/typo3/sysext/core/Classes/Charset/CharsetConverter.php
index 6e3749eb67f0..92b847b2c772 100644
--- a/typo3/sysext/core/Classes/Charset/CharsetConverter.php
+++ b/typo3/sysext/core/Classes/Charset/CharsetConverter.php
@@ -399,7 +399,7 @@ class CharsetConverter implements SingletonInterface
         } else {
             $int = $ord;
         }
-        return $hex ? 'x' . dechex($int) : $int;
+        return $hex ? 'x' . dechex((int)$int) : $int;
     }
 
     /********************************************
diff --git a/typo3/sysext/core/Classes/Crypto/PasswordHashing/Pbkdf2PasswordHash.php b/typo3/sysext/core/Classes/Crypto/PasswordHashing/Pbkdf2PasswordHash.php
index 6da8345dc0a9..d4bf0b5b4657 100644
--- a/typo3/sysext/core/Classes/Crypto/PasswordHashing/Pbkdf2PasswordHash.php
+++ b/typo3/sysext/core/Classes/Crypto/PasswordHashing/Pbkdf2PasswordHash.php
@@ -205,7 +205,7 @@ class Pbkdf2PasswordHash implements PasswordHashInterface
     {
         if (!strncmp('$', $salt, 1)) {
             if (!strncmp(self::PREFIX, $salt, strlen(self::PREFIX))) {
-                $saltParts = GeneralUtility::trimExplode('$', $salt, 4);
+                $saltParts = GeneralUtility::trimExplode('$', $salt, true);
                 $salt = $saltParts[2];
             }
         }
diff --git a/typo3/sysext/core/Classes/Database/QueryGenerator.php b/typo3/sysext/core/Classes/Database/QueryGenerator.php
index 471cf4e34dab..8a0bfc2124ec 100644
--- a/typo3/sysext/core/Classes/Database/QueryGenerator.php
+++ b/typo3/sysext/core/Classes/Database/QueryGenerator.php
@@ -1525,7 +1525,7 @@ class QueryGenerator
                 $nextButton = '';
 
                 if ($limitBegin) {
-                    $prevButton = '<input type="button" class="btn btn-default" value="previous ' . htmlspecialchars($limitLength) . '" data-value="' . htmlspecialchars($prevLimit . ',' . $limitLength) . '">';
+                    $prevButton = '<input type="button" class="btn btn-default" value="previous ' . htmlspecialchars((string)$limitLength) . '" data-value="' . htmlspecialchars($prevLimit . ',' . $limitLength) . '">';
                 }
                 if (!$limitLength) {
                     $limitLength = 100;
@@ -1536,7 +1536,7 @@ class QueryGenerator
                     $nextLimit = 0;
                 }
                 if ($nextLimit) {
-                    $nextButton = '<input type="button" class="btn btn-default" value="next ' . htmlspecialchars($limitLength) . '" data-value="' . htmlspecialchars($nextLimit . ',' . $limitLength) . '">';
+                    $nextButton = '<input type="button" class="btn btn-default" value="next ' . htmlspecialchars((string)$limitLength) . '" data-value="' . htmlspecialchars($nextLimit . ',' . $limitLength) . '">';
                 }
 
                 $out[] = '<div class="form-group">';
diff --git a/typo3/sysext/core/Classes/ExpressionLanguage/Resolver.php b/typo3/sysext/core/Classes/ExpressionLanguage/Resolver.php
index b7a4a881f9fe..12cdc74a1698 100644
--- a/typo3/sysext/core/Classes/ExpressionLanguage/Resolver.php
+++ b/typo3/sysext/core/Classes/ExpressionLanguage/Resolver.php
@@ -17,6 +17,7 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Core\ExpressionLanguage;
 
+use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
 use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -63,6 +64,7 @@ class Resolver
         $generalVariables = array_replace_recursive(...$generalVariables);
         $this->expressionLanguageVariables = array_replace_recursive($generalVariables, $variables);
         foreach ($functionProviders as $functionProvider) {
+            /** @var ExpressionFunctionProviderInterface[] $functionProviderInstances */
             $functionProviderInstances[] = GeneralUtility::makeInstance($functionProvider);
         }
         $this->expressionLanguage = new ExpressionLanguage(null, $functionProviderInstances);
diff --git a/typo3/sysext/core/Classes/Html/HtmlParser.php b/typo3/sysext/core/Classes/Html/HtmlParser.php
index bb0b268c7cd0..a35a7b9589cc 100644
--- a/typo3/sysext/core/Classes/Html/HtmlParser.php
+++ b/typo3/sysext/core/Classes/Html/HtmlParser.php
@@ -274,7 +274,7 @@ class HtmlParser
                         }
                     } else {
                         if ($namekey = preg_replace('/[^[:alnum:]_\\:\\-]/', '', $val) ?? '') {
-                            $name = strtolower($namekey);
+                            $name = strtolower((string)$namekey);
                             $attributesMeta[$name] = [];
                             $attributesMeta[$name]['origTag'] = $namekey;
                             $attributes[$name] = '';
@@ -525,7 +525,7 @@ class HtmlParser
                                                         $tagAttrib[0][$attr] = $params['list'][0];
                                                     }
                                                 } else {
-                                                    if (!in_array($this->caseShift($tagAttrib[0][$attr], $params['casesensitiveComp']), $this->caseShift($params['list'], $params['casesensitiveComp'], $tagName))) {
+                                                    if (!in_array($this->caseShift($tagAttrib[0][$attr], $params['casesensitiveComp']), (array)$this->caseShift($params['list'], $params['casesensitiveComp'], $tagName))) {
                                                         $tagAttrib[0][$attr] = $params['list'][0];
                                                     }
                                                 }
diff --git a/typo3/sysext/core/Classes/Imaging/IconRegistry.php b/typo3/sysext/core/Classes/Imaging/IconRegistry.php
index 7a39bc831c7a..1920a60be709 100644
--- a/typo3/sysext/core/Classes/Imaging/IconRegistry.php
+++ b/typo3/sysext/core/Classes/Imaging/IconRegistry.php
@@ -473,7 +473,7 @@ class IconRegistry implements SingletonInterface
     {
         $dir = dirname($this->backendIconDeclaration);
         $absoluteIconDeclarationPath = GeneralUtility::getFileAbsFileName($this->backendIconDeclaration);
-        $json = json_decode(file_get_contents($absoluteIconDeclarationPath), true);
+        $json = json_decode(file_get_contents($absoluteIconDeclarationPath) ?: '', true);
         foreach ($json['icons'] ?? [] as $declaration) {
             $iconOptions = [
                 'sprite' => $dir . '/' . $declaration['sprite'],
@@ -536,7 +536,7 @@ class IconRegistry implements SingletonInterface
      */
     public function registerIcon($identifier, $iconProviderClassName, array $options = [])
     {
-        if (!in_array(IconProviderInterface::class, class_implements($iconProviderClassName), true)) {
+        if (!in_array(IconProviderInterface::class, class_implements($iconProviderClassName) ?: [], true)) {
             throw new \InvalidArgumentException('An IconProvider must implement '
                 . IconProviderInterface::class, 1437425803);
         }
diff --git a/typo3/sysext/core/Classes/Resource/Collection/FileCollectionRegistry.php b/typo3/sysext/core/Classes/Resource/Collection/FileCollectionRegistry.php
index 412a5389e623..3a4d8040562e 100644
--- a/typo3/sysext/core/Classes/Resource/Collection/FileCollectionRegistry.php
+++ b/typo3/sysext/core/Classes/Resource/Collection/FileCollectionRegistry.php
@@ -59,7 +59,7 @@ class FileCollectionRegistry implements SingletonInterface
             throw new \InvalidArgumentException('Class ' . $className . ' does not exist.', 1391295613);
         }
 
-        if (!in_array(AbstractFileCollection::class, class_parents($className), true)) {
+        if (!in_array(AbstractFileCollection::class, class_parents($className) ?: [], true)) {
             throw new \InvalidArgumentException('FileCollection ' . $className . ' needs to extend the AbstractFileCollection.', 1391295633);
         }
 
diff --git a/typo3/sysext/core/Classes/Resource/Driver/DriverRegistry.php b/typo3/sysext/core/Classes/Resource/Driver/DriverRegistry.php
index f506b17a54bf..3cdf16876a1f 100644
--- a/typo3/sysext/core/Classes/Resource/Driver/DriverRegistry.php
+++ b/typo3/sysext/core/Classes/Resource/Driver/DriverRegistry.php
@@ -64,7 +64,7 @@ class DriverRegistry implements SingletonInterface
             throw new \InvalidArgumentException('Class ' . $className . ' does not exist.', 1314979197);
         }
 
-        if (!in_array(DriverInterface::class, class_implements($className), true)) {
+        if (!in_array(DriverInterface::class, class_implements($className) ?: [], true)) {
             throw new \InvalidArgumentException('Driver ' . $className . ' needs to implement the DriverInterface.', 1387619575);
         }
         if ($shortName === '') {
diff --git a/typo3/sysext/core/Classes/Resource/Index/ExtractorRegistry.php b/typo3/sysext/core/Classes/Resource/Index/ExtractorRegistry.php
index 6ba66e0e38f8..262de490824a 100644
--- a/typo3/sysext/core/Classes/Resource/Index/ExtractorRegistry.php
+++ b/typo3/sysext/core/Classes/Resource/Index/ExtractorRegistry.php
@@ -57,7 +57,7 @@ class ExtractorRegistry implements SingletonInterface
         if (!class_exists($className)) {
             throw new \InvalidArgumentException('The class "' . $className . '" you are registering is not available', 1422705270);
         }
-        if (!in_array(ExtractorInterface::class, class_implements($className))) {
+        if (!in_array(ExtractorInterface::class, class_implements($className) ?: [])) {
             throw new \InvalidArgumentException('The extractor needs to implement the ExtractorInterface', 1422705271);
         }
         $this->extractors[] = $className;
diff --git a/typo3/sysext/core/Classes/Resource/Rendering/RendererRegistry.php b/typo3/sysext/core/Classes/Resource/Rendering/RendererRegistry.php
index 59791d34249f..747cec68eb0c 100644
--- a/typo3/sysext/core/Classes/Resource/Rendering/RendererRegistry.php
+++ b/typo3/sysext/core/Classes/Resource/Rendering/RendererRegistry.php
@@ -59,7 +59,7 @@ class RendererRegistry implements SingletonInterface
         if (!class_exists($className)) {
             throw new \InvalidArgumentException('The class "' . $className . '" you are trying to register is not available', 1411840171);
         }
-        if (!in_array(FileRendererInterface::class, class_implements($className), true)) {
+        if (!in_array(FileRendererInterface::class, class_implements($className) ?: [], true)) {
             throw new \InvalidArgumentException('The renderer needs to implement the FileRendererInterface', 1411840172);
         }
         $this->classNames[] = $className;
diff --git a/typo3/sysext/core/Classes/Resource/Security/FileMetadataPermissionsAspect.php b/typo3/sysext/core/Classes/Resource/Security/FileMetadataPermissionsAspect.php
index 2e80e3c2b6c5..b05e4b522f50 100644
--- a/typo3/sysext/core/Classes/Resource/Security/FileMetadataPermissionsAspect.php
+++ b/typo3/sysext/core/Classes/Resource/Security/FileMetadataPermissionsAspect.php
@@ -92,7 +92,7 @@ class FileMetadataPermissionsAspect implements DataHandlerCheckModifyAccessListH
                     $recordAccessAllowed = false;
 
                     if (strpos((string)$id, 'NEW') === false) {
-                        $fileMetadataRecord = BackendUtility::getRecord('sys_file_metadata', $id);
+                        $fileMetadataRecord = BackendUtility::getRecord('sys_file_metadata', (int)$id);
                         if ($fileMetadataRecord !== null) {
                             if ($parent->isImporting && empty($fileMetadataRecord['file'])) {
                                 // When importing the record was added with an empty file relation as first step
diff --git a/typo3/sysext/core/Classes/Resource/Service/ImageProcessingService.php b/typo3/sysext/core/Classes/Resource/Service/ImageProcessingService.php
index cccb3fd2a27e..65a8c64d5210 100644
--- a/typo3/sysext/core/Classes/Resource/Service/ImageProcessingService.php
+++ b/typo3/sysext/core/Classes/Resource/Service/ImageProcessingService.php
@@ -61,6 +61,7 @@ class ImageProcessingService
             $this->locker->acquireLock(self::class, $processedFileId);
 
             // Fetch the processed file again, as it might have been processed by another process while waiting for the lock
+            /** @var ProcessedFile $processedFile */
             $processedFile = $this->processedFileRepository->findByUid($processedFileId);
             $this->validateProcessedFile($processedFile);
 
diff --git a/typo3/sysext/core/Classes/Resource/SynchronizeFolderRelations.php b/typo3/sysext/core/Classes/Resource/SynchronizeFolderRelations.php
index 611d30257e52..c10821822244 100644
--- a/typo3/sysext/core/Classes/Resource/SynchronizeFolderRelations.php
+++ b/typo3/sysext/core/Classes/Resource/SynchronizeFolderRelations.php
@@ -82,7 +82,7 @@ class SynchronizeFolderRelations
         }
 
         if ($synchronized) {
-            $this->addFlashMessage($synchronized, 'sys_file_collection', 'afterFolderRenamed');
+            $this->addFlashMessage((int)$synchronized, 'sys_file_collection', 'afterFolderRenamed');
         }
     }
 
@@ -123,7 +123,7 @@ class SynchronizeFolderRelations
         }
 
         if ($synchronized) {
-            $this->addFlashMessage($synchronized, 'sys_filemounts', 'afterFolderRenamed');
+            $this->addFlashMessage((int)$synchronized, 'sys_filemounts', 'afterFolderRenamed');
         }
     }
 
diff --git a/typo3/sysext/core/Classes/Resource/TextExtraction/TextExtractorRegistry.php b/typo3/sysext/core/Classes/Resource/TextExtraction/TextExtractorRegistry.php
index 48b03b6531f1..50c37597d28b 100644
--- a/typo3/sysext/core/Classes/Resource/TextExtraction/TextExtractorRegistry.php
+++ b/typo3/sysext/core/Classes/Resource/TextExtraction/TextExtractorRegistry.php
@@ -60,7 +60,7 @@ class TextExtractorRegistry implements SingletonInterface
             throw new \InvalidArgumentException('The class "' . $className . '" you are trying to register is not available', 1422906893);
         }
 
-        if (!in_array(TextExtractorInterface::class, class_implements($className), true)) {
+        if (!in_array(TextExtractorInterface::class, class_implements($className) ?: [], true)) {
             throw new \InvalidArgumentException($className . ' must implement interface' . TextExtractorInterface::class, 1422771427);
         }
 
diff --git a/typo3/sysext/core/Classes/Routing/Aspect/AspectFactory.php b/typo3/sysext/core/Classes/Routing/Aspect/AspectFactory.php
index 6117675a6213..7dea0ff3f293 100644
--- a/typo3/sysext/core/Classes/Routing/Aspect/AspectFactory.php
+++ b/typo3/sysext/core/Classes/Routing/Aspect/AspectFactory.php
@@ -115,7 +115,7 @@ class AspectFactory
     protected function enrich(AspectInterface $aspect, SiteLanguage $language, Site $site): AspectInterface
     {
         // the check for the trait is @deprecated and can be removed at any time after TYPO3 v11
-        if ($aspect instanceof SiteLanguageAwareInterface || in_array(SiteLanguageAwareTrait::class, class_uses($aspect), true)) {
+        if ($aspect instanceof SiteLanguageAwareInterface || in_array(SiteLanguageAwareTrait::class, class_uses($aspect) ?: [], true)) {
             /** @var AspectInterface|SiteLanguageAwareInterface $aspect */
             $aspect->setSiteLanguage($language);
         }
diff --git a/typo3/sysext/core/Classes/Routing/Route.php b/typo3/sysext/core/Classes/Routing/Route.php
index 3c8a509e48cd..e6e9a9a50bb2 100644
--- a/typo3/sysext/core/Classes/Routing/Route.php
+++ b/typo3/sysext/core/Classes/Routing/Route.php
@@ -180,7 +180,7 @@ class Route extends SymfonyRoute
         return array_filter(
             $aspects,
             function (AspectInterface $aspect) use ($classNames) {
-                $uses = class_uses($aspect);
+                $uses = class_uses($aspect) ?: [];
                 foreach ($classNames as $className) {
                     if (!is_a($aspect, $className)
                         && !in_array($className, $uses, true)
diff --git a/typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php b/typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php
index 8fd52a3005ca..e97f31f21460 100644
--- a/typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php
+++ b/typo3/sysext/extbase/Classes/Persistence/ClassesConfigurationFactory.php
@@ -115,7 +115,7 @@ final class ClassesConfigurationFactory implements SingletonInterface
              * parents of $className until one of these parents.
              */
             $relevantParentClasses = [];
-            $parentClasses = class_parents($className);
+            $parentClasses = class_parents($className) ?: [];
             while (null !== $parentClass = array_shift($parentClasses)) {
                 if (in_array($parentClass, [AbstractEntity::class, AbstractValueObject::class], true)) {
                     break;
diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
index 52f31b8db6fe..16b43e78c895 100644
--- a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
+++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
@@ -197,7 +197,7 @@ class DataMapper
     {
         // Note: The class_implements() function also invokes autoload to assure that the interfaces
         // and the class are loaded. Would end up with __PHP_Incomplete_Class without it.
-        if (!in_array(DomainObjectInterface::class, class_implements($className))) {
+        if (!in_array(DomainObjectInterface::class, class_implements($className) ?: [])) {
             throw new CannotReconstituteObjectException('Cannot create empty instance of the class "' . $className
                 . '" because it does not implement the TYPO3\\CMS\\Extbase\\DomainObject\\DomainObjectInterface.', 1234386924);
         }
diff --git a/typo3/sysext/extbase/Classes/Property/PropertyMapper.php b/typo3/sysext/extbase/Classes/Property/PropertyMapper.php
index 1cc653e925da..941d3771ef6f 100644
--- a/typo3/sysext/extbase/Classes/Property/PropertyMapper.php
+++ b/typo3/sysext/extbase/Classes/Property/PropertyMapper.php
@@ -306,7 +306,7 @@ class PropertyMapper implements SingletonInterface
             }
         }
 
-        $converters = $this->getConvertersForInterfaces($convertersForSource, class_implements($targetClass));
+        $converters = $this->getConvertersForInterfaces($convertersForSource, class_implements($targetClass) ?: []);
         $converter = $this->findEligibleConverterWithHighestPriority($converters, $source, $targetClass);
 
         if ($converter !== null) {
diff --git a/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php b/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php
index 256b4783b738..8e44962f189d 100644
--- a/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php
+++ b/typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php
@@ -158,7 +158,7 @@ class ValidatorResolver implements SingletonInterface
                             ]
                         );
                         $objectValidator->addPropertyValidator($property->getName(), $collectionValidator);
-                    } elseif (class_exists($propertyTargetClassName) && !TypeHandlingUtility::isCoreType($propertyTargetClassName) && !in_array(SingletonInterface::class, class_implements($propertyTargetClassName, true), true)) {
+                    } elseif (class_exists($propertyTargetClassName) && !TypeHandlingUtility::isCoreType($propertyTargetClassName) && !in_array(SingletonInterface::class, class_implements($propertyTargetClassName, true) ?: [], true)) {
                         /*
                          * class_exists($propertyTargetClassName) checks, if the type of the property is an object
                          * instead of a simple type. Like DateTime or another model.
diff --git a/typo3/sysext/extensionmanager/Classes/Controller/ListController.php b/typo3/sysext/extensionmanager/Classes/Controller/ListController.php
index 4a5db1f3d218..3bd4809b7016 100644
--- a/typo3/sysext/extensionmanager/Classes/Controller/ListController.php
+++ b/typo3/sysext/extensionmanager/Classes/Controller/ListController.php
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
 use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator;
+use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
 use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
 use TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository;
@@ -207,6 +208,7 @@ class ListController extends AbstractModuleController
             $paginator = new ArrayPaginator($extensions, $currentPage);
             $tableId = 'terSearchTable';
         } else {
+            /** @var QueryResultInterface $extensions */
             $extensions = $this->extensionRepository->findAll();
             $paginator = new QueryResultPaginator($extensions, $currentPage);
             $tableId = 'terTable';
diff --git a/typo3/sysext/extensionmanager/Classes/Domain/Model/Extension.php b/typo3/sysext/extensionmanager/Classes/Domain/Model/Extension.php
index 889fdb735c3d..4a9ac9536e0d 100644
--- a/typo3/sysext/extensionmanager/Classes/Domain/Model/Extension.php
+++ b/typo3/sysext/extensionmanager/Classes/Domain/Model/Extension.php
@@ -676,7 +676,7 @@ class Extension extends AbstractEntity
             }
             foreach ($dependencyValues as $dependency => $versionConstraint) {
                 if ($dependency) {
-                    $dependencyObject = Dependency::createFromEmConf($dependency, $versionConstraint, $dependencyType);
+                    $dependencyObject = Dependency::createFromEmConf((string)$dependency, $versionConstraint, (string)$dependencyType);
                     $dependenciesObject->attach($dependencyObject);
                 }
             }
diff --git a/typo3/sysext/extensionmanager/Classes/Remote/TerExtensionRemote.php b/typo3/sysext/extensionmanager/Classes/Remote/TerExtensionRemote.php
index 113f5f7361c5..2e8a69bfdbd8 100644
--- a/typo3/sysext/extensionmanager/Classes/Remote/TerExtensionRemote.php
+++ b/typo3/sysext/extensionmanager/Classes/Remote/TerExtensionRemote.php
@@ -101,7 +101,7 @@ class TerExtensionRemote implements ExtensionDownloaderRemoteInterface, Listable
         try {
             $response = $this->downloadFile('extensions.md5');
             $md5SumOfRemoteExtensionListFile = $response->getBody()->getContents();
-            return hash_equals($md5SumOfRemoteExtensionListFile, md5_file($this->localExtensionListCacheFile));
+            return hash_equals($md5SumOfRemoteExtensionListFile, md5_file($this->localExtensionListCacheFile) ?: '');
         } catch (DownloadFailedException $exception) {
             return false;
         }
@@ -203,7 +203,7 @@ class TerExtensionRemote implements ExtensionDownloaderRemoteInterface, Listable
         [$expectedHash, $compressionType, $contents] = explode(':', $stream, 3);
         if ($compressionType === 'gzcompress') {
             if (function_exists('gzuncompress')) {
-                $contents = gzuncompress($contents);
+                $contents = gzuncompress($contents) ?: '';
             } else {
                 throw new VerificationFailedException('No decompressor available for compressed content. gzcompress()/gzuncompress() functions are not available', 1601370681);
             }
diff --git a/typo3/sysext/filelist/Classes/FileFacade.php b/typo3/sysext/filelist/Classes/FileFacade.php
index 189710edea89..32741b66e7ab 100644
--- a/typo3/sysext/filelist/Classes/FileFacade.php
+++ b/typo3/sysext/filelist/Classes/FileFacade.php
@@ -134,7 +134,7 @@ class FileFacade
      */
     public function getPublicUrl()
     {
-        return PathUtility::getAbsoluteWebPath($this->resource->getPublicUrl());
+        return PathUtility::getAbsoluteWebPath($this->resource->getPublicUrl() ?? '');
     }
 
     /**
diff --git a/typo3/sysext/filelist/Classes/FileList.php b/typo3/sysext/filelist/Classes/FileList.php
index 21f7c4e56c52..4ea3ae756bc6 100644
--- a/typo3/sysext/filelist/Classes/FileList.php
+++ b/typo3/sysext/filelist/Classes/FileList.php
@@ -567,7 +567,7 @@ class FileList
             // The icon with link
             $theIcon = '<span title="' . htmlspecialchars($folderName) . '">' . $this->iconFactory->getIconForResource($folderObject, Icon::SIZE_SMALL)->render() . '</span>';
             if (!$isLocked) {
-                $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'sys_file', $folderObject->getCombinedIdentifier());
+                $theIcon = (string)BackendUtility::wrapClickMenuOnIcon($theIcon, 'sys_file', $folderObject->getCombinedIdentifier());
             }
 
             // Preparing and getting the data-array
@@ -716,7 +716,7 @@ class FileList
             // The icon with link
             $theIcon = '<span title="' . htmlspecialchars($fileName . ' [' . (int)$fileObject->getUid() . ']') . '">'
                 . $this->iconFactory->getIconForResource($fileObject, Icon::SIZE_SMALL)->render() . '</span>';
-            $theIcon = BackendUtility::wrapClickMenuOnIcon($theIcon, 'sys_file', $fileObject->getCombinedIdentifier());
+            $theIcon = (string)BackendUtility::wrapClickMenuOnIcon($theIcon, 'sys_file', $fileObject->getCombinedIdentifier());
             // Preparing and getting the data-array
             $theData = [];
             foreach ($this->fieldArray as $field) {
@@ -806,7 +806,7 @@ class FileList
                                     'height' => $this->thumbnailConfiguration->getHeight(),
                                 ]
                             );
-                            $theData[$field] .= '<br /><img src="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($processedFile->getPublicUrl())) . '" ' .
+                            $theData[$field] .= '<br /><img src="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($processedFile->getPublicUrl() ?? '')) . '" ' .
                                 'width="' . htmlspecialchars($processedFile->getProperty('width')) . '" ' .
                                 'height="' . htmlspecialchars($processedFile->getProperty('height')) . '" ' .
                                 'title="' . htmlspecialchars($fileName) . '" alt="" />';
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Labels/CshViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Labels/CshViewHelper.php
index ac84acb772de..e06211deb7ef 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Labels/CshViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Labels/CshViewHelper.php
@@ -112,7 +112,7 @@ class CshViewHelper extends AbstractBackendViewHelper
             $label = self::getLanguageService()->sL($label);
         }
         // Double encode can be set to true, once the typo3fluid/fluid fix is released and required
-        $label = '<label>' . htmlspecialchars($label, ENT_QUOTES, null, false) . '</label>';
+        $label = '<label>' . htmlspecialchars($label, ENT_QUOTES, '', false) . '</label>';
         return BackendUtility::wrapInHelp($table, $field, $label);
     }
 }
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php
index df6ad8e17772..6887a91d9356 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php
@@ -95,7 +95,7 @@ class ActionMenuItemViewHelper extends AbstractTagBasedViewHelper
 
         $this->tag->setContent(
             // Double encode can be set to true, once the typo3fluid/fluid fix is released and required
-            htmlspecialchars($label, ENT_QUOTES, null, false)
+            htmlspecialchars($label, ENT_QUOTES, '', false)
         );
         return $this->tag->render();
     }
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormViewHelper.php
index 024921d28099..bb3a5b9ab570 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormViewHelper.php
@@ -96,7 +96,7 @@ abstract class AbstractFormViewHelper extends AbstractTagBasedViewHelper
         $name = $this->prefixFieldName($name) . '[__identity]';
         $this->registerFieldNameForFormTokenGeneration($name);
 
-        return LF . '<input type="hidden" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($identifier) . '" />' . LF;
+        return LF . '<input type="hidden" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars((string)$identifier) . '" />' . LF;
     }
 
     /**
diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentDataProcessor.php b/typo3/sysext/frontend/Classes/ContentObject/ContentDataProcessor.php
index 052fa1362b04..01671561c9fa 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentDataProcessor.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentDataProcessor.php
@@ -47,7 +47,7 @@ class ContentDataProcessor
                     throw new \UnexpectedValueException('Processor class name "' . $className . '" does not exist!', 1427455378);
                 }
 
-                if (!in_array(DataProcessorInterface::class, class_implements($className), true)) {
+                if (!in_array(DataProcessorInterface::class, class_implements($className) ?: [], true)) {
                     throw new \UnexpectedValueException(
                         'Processor with class name "' . $className . '" ' .
                         'must implement interface "' . DataProcessorInterface::class . '"',
diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index 9c24a3a85eab..b54dab4e9161 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -1086,7 +1086,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
             if ($conf['JSwindow']) {
                 $altUrl = $this->stdWrapValue('altUrl', $conf['JSwindow.'] ?? []);
                 if ($altUrl) {
-                    $url = $altUrl . ($conf['JSwindow.']['altUrl_noDefaultParams'] ? '' : '?file=' . rawurlencode($imageFile) . $params);
+                    $url = $altUrl . ($conf['JSwindow.']['altUrl_noDefaultParams'] ? '' : '?file=' . rawurlencode((string)$imageFile) . $params);
                 }
 
                 $processedFile = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $conf);
@@ -1117,9 +1117,9 @@ class ContentObjectRenderer implements LoggerAwareInterface
 
                 $onClick = 'openPic('
                     . GeneralUtility::quoteJSvalue($this->getTypoScriptFrontendController()->baseUrlWrap($url)) . ','
-                    . '\'' . ($newWindow ? md5($url) : 'thePicture') . '\','
+                    . '\'' . ($newWindow ? md5((string)$url) : 'thePicture') . '\','
                     . GeneralUtility::quoteJSvalue(rtrim($paramString, ',')) . '); return false;';
-                $a1 = '<a href="' . htmlspecialchars($url) . '"'
+                $a1 = '<a href="' . htmlspecialchars((string)$url) . '"'
                     . ' onclick="' . htmlspecialchars($onClick) . '"'
                     . ($target !== '' ? ' target="' . htmlspecialchars($target) . '"' : '')
                     . $this->getTypoScriptFrontendController()->ATagParams . '>';
@@ -1970,7 +1970,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
             ? gmstrftime($conf['strftime'] ?? null, $content)
             : strftime($conf['strftime'] ?? null, $content);
         if (!empty($conf['strftime.']['charset'])) {
-            $output = mb_convert_encoding($content, 'utf-8', trim(strtolower($conf['strftime.']['charset'])));
+            $output = mb_convert_encoding((string)$content, 'utf-8', trim(strtolower($conf['strftime.']['charset'])));
             return $output ?: $content;
         }
         return $content;
diff --git a/typo3/sysext/indexed_search/Classes/Controller/SearchController.php b/typo3/sysext/indexed_search/Classes/Controller/SearchController.php
index fba53af49a28..6f43f7c057df 100644
--- a/typo3/sysext/indexed_search/Classes/Controller/SearchController.php
+++ b/typo3/sysext/indexed_search/Classes/Controller/SearchController.php
@@ -1107,7 +1107,7 @@ class SearchController extends ActionController
             }
 
             // disable single entries by TypoScript
-            $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['languageUid']);
+            $allOptions = $this->removeOptionsFromOptionList($allOptions, (array)$blindSettings['languageUid']);
         } else {
             $allOptions = [];
         }
@@ -1202,7 +1202,7 @@ class SearchController extends ActionController
                 }
             }
             // disable single entries by TypoScript
-            $allOptions = $this->removeOptionsFromOptionList($allOptions, $blindSettings['indexingConfigurations']);
+            $allOptions = $this->removeOptionsFromOptionList($allOptions, (array)$blindSettings['indexingConfigurations']);
         } else {
             $allOptions = [];
         }
diff --git a/typo3/sysext/install/Classes/Controller/InstallerController.php b/typo3/sysext/install/Classes/Controller/InstallerController.php
index 1f81883f9a95..1625918b4d1e 100644
--- a/typo3/sysext/install/Classes/Controller/InstallerController.php
+++ b/typo3/sysext/install/Classes/Controller/InstallerController.php
@@ -1090,7 +1090,7 @@ For each website you need a TypoScript template on the main page of your website
         $this->lateBootService->loadExtLocalconfDatabaseAndExtTables();
         if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $updateClassName) {
-                if (!in_array(RepeatableInterface::class, class_implements($updateClassName), true)) {
+                if (!in_array(RepeatableInterface::class, class_implements($updateClassName) ?: [], true)) {
                     $this->registry->set('installUpdate', $updateClassName, 1);
                 }
             }
diff --git a/typo3/sysext/install/Classes/Updates/DatabaseRowsUpdateWizard.php b/typo3/sysext/install/Classes/Updates/DatabaseRowsUpdateWizard.php
index effd3fda0121..aef97508c8df 100644
--- a/typo3/sysext/install/Classes/Updates/DatabaseRowsUpdateWizard.php
+++ b/typo3/sysext/install/Classes/Updates/DatabaseRowsUpdateWizard.php
@@ -164,7 +164,7 @@ class DatabaseRowsUpdateWizard implements UpgradeWizardInterface, RepeatableInte
         // and throw away all tables before that start point.
         sort($listOfAllTables);
         reset($listOfAllTables);
-        $firstTable = current($listOfAllTables);
+        $firstTable = current($listOfAllTables) ?: '';
         $startPosition = $this->getStartPosition($firstTable);
         foreach ($listOfAllTables as $key => $table) {
             if ($table === $startPosition['table']) {
diff --git a/typo3/sysext/install/Classes/Updates/RowUpdater/WorkspaceNewPlaceholderRemovalMigration.php b/typo3/sysext/install/Classes/Updates/RowUpdater/WorkspaceNewPlaceholderRemovalMigration.php
index 74cc5e8b306a..07fe911431b8 100644
--- a/typo3/sysext/install/Classes/Updates/RowUpdater/WorkspaceNewPlaceholderRemovalMigration.php
+++ b/typo3/sysext/install/Classes/Updates/RowUpdater/WorkspaceNewPlaceholderRemovalMigration.php
@@ -69,8 +69,8 @@ class WorkspaceNewPlaceholderRemovalMigration implements RowUpdaterInterface, Lo
                 if (in_array($fieldName, ['uid', 'pid', 'deleted', 't3ver_state', 't3ver_oid'], true)) {
                     continue;
                 }
-                if ($this->isMMField($tableName, $fieldName)) {
-                    $this->transferMMValues($tableName, $fieldName, (int)$versionedRecord['uid'], (int)$row['uid']);
+                if ($this->isMMField($tableName, (string)$fieldName)) {
+                    $this->transferMMValues($tableName, (string)$fieldName, (int)$versionedRecord['uid'], (int)$row['uid']);
                     continue;
                 }
                 $row[$fieldName] = $value;
diff --git a/typo3/sysext/linkvalidator/ext_tables.php b/typo3/sysext/linkvalidator/ext_tables.php
index 0406dcfe2f6f..597ca4932edd 100644
--- a/typo3/sysext/linkvalidator/ext_tables.php
+++ b/typo3/sysext/linkvalidator/ext_tables.php
@@ -6,7 +6,7 @@ defined('TYPO3') or die();
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
     'web_info',
     \TYPO3\CMS\Linkvalidator\Report\LinkValidatorReport::class,
-    null,
+    '',
     'LLL:EXT:linkvalidator/Resources/Private/Language/locallang.xlf:mod_linkvalidator'
 );
 
diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
index e729e98e9b90..a518642ef4b2 100644
--- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
+++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
@@ -1221,7 +1221,7 @@ class DatabaseRecordList
             $tagAttributes
         );
 
-        $rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true));
+        $rowOutput .= $this->addElement(1, (string)$theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true));
         // Finally, return table row element:
         return $rowOutput;
     }
diff --git a/typo3/sysext/scheduler/Classes/Task/FileStorageExtractionTask.php b/typo3/sysext/scheduler/Classes/Task/FileStorageExtractionTask.php
index 0d2cb9008444..07cf30255b7a 100644
--- a/typo3/sysext/scheduler/Classes/Task/FileStorageExtractionTask.php
+++ b/typo3/sysext/scheduler/Classes/Task/FileStorageExtractionTask.php
@@ -50,6 +50,9 @@ class FileStorageExtractionTask extends AbstractTask
         $success = false;
         if ((int)$this->storageUid > 0) {
             $storage = GeneralUtility::makeInstance(StorageRepository::class)->findByUid($this->storageUid);
+            if ($storage === null) {
+                throw new \RuntimeException(self::class . ' misconfiguration: "Storage to index" must be an existing storage.', 1615020909);
+            }
             $currentEvaluatePermissionsValue = $storage->getEvaluatePermissions();
             $storage->setEvaluatePermissions(false);
             $indexer = $this->getIndexer($storage);
diff --git a/typo3/sysext/scheduler/Classes/Task/FileStorageIndexingTask.php b/typo3/sysext/scheduler/Classes/Task/FileStorageIndexingTask.php
index 175dc630cafd..cb6e61fffda4 100644
--- a/typo3/sysext/scheduler/Classes/Task/FileStorageIndexingTask.php
+++ b/typo3/sysext/scheduler/Classes/Task/FileStorageIndexingTask.php
@@ -42,6 +42,9 @@ class FileStorageIndexingTask extends AbstractTask
     {
         if ((int)$this->storageUid > 0) {
             $storage = GeneralUtility::makeInstance(StorageRepository::class)->findByUid($this->storageUid);
+            if ($storage === null) {
+                throw new \RuntimeException(self::class . ' misconfiguration: "Storage to index" must be an existing storage.', 1615020908);
+            }
             $currentEvaluatePermissionsValue = $storage->getEvaluatePermissions();
             $storage->setEvaluatePermissions(false);
             $indexer = $this->getIndexer($storage);
diff --git a/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php b/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php
index 5b1d428e08da..592434a31bb6 100644
--- a/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php
+++ b/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php
@@ -378,7 +378,7 @@ class ViewModuleController
     protected function getShortcutTitle(int $pageId): string
     {
         $pageTitle = '';
-        $pageRow = BackendUtility::getRecord('pages', $pageId);
+        $pageRow = BackendUtility::getRecord('pages', $pageId) ?? [];
         if ($pageRow !== []) {
             $pageTitle = BackendUtility::getRecordTitle('pages', $pageRow);
         }
diff --git a/typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php b/typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php
index 065a03566429..580a9c0769e5 100644
--- a/typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php
+++ b/typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php
@@ -273,6 +273,9 @@ class ActionHandler
                 if (!$stageRecord->isEditStage()) {
                     $this->stageService->getRecordService()->add($table, $uid);
                     $previousStageRecord = $stageRecord->getPrevious();
+                    if ($previousStageRecord === null) {
+                        return $this->getErrorResponse('error.sendToPrevStage.noPreviousStage', 1287264747);
+                    }
                     $result = $this->getSentToStageWindow($previousStageRecord);
                     $result['affects'] = [
                         'table' => $table,
@@ -643,6 +646,7 @@ class ActionHandler
         }
 
         $result = [];
+        // TODO: $nextStage might be null, error ignored in phpstan.neon
         if ($nextStage->isDialogEnabled()) {
             $result['sendMailTo'] = $this->getRecipientsOfStage($nextStage);
             $result['additional'] = [
diff --git a/typo3/sysext/workspaces/Classes/Controller/Remote/RemoteServer.php b/typo3/sysext/workspaces/Classes/Controller/Remote/RemoteServer.php
index d9706ef44087..6a4fc40bf559 100644
--- a/typo3/sysext/workspaces/Classes/Controller/Remote/RemoteServer.php
+++ b/typo3/sysext/workspaces/Classes/Controller/Remote/RemoteServer.php
@@ -245,7 +245,7 @@ class RemoteServer
                         'content' => BackendUtility::getProcessedValue(
                             $parameter->table,
                             $fieldName,
-                            $liveReturnArray[$fieldName],
+                            (string)$liveReturnArray[$fieldName],
                             0,
                             true,
                             false,
@@ -394,7 +394,7 @@ class RemoteServer
                     ProcessedFile::CONTEXT_IMAGEPREVIEW,
                     ['width' => 40, 'height' => 40]
                 );
-                $thumbnailMarkup = '<img src="' . PathUtility::getAbsoluteWebPath($thumbnailFile->getPublicUrl()) . '" />';
+                $thumbnailMarkup = '<img src="' . PathUtility::getAbsoluteWebPath($thumbnailFile->getPublicUrl() ?? '') . '" />';
                 $substitutes[$identifierWithRandomValue] = $thumbnailMarkup;
             } else {
                 $substitutes[$identifierWithRandomValue] = $fileReference->getPublicUrl();
diff --git a/typo3/sysext/workspaces/Classes/Controller/ReviewController.php b/typo3/sysext/workspaces/Classes/Controller/ReviewController.php
index 090ff7b9d955..f1c7f356a36e 100644
--- a/typo3/sysext/workspaces/Classes/Controller/ReviewController.php
+++ b/typo3/sysext/workspaces/Classes/Controller/ReviewController.php
@@ -225,7 +225,7 @@ class ReviewController
                 'title' => $workspaceTitle,
                 'itemId' => 'workspace-' . $workspaceId,
                 'workspaceId' => $workspaceId,
-                'triggerUrl' => $this->getModuleUri($workspaceId),
+                'triggerUrl' => $this->getModuleUri((int)$workspaceId),
             ];
         }
 
diff --git a/typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php b/typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php
index 69005a89a7bc..126a8e21d1fb 100644
--- a/typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php
+++ b/typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php
@@ -558,7 +558,7 @@ class DataHandlerHook
         $curVersion = BackendUtility::getRecord($table, $id, '*');
         // Versioned records which contents will be moved into $curVersion
         $isNewRecord = ((int)($curVersion['t3ver_state'] ?? 0) === VersionState::NEW_PLACEHOLDER);
-        if ($isNewRecord) {
+        if ($isNewRecord && is_array($curVersion)) {
             $this->publishNewRecord($table, $curVersion, $dataHandler, $comment, (array)$notificationAlternativeRecipients);
             return;
         }
-- 
GitLab