From 6cfec87e37399d141b5c90597f8c814177b8adc8 Mon Sep 17 00:00:00 2001
From: Daniel Goerz <daniel.goerz@posteo.de>
Date: Tue, 20 Apr 2021 10:42:26 +0200
Subject: [PATCH] [TASK] Activate phpstan option reportUnmatchedIgnoredErrors

Releases: master
Resolves: #93955
Change-Id: Idb5e338c7a1e34f1197d38d01bec5f8735509e8f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68834
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 Build/phpstan.php7config.php | 50 +++++++++++++++++++++
 Build/phpstan.php8config.php | 43 ++----------------
 phpstan.neon                 | 86 ++++--------------------------------
 3 files changed, 62 insertions(+), 117 deletions(-)

diff --git a/Build/phpstan.php7config.php b/Build/phpstan.php7config.php
index b9eb197d610b..a1692ec9bd06 100644
--- a/Build/phpstan.php7config.php
+++ b/Build/phpstan.php7config.php
@@ -21,6 +21,56 @@ if (PHP_MAJOR_VERSION === 7) {
             'message' => '#^Parameter \\#1 \\$sem_identifier of function sem_remove expects resource, resource\\|SysvSemaphore given\\.$#',
             'path' => '../typo3/sysext/core/Classes/Locking/SemaphoreLockStrategy.php',
             'count' => 1,
+        ],
+        [
+            'message' => '#^Parameter \\#2 \\$algo of function password_hash expects string\\|null, int\\|string\\|null given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Crypto/PasswordHashing/AbstractArgon2PasswordHash.php',
+            'count' => 1
+        ],
+        [
+            'message' => '#^Parameter \\#2 \\$algo of function password_needs_rehash expects string\\|null, int\\|string\\|null given\\.$#',
+            'path' => '../typo3/sysext/core/Classes/Crypto/PasswordHashing/AbstractArgon2PasswordHash.php',
+            'count' => 1
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/Controller/EnvironmentController.php',
+            'count' => 6
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$im of function imagefilledrectangle expects resource, resource\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/Controller/EnvironmentController.php',
+            'count' => 4
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$im of function imagegif expects resource, resource\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/Controller/EnvironmentController.php',
+            'count' => 1
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$im of function imagettftext expects resource, resource\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/Controller/EnvironmentController.php',
+            'count' => 1
+        ],
+        [
+            'message' => '#^Parameter \\#6 \\$col of function imagefilledrectangle expects int, int\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/Controller/EnvironmentController.php',
+            'count' => 4
+        ],
+        [
+            'message' => '#^Parameter \\#6 \\$col of function imagettftext expects int, int\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/Controller/EnvironmentController.php',
+            'count' => 1
+        ],
+        [
+            'message' => '#^Parameter \\#1 \\$im of function imagedestroy expects resource, resource\\|false given\\.$#',
+            'path' => '../typo3/sysext/install/Classes/SystemEnvironment/Check.php',
+            'count' => 3
+        ],
+        [
+            'message' => '#^Parameter \\#2 \\$col of function imagecolortransparent expects int, int\\|false given\\.$#',
+            'path' => '../typo3/sysext/frontend/Classes/Imaging/GifBuilder.php',
+            'count' => 1
         ]
     ];
 }
diff --git a/Build/phpstan.php8config.php b/Build/phpstan.php8config.php
index 3ec4d42a8299..2700452a1b94 100644
--- a/Build/phpstan.php8config.php
+++ b/Build/phpstan.php8config.php
@@ -41,21 +41,6 @@ if (PHP_MAJOR_VERSION === 8) {
             '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',
@@ -72,30 +57,10 @@ if (PHP_MAJOR_VERSION === 8) {
             '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,
-        ],
+            'message' => '#^Parameter \\#2 \\$color of function imagecolortransparent expects int\\|null, int\\|false given\\.$#',
+            'path' => '../typo3/sysext/frontend/Classes/Imaging/GifBuilder.php',
+            'count' => 1
+        ]
     ];
 }
 
diff --git a/phpstan.neon b/phpstan.neon
index 2786c8fa3e94..7c3ddfd027bc 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -21,9 +21,7 @@ parameters:
   # removed from this file.
   checkThisOnly: true
   checkPhpDocMissingReturn: false
-
-  # Set to true during local runs to find unmatched ignored errors. bamboo needs this to be set to false.
-  reportUnmatchedIgnoredErrors: false
+  reportUnmatchedIgnoredErrors: true
 
   scanDirectories:
     - %currentWorkingDirectory%/typo3/sysext/
@@ -125,11 +123,11 @@ parameters:
 
     # Ignored errors for level 5
     -
-      message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, string given\\.$#"
+      message: "#^Parameter \\#1 \\$(var|value) of function count expects array\\|Countable, string given\\.$#"
       count: 2
       path: typo3/sysext/core/Classes/Database/QueryGenerator.php
     -
-      message: "#^Parameter \\#1 \\$input of function array_slice expects array, string given\\.$#"
+      message: "#^Parameter \\#1 \\$(input|array) of function array_slice expects array, string given\\.$#"
       count: 2
       path: typo3/sysext/core/Classes/Database/QueryGenerator.php
     -
@@ -152,30 +150,14 @@ parameters:
       message: "#^Parameter \\#2 \\$first of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\QueryGenerator\\:\\:getUserDefQuery\\(\\) expects bool, int given\\.$#"
       count: 1
       path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-    -
-      message: "#^Parameter \\#2 \\$time of static method DateTime\\:\\:createFromFormat\\(\\) expects string, int\\|string given\\.$#"
-      count: 1
-      path: typo3/sysext/core/Classes/Database/QueryGenerator.php
     -
       message: "#^Parameter \\#2 \\$replace of function str_replace expects array\\|string, int given\\.$#"
       count: 1
       path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-    -
-      message: "#^Parameter \\#1 \\$str of function trim expects string, array\\|string given\\.$#"
-      count: 1
-      path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-    -
-      message: "#^Parameter \\#2 \\$timestamp of function date expects int, int\\|false given\\.$#"
-      count: 1
-      path: typo3/sysext/core/Classes/Database/QueryGenerator.php
     -
       message: "#^Parameter \\#2 \\$storeIndex of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\QueryView\\:\\:loadStoreQueryConfigs\\(\\) expects int, string given\\.$#"
       count: 1
       path: typo3/sysext/core/Classes/Database/QueryView.php
-    -
-      message: "#^Parameter \\#2 \\$timestamp of function strftime expects int, string given\\.$#"
-      count: 3
-      path: typo3/sysext/core/Classes/Database/QueryView.php
     -
       message: "#^Parameter \\#1 \\$constraint of static method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\QueryHelper\\:\\:stripLogicalOperatorPrefix\\(\\) expects string, string\\|null given\\.$#"
       count: 1
@@ -188,46 +170,10 @@ parameters:
       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
@@ -241,15 +187,11 @@ parameters:
       count: 1
       path: typo3/sysext/install/Classes/Controller/InstallerController.php
     -
-      message: "#^Parameter \\#4 \\$col of function imagefill expects int, int\\|false given\\.$#"
+      message: "#^Parameter \\#4 \\$(col|color) 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\\.$#"
+      message: "#^Parameter \\#6 \\$(col|color) of function imagefilledrectangle expects int, int\\|false given\\.$#"
       count: 1
       path: typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
     -
@@ -297,15 +239,11 @@ parameters:
       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\\.$#"
+      message: "#^Parameter \\#1 \\$(exception_handler|callback) 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\\.$#"
+      message: "#^Parameter \\#1 \\$(exception_handler|callback) 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
     -
@@ -313,21 +251,13 @@ parameters:
       count: 1
       path: typo3/sysext/core/Classes/DependencyInjection/ServiceProviderRegistry.php
     -
-      message: "#^Parameter \\#1 \\$name of class ReflectionFunction constructor expects Closure\\|string, callable\\(\\)\\: mixed given\\.$#"
+      message: "#^Parameter \\#1 \\$(name|function) 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
-- 
GitLab