From e659740495d61377be3a34daaeff016b771d9d1a Mon Sep 17 00:00:00 2001
From: Daniel Goerz <daniel.goerz@posteo.de>
Date: Thu, 11 Mar 2021 21:57:51 +0100
Subject: [PATCH] [TASK] Run phpstan with PHP 8 in nightly and premerge builds

Resolves: #93704
Releases: master
Change-Id: I24067c4b705c671b87a9bbdfed30535a39528879
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68359
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
---
 Build/gitlab-ci/nightly/integrity.yml         |  12 +++
 Build/gitlab-ci/pre-merge/integrity.yml       |  14 +++
 Build/phpstan.php7config.php                  |  28 +++++
 Build/phpstan.php8config.php                  | 102 ++++++++++++++++++
 phpstan.neon                                  |  91 ++--------------
 .../core/Classes/DataHandling/DataHandler.php |   5 +-
 .../core/Classes/Database/QueryGenerator.php  |   6 +-
 .../core/Classes/Database/QueryView.php       |   6 +-
 .../Classes/Error/DebugExceptionHandler.php   |   5 +-
 .../Error/ProductionExceptionHandler.php      |   5 +-
 typo3/sysext/core/Classes/Http/Stream.php     |   3 +
 .../Classes/Locking/SemaphoreLockStrategy.php |   2 +-
 .../core/Classes/Utility/GeneralUtility.php   |   6 +-
 .../Utility/Parser/ExtensionXmlPushParser.php |   6 +-
 .../Classes/FolderStructure/AbstractNode.php  |   2 +-
 .../Classes/CronCommand/NormalizeCommand.php  |   2 +-
 16 files changed, 192 insertions(+), 103 deletions(-)
 create mode 100644 Build/phpstan.php7config.php
 create mode 100644 Build/phpstan.php8config.php

diff --git a/Build/gitlab-ci/nightly/integrity.yml b/Build/gitlab-ci/nightly/integrity.yml
index 925ca61ca36c..6045c74dbcf4 100644
--- a/Build/gitlab-ci/nightly/integrity.yml
+++ b/Build/gitlab-ci/nightly/integrity.yml
@@ -96,3 +96,15 @@ 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 457c486d265b..ca9e3d12326a 100644
--- a/Build/gitlab-ci/pre-merge/integrity.yml
+++ b/Build/gitlab-ci/pre-merge/integrity.yml
@@ -98,3 +98,17 @@ phpstan php 7.4 pre-merge:
     - 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.php7config.php b/Build/phpstan.php7config.php
new file mode 100644
index 000000000000..b9eb197d610b
--- /dev/null
+++ b/Build/phpstan.php7config.php
@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+$config = [];
+
+if (PHP_MAJOR_VERSION === 7) {
+    $config['parameters']['ignoreErrors'] = [
+        '#Class GdImage not found.#',
+        [
+            'message' => '#^Parameter \\#[1-4]{1} \\$[a-z]* of function [a-z_]* expects resource, resource\\|XmlParser given\\.$#',
+            'path' => '../typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPushParser.php',
+            'count' => 9,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$sem_identifier of function sem_release expects resource, resource\\|SysvSemaphore given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$sem_identifier of function sem_remove expects resource, resource\\|SysvSemaphore given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php',
+            'count' => 1,
+        ]
+    ];
+}
+
+return $config;
diff --git a/Build/phpstan.php8config.php b/Build/phpstan.php8config.php
new file mode 100644
index 000000000000..3ec4d42a8299
--- /dev/null
+++ b/Build/phpstan.php8config.php
@@ -0,0 +1,102 @@
+<?php
+
+declare(strict_types=1);
+
+$config = [];
+
+if (PHP_MAJOR_VERSION === 8) {
+    $config['parameters']['ignoreErrors'] = [
+        [
+            'message' => '#^Parameter \\#1 \\$image of function imagedestroy expects GdImage, GdImage\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/SystemEnvironment/Check.php',
+            'count' => 3,
+        ],
+        [
+            'message' => '#^Parameter \\#6 \\$color of function imagefilledrectangle expects int, int\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/Controller/EnvironmentController.php',
+            'count' => 4,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$image of function imagefilledrectangle expects GdImage, GdImage\\|false given\\.$#',
+            'path' => '../',
+            'count' => 4,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$image of function imagegif expects GdImage, GdImage\\|false given\\.$#',
+            'path' => '../',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#6 \\$color of function imagettftext expects int, int\\|false given\\.$#',
+            'path' => '../',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$image of function imagettftext expects GdImage, GdImage\\|false given\\.$#',
+            'path' => '../',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$image of function imagecolorallocate expects GdImage, GdImage\\|false given\\.$#',
+            'path' => '../',
+            'count' => 6,
+        ],
+        [
+            'message' => '#^Parameter \\#2 \\$color of function imagecolortransparent expects int\\|null, int\\|false given\\.$#',
+            'path' => '../typo3/sysext/frontend/Classes/Imaging/GifBuilder.php',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#6 \\$color of function imagefilledrectangle expects int, int\\|false given\\.$#',
+            'path' => '../typo3/sysext/frontend/Classes/Imaging/GifBuilder.php',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#4 \\$color of function imagefill expects int, int\\|false given\\.$#',
+            'path' => '../typo3/sysext/frontend/Classes/Imaging/GifBuilder.php',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#[1-4]{1} \\$[a-z]* of function [a-z_]* expects XmlParser, resource\\|XmlParser given\\.$#',
+            'path' => '../typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPushParser.php',
+            'count' => 9,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$semaphore of function sem_release expects SysvSemaphore, resource\\|SysvSemaphore given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$semaphore of function sem_remove expects SysvSemaphore, resource\\|SysvSemaphore given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$function of class ReflectionFunction constructor expects Closure\\|string, callable\\(\\)\\: mixed given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/DependencyInjection/ServiceProviderCompilationPass.php',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$value of function count expects array\\|Countable, string given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Database/QueryGenerator.php',
+            'count' => 2,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$array of function array_slice expects array, string given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Database/QueryGenerator.php',
+            'count' => 2,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$callback of function set_exception_handler expects \\(callable\\(Throwable\\)\\: void\\)\\|null, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\Error\\\\DebugExceptionHandler\\), \'handleException\'\\) given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Error/DebugExceptionHandler.php',
+            'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$callback of function set_exception_handler expects \\(callable\\(Throwable\\)\\: void\\)\\|null, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\Error\\\\ProductionExceptionHandler\\), \'handleException\'\\) given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Error/ProductionExceptionHandler.php',
+            'count' => 1,
+        ],
+    ];
+}
+
+return $config;
diff --git a/phpstan.neon b/phpstan.neon
index e70d5f8f3461..2786c8fa3e94 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,6 +1,8 @@
 includes:
     - vendor/friendsoftypo3/phpstan-typo3/extension.neon
     - Build/phpstan.level8.neon
+    - Build/phpstan.php7config.php
+    - Build/phpstan.php8config.php
 # Include bleeding edge rules if necessary but do not commit
 #    - vendor/phpstan/phpstan/conf/bleedingEdge.neon
 
@@ -33,10 +35,9 @@ parameters:
     - %currentWorkingDirectory%/typo3/sysext/*/Documentation/*
     - %currentWorkingDirectory%/typo3/sysext/*/Resources/*
     - %currentWorkingDirectory%/typo3/sysext/*/Configuration/*
+    - %currentWorkingDirectory%/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
 
   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
@@ -179,86 +180,6 @@ 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
@@ -336,15 +257,15 @@ parameters:
       count: 1
       path: typo3/sysext/frontend/Classes/ContentObject/ScalableVectorGraphicsContentObject.php
     -
-      message: "#^Parameter \\#1 \\$array_arg of function current expects array, object given\\.$#"
+      message: "#^Parameter \\#1 \\$(array_arg|array) 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\\.$#"
+      message: "#^Parameter \\#1 \\$(array_arg|array) 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\\.$#"
+      message: "#^Parameter \\#1 \\$(array_arg|array) of function next expects array, object given\\.$#"
       count: 1
       path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
     -
diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
index c62c39d764b9..8bf3f22867b5 100644
--- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php
+++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
@@ -6166,7 +6166,10 @@ class DataHandler implements LoggerAwareInterface
                 }
                 // Process the arguments with the defined function:
                 if (!empty($remapAction['func'])) {
-                    $newValue = call_user_func_array([$this, $remapAction['func']], $remapAction['args']);
+                    $callable = [$this, $remapAction['func']];
+                    if (is_callable($callable)) {
+                        $newValue = call_user_func_array($callable, $remapAction['args']);
+                    }
                 }
                 // If array is returned, check for maxitems condition, if string is returned this was already done:
                 if (is_array($newValue)) {
diff --git a/typo3/sysext/core/Classes/Database/QueryGenerator.php b/typo3/sysext/core/Classes/Database/QueryGenerator.php
index 8a0bfc2124ec..f6b2563ee69f 100644
--- a/typo3/sysext/core/Classes/Database/QueryGenerator.php
+++ b/typo3/sysext/core/Classes/Database/QueryGenerator.php
@@ -1294,7 +1294,7 @@ class QueryGenerator
             return false;
         }
         $format = 'Y-m-d\\TH:i:s\\Z';
-        $formattedDate = \DateTime::createFromFormat($format, $date);
+        $formattedDate = \DateTime::createFromFormat($format, (string)$date);
         return $formattedDate && $formattedDate->format($format) === $date;
     }
 
@@ -1345,7 +1345,7 @@ class QueryGenerator
             $inputVal = $this->cleanInputVal($conf, '1');
             $qsTmp = str_replace('#VALUE1#', trim($queryBuilder->quote($inputVal), '\''), $qsTmp);
         }
-        $qs .= trim($qsTmp);
+        $qs .= trim((string)$qsTmp);
         return $qs;
     }
 
@@ -1698,7 +1698,7 @@ class QueryGenerator
      */
     protected function getDateTimePickerField($name, $timestamp, $type)
     {
-        $value = strtotime($timestamp) ? date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], strtotime($timestamp)) : '';
+        $value = strtotime($timestamp) ? date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], (int)strtotime($timestamp)) : '';
         $id = StringUtility::getUniqueId('dt_');
         $html = [];
         $html[] = '<div class="input-group" id="' . $id . '-wrapper">';
diff --git a/typo3/sysext/core/Classes/Database/QueryView.php b/typo3/sysext/core/Classes/Database/QueryView.php
index b8a6e966cce6..2b304999e4be 100644
--- a/typo3/sysext/core/Classes/Database/QueryView.php
+++ b/typo3/sysext/core/Classes/Database/QueryView.php
@@ -843,15 +843,15 @@ class QueryView
         switch ($fields['type']) {
             case 'date':
                 if ($fieldValue != -1) {
-                    $out = strftime('%d-%m-%Y', $fieldValue);
+                    $out = strftime('%d-%m-%Y', (int)$fieldValue);
                 }
                 break;
             case 'time':
                 if ($fieldValue != -1) {
                     if ($splitString === '<br />') {
-                        $out = strftime('%H:%M' . $splitString . '%d-%m-%Y', $fieldValue);
+                        $out = strftime('%H:%M' . $splitString . '%d-%m-%Y', (int)$fieldValue);
                     } else {
-                        $out = strftime('%H:%M %d-%m-%Y', $fieldValue);
+                        $out = strftime('%H:%M %d-%m-%Y', (int)$fieldValue);
                     }
                 }
                 break;
diff --git a/typo3/sysext/core/Classes/Error/DebugExceptionHandler.php b/typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
index 320784c7517b..5159286e7755 100644
--- a/typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
+++ b/typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
@@ -31,7 +31,10 @@ class DebugExceptionHandler extends AbstractExceptionHandler
      */
     public function __construct()
     {
-        set_exception_handler([$this, 'handleException']);
+        $callable = [$this, 'handleException'];
+        if (is_callable($callable)) {
+            set_exception_handler($callable);
+        }
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Error/ProductionExceptionHandler.php b/typo3/sysext/core/Classes/Error/ProductionExceptionHandler.php
index c81a6f15f6b4..94bbb9e8acaa 100644
--- a/typo3/sysext/core/Classes/Error/ProductionExceptionHandler.php
+++ b/typo3/sysext/core/Classes/Error/ProductionExceptionHandler.php
@@ -47,7 +47,10 @@ class ProductionExceptionHandler extends AbstractExceptionHandler
      */
     public function __construct()
     {
-        set_exception_handler([$this, 'handleException']);
+        $callable = [$this, 'handleException'];
+        if (is_callable($callable)) {
+            set_exception_handler($callable);
+        }
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Http/Stream.php b/typo3/sysext/core/Classes/Http/Stream.php
index 15f4a028c490..093d964428c9 100644
--- a/typo3/sysext/core/Classes/Http/Stream.php
+++ b/typo3/sysext/core/Classes/Http/Stream.php
@@ -93,6 +93,9 @@ class Stream implements StreamInterface
             return;
         }
         $resource = $this->detach();
+        if ($resource === null) {
+            return;
+        }
         fclose($resource);
     }
 
diff --git a/typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php b/typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php
index ae5c42b378ab..70e27b9ed15c 100644
--- a/typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php
+++ b/typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php
@@ -37,7 +37,7 @@ class SemaphoreLockStrategy implements LockingStrategyInterface
     protected $id;
 
     /**
-     * @var resource Semaphore Resource used for this lock
+     * @var resource|\SysvSemaphore Semaphore Resource used for this lock
      */
     protected $resource;
 
diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
index 4d1e6590123a..047b61762624 100644
--- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php
+++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
@@ -1746,7 +1746,7 @@ class GeneralUtility
                 $targetPermissions = str_pad($targetPermissions, 4, '0', STR_PAD_LEFT);
                 $targetPermissions = octdec($targetPermissions);
                 // "@" is there because file is not necessarily OWNED by the user
-                $result = @chmod($path, $targetPermissions);
+                $result = @chmod($path, (int)$targetPermissions);
             }
             // Set createGroup if not empty
             if (
@@ -1870,7 +1870,7 @@ class GeneralUtility
      */
     public static function mkdir($newFolder)
     {
-        $result = @mkdir($newFolder, octdec($GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
+        $result = @mkdir($newFolder, (int)octdec($GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
         if ($result) {
             static::fixPermissions($newFolder);
         }
@@ -1915,7 +1915,7 @@ class GeneralUtility
     {
         $currentPath = $fullDirectoryPath;
         $firstCreatedPath = '';
-        $permissionMask = octdec($GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']);
+        $permissionMask = (int)octdec($GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']);
         if (!@is_dir($currentPath)) {
             do {
                 $firstCreatedPath = $currentPath;
diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPushParser.php b/typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPushParser.php
index 2188aeb8755e..fe0411adbb3f 100644
--- a/typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPushParser.php
+++ b/typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPushParser.php
@@ -63,7 +63,7 @@ class ExtensionXmlPushParser extends AbstractExtensionXmlParser
     public function parseXml($file)
     {
         $this->createParser();
-        if (!is_resource($this->objXml)) {
+        if (!is_resource($this->objXml) && !$this->objXml instanceof \XmlParser) {
             throw new ExtensionManagerException('Unable to create XML parser.', 1342640663);
         }
         // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
@@ -72,8 +72,8 @@ class ExtensionXmlPushParser extends AbstractExtensionXmlParser
             $previousValueOfEntityLoader = libxml_disable_entity_loader(true);
         }
         // keep original character case of XML document
-        xml_parser_set_option($this->objXml, XML_OPTION_CASE_FOLDING, false);
-        xml_parser_set_option($this->objXml, XML_OPTION_SKIP_WHITE, false);
+        xml_parser_set_option($this->objXml, XML_OPTION_CASE_FOLDING, 0);
+        xml_parser_set_option($this->objXml, XML_OPTION_SKIP_WHITE, 0);
         xml_parser_set_option($this->objXml, XML_OPTION_TARGET_ENCODING, 'utf-8');
         xml_set_element_handler($this->objXml, [$this, 'startElement'], [$this, 'endElement']);
         xml_set_character_data_handler($this->objXml, [$this, 'characterData']);
diff --git a/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php b/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php
index cb4b90ecf403..de9b693cb9d6 100644
--- a/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php
+++ b/typo3/sysext/install/Classes/FolderStructure/AbstractNode.php
@@ -149,7 +149,7 @@ abstract class AbstractNode
                 1366744035
             );
         }
-        $result = @chmod($this->getAbsolutePath(), octdec($this->getTargetPermission()));
+        $result = @chmod($this->getAbsolutePath(), (int)octdec($this->getTargetPermission()));
         if ($result === true) {
             return new FlashMessage(
                 '',
diff --git a/typo3/sysext/scheduler/Classes/CronCommand/NormalizeCommand.php b/typo3/sysext/scheduler/Classes/CronCommand/NormalizeCommand.php
index 385138ec5d59..9edbe7e4c0e0 100644
--- a/typo3/sysext/scheduler/Classes/CronCommand/NormalizeCommand.php
+++ b/typo3/sysext/scheduler/Classes/CronCommand/NormalizeCommand.php
@@ -354,7 +354,7 @@ class NormalizeCommand
         }
         if (!$normalizedWeekday) {
             // Convert string representation like 'sun' to integer
-            $timestamp = strtotime('next ' . $weekday, mktime(0, 0, 0, 1, 1, 2010));
+            $timestamp = strtotime('next ' . $weekday, (int)mktime(0, 0, 0, 1, 1, 2010));
             if (!$timestamp || $timestamp < strtotime('2010-01-01') || $timestamp > strtotime('2010-01-08')) {
                 throw new \InvalidArgumentException('Unable to convert given weekday name.', 1291163589);
             }
-- 
GitLab