From 3a4dd1eea9fea0b0c762b9b482a0721d5198b4cf Mon Sep 17 00:00:00 2001
From: Daniel Goerz <daniel.goerz@posteo.de>
Date: Sun, 30 May 2021 11:43:07 +0200
Subject: [PATCH] [TASK] Enable TypesAssignedToPropertiesRule in phpstan

composer req friendsoftypo3/phpstan-typo3 ^0.8.1 --dev

This patch is the next step towards full level 3
compatibility of the TYPO3 core.

Releases: master
Resolves: #94127
Change-Id: I5092ce3a9248a7e5ecba3f42183765c1b1d5b1cc
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69327
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
---
 Build/phpstan.level3.neon                          |  2 +-
 composer.json                                      |  2 +-
 composer.lock                                      | 14 +++++++-------
 phpstan.neon                                       | 14 ++++++++++++++
 typo3/sysext/backend/Classes/View/ArrayBrowser.php |  4 ++--
 .../core/Classes/Imaging/GraphicalFunctions.php    |  2 +-
 6 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/Build/phpstan.level3.neon b/Build/phpstan.level3.neon
index 54f2a235ec16..bda67ceff336 100644
--- a/Build/phpstan.level3.neon
+++ b/Build/phpstan.level3.neon
@@ -10,7 +10,7 @@ rules:
 	- PHPStan\Rules\Generators\YieldTypeRule
 #	- PHPStan\Rules\Methods\ReturnTypeRule
 	- PHPStan\Rules\Properties\DefaultValueTypesAssignedToPropertiesRule
-#	- PHPStan\Rules\Properties\TypesAssignedToPropertiesRule
+	- PHPStan\Rules\Properties\TypesAssignedToPropertiesRule
 	- PHPStan\Rules\Variables\ThrowTypeRule
 	- PHPStan\Rules\Variables\VariableCloningRule
 
diff --git a/composer.json b/composer.json
index fd4eb0ff88a5..461b43dfab33 100644
--- a/composer.json
+++ b/composer.json
@@ -91,7 +91,7 @@
 		"codeception/module-webdriver": "^1.1.4",
 		"composer/package-versions-deprecated": "^1.10",
 		"friendsofphp/php-cs-fixer": "^2.19 || ^3.0",
-		"friendsoftypo3/phpstan-typo3": "^0.7.0",
+		"friendsoftypo3/phpstan-typo3": "^0.8.1",
 		"php-webdriver/webdriver": "^1.9.0",
 		"phpspec/prophecy": "^1.12.2",
 		"phpstan/phpstan": "^0.12.64",
diff --git a/composer.lock b/composer.lock
index 010538df2385..acf554bc9e5c 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "0a6013a98ba1ec2a7ab5e3719aa00cbe",
+    "content-hash": "c110d52283819e782f64960c0f6d4e1a",
     "packages": [
         {
             "name": "bacon/bacon-qr-code",
@@ -5452,16 +5452,16 @@
         },
         {
             "name": "friendsoftypo3/phpstan-typo3",
-            "version": "0.7.0",
+            "version": "0.8.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/FriendsOfTYPO3/phpstan-typo3.git",
-                "reference": "e51a2370ec3ecd44535c066fab90ee775c52e43b"
+                "reference": "5060372cb8d05673c6119e9a5443e9f11a49baa9"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/FriendsOfTYPO3/phpstan-typo3/zipball/e51a2370ec3ecd44535c066fab90ee775c52e43b",
-                "reference": "e51a2370ec3ecd44535c066fab90ee775c52e43b",
+                "url": "https://api.github.com/repos/FriendsOfTYPO3/phpstan-typo3/zipball/5060372cb8d05673c6119e9a5443e9f11a49baa9",
+                "reference": "5060372cb8d05673c6119e9a5443e9f11a49baa9",
                 "shasum": ""
             },
             "require": {
@@ -5489,9 +5489,9 @@
             "description": "TYPO3 rules for PHPStan",
             "support": {
                 "issues": "https://github.com/FriendsOfTYPO3/phpstan-typo3/issues",
-                "source": "https://github.com/FriendsOfTYPO3/phpstan-typo3/tree/0.7.0"
+                "source": "https://github.com/FriendsOfTYPO3/phpstan-typo3/tree/0.8.1"
             },
-            "time": "2021-03-01T12:40:52+00:00"
+            "time": "2021-05-31T08:45:47+00:00"
         },
         {
             "name": "mikey179/vfsstream",
diff --git a/phpstan.neon b/phpstan.neon
index 9e8b619d02a9..da2871bd2440 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -109,6 +109,20 @@ parameters:
       count: 1
       path: typo3/sysext/core/Classes/Database/Connection.php
 
+    # TypesAssignedToPropertiesRule
+    -
+      message: "#^Property Doctrine\\\\DBAL\\\\Schema\\\\SchemaDiff\\:\\:\\$newTables \\(array\\<Doctrine\\\\DBAL\\\\Schema\\\\Table\\>\\) does not accept array\\<Doctrine\\\\DBAL\\\\Schema\\\\TableDiff\\>\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php
+    -
+      message: "#^Property Doctrine\\\\DBAL\\\\Schema\\\\SchemaDiff\\:\\:\\$removedTables \\(array\\<Doctrine\\\\DBAL\\\\Schema\\\\Table\\>\\) does not accept array\\<Doctrine\\\\DBAL\\\\Schema\\\\TableDiff\\>\\.$#"
+      count: 1
+      path: typo3/sysext/core/Classes/Database/Schema/ConnectionMigrator.php
+    -
+      message: "#^Property PhpParser\\\\Node\\\\Arg\\:\\:\\$value \\(PhpParser\\\\Node\\\\Expr\\) does not accept PhpParser\\\\Node\\\\Name\\\\FullyQualified\\.$#"
+      count: 1
+      path: typo3/sysext/install/Classes/ExtensionScanner/Php/GeneratorClassesResolver.php
+
     # Ignored errors for level 4
     -
       message: "#^Ternary operator condition is always false\\.$#"
diff --git a/typo3/sysext/backend/Classes/View/ArrayBrowser.php b/typo3/sysext/backend/Classes/View/ArrayBrowser.php
index 44228383c741..d97bdae36b2e 100644
--- a/typo3/sysext/backend/Classes/View/ArrayBrowser.php
+++ b/typo3/sysext/backend/Classes/View/ArrayBrowser.php
@@ -53,9 +53,9 @@ class ArrayBrowser
      * If set, the values are truncated with "..." appended if longer than a certain
      * length.
      *
-     * @var int
+     * @var bool
      */
-    public $regexMode = 0;
+    public $regexMode = false;
 
     /**
      * If set, search for string with regex, otherwise stristr()
diff --git a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
index 695803316d84..a44b65f9982d 100644
--- a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+++ b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
@@ -296,7 +296,7 @@ class GraphicalFunctions
     protected $OFFSET;
 
     /**
-     * @var resource
+     * @var resource|\GdImage
      */
     protected $im;
 
-- 
GitLab