From f68873a878bb15060bd571d6a87f46fb05549b80 Mon Sep 17 00:00:00 2001 From: Oliver Klee <typo3-coding@oliverklee.de> Date: Thu, 3 Nov 2022 08:55:29 +0100 Subject: [PATCH] [TASK] Update to PHPStan 1.9.0 This update finds new problems and gets rid of some false positives. Run commands: > composer req --dev phpstan/phpstan:^1.9.0 > ./Build/Scripts/runTests.sh -s phpstanGenerateBaseline Blog article about the new release: https://phpstan.org/blog/phpstan-1-9-0-with-phpdoc-asserts-list-type Resolves: #98986 Releases: main, 11.5 Change-Id: I15516853c3a1bac80b80466fe4bae8a0f150ba68 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76397 Tested-by: core-ci <typo3@b13.com> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> --- Build/phpstan/phpstan-baseline.neon | 58 +++++++++++++++++------------ composer.json | 2 +- composer.lock | 14 +++---- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon index c095bfdba388..f2b96d39f18d 100644 --- a/Build/phpstan/phpstan-baseline.neon +++ b/Build/phpstan/phpstan-baseline.neon @@ -31,17 +31,22 @@ parameters: path: ../../typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php - - message: "#^Offset 2 on array\\{\\} in empty\\(\\) does not exist\\.$#" + message: "#^Offset 'tt_content' does not exist on array\\<int, string\\>\\|string\\.$#" count: 1 - path: ../../typo3/sysext/backend/Classes/Controller/EditDocumentController.php + path: ../../typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php - - message: "#^Result of \\|\\| is always true\\.$#" + message: "#^Offset 'tt_content' on array\\<int, string\\>\\|string on left side of \\?\\? does not exist\\.$#" + count: 1 + path: ../../typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php + + - + message: "#^Offset 2 on array\\{\\} in empty\\(\\) does not exist\\.$#" count: 1 path: ../../typo3/sysext/backend/Classes/Controller/EditDocumentController.php - - message: "#^Variable \\$keys in empty\\(\\) always exists and is not falsy\\.$#" + message: "#^Result of \\|\\| is always true\\.$#" count: 1 path: ../../typo3/sysext/backend/Classes/Controller/EditDocumentController.php @@ -105,6 +110,16 @@ parameters: count: 2 path: ../../typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php + - + message: "#^Strict comparison using \\=\\=\\= between non\\-empty\\-array\\<int, array\\{label\\: string, attributes\\: non\\-empty\\-array\\<'class'\\|'disabled'\\|'title'\\|'value', mixed\\>\\}\\> and array\\{\\} will always evaluate to false\\.$#" + count: 1 + path: ../../typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php + + - + message: "#^Offset 'title' on array\\{title\\: string, value\\: mixed, icon\\: string, selected\\: bool\\} on left side of \\?\\? always exists and is not nullable\\.$#" + count: 1 + path: ../../typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php + - message: "#^Negated boolean expression is always false\\.$#" count: 1 @@ -775,6 +790,11 @@ parameters: count: 1 path: ../../typo3/sysext/core/Classes/DataHandling/Model/CorrelationId.php + - + message: "#^Offset 'aspects' on array\\<string\\|null\\> on left side of \\?\\? always exists and is not nullable\\.$#" + count: 1 + path: ../../typo3/sysext/core/Classes/DataHandling/Model/CorrelationId.php + - message: "#^Method TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\Model\\\\RecordStateFactory\\:\\:forName\\(\\) should return static\\(TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\Model\\\\RecordStateFactory\\) but returns object\\.$#" count: 1 @@ -940,6 +960,11 @@ parameters: count: 1 path: ../../typo3/sysext/core/Classes/Database/ReferenceIndex.php + - + message: "#^Variable \\$chunk in empty\\(\\) always exists and is not falsy\\.$#" + count: 1 + path: ../../typo3/sysext/core/Classes/Database/ReferenceIndex.php + - message: "#^Variable \\$hashList in empty\\(\\) always exists and is not falsy\\.$#" count: 1 @@ -1440,6 +1465,11 @@ parameters: count: 2 path: ../../typo3/sysext/core/Classes/Resource/Search/QueryRestrictions/SearchTermRestriction.php + - + message: "#^Function array_merge invoked with 0 parameters, at least 1 required\\.$#" + count: 1 + path: ../../typo3/sysext/core/Classes/Resource/Security/SvgTypeCheck.php + - message: "#^Argument of an invalid type TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Index\\\\ExtractorInterface supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -1690,21 +1720,6 @@ parameters: count: 1 path: ../../typo3/sysext/core/Classes/Utility/GeneralUtility.php - - - message: "#^Offset 'ch' does not exist on array\\{\\}\\|array\\{attrs\\?\\: mixed, ch\\?\\: non\\-empty\\-array\\<int\\|string, array\\<int, array\\<literal\\-string&non\\-falsy\\-string, mixed\\>\\>\\>, tag\\?\\: mixed, values\\?\\: array\\<int, mixed\\>\\}\\.$#" - count: 1 - path: ../../typo3/sysext/core/Classes/Utility/GeneralUtility.php - - - - message: "#^Offset 'tag' does not exist on array\\{\\}\\|array\\{attrs\\?\\: mixed, ch\\?\\: non\\-empty\\-array\\<int\\|string, array\\<int, array\\<literal\\-string&non\\-falsy\\-string, mixed\\>\\>\\>, tag\\?\\: mixed, values\\?\\: array\\<int, mixed\\>\\}\\.$#" - count: 1 - path: ../../typo3/sysext/core/Classes/Utility/GeneralUtility.php - - - - message: "#^Offset 'values' does not exist on array\\{\\}\\|array\\{attrs\\?\\: mixed, ch\\?\\: non\\-empty\\-array\\<int\\|string, array\\<int, array\\<literal\\-string&non\\-falsy\\-string, mixed\\>\\>\\>, values\\?\\: array\\<int, mixed\\>\\}\\.$#" - count: 1 - path: ../../typo3/sysext/core/Classes/Utility/GeneralUtility.php - - message: "#^Template type T of method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:makeInstance\\(\\) is not referenced in a parameter\\.$#" count: 1 @@ -4520,11 +4535,6 @@ parameters: count: 1 path: ../../typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php - - - message: "#^Method TYPO3\\\\CMS\\\\Frontend\\\\Tests\\\\Unit\\\\ContentObject\\\\ContentObjectRendererTest\\:\\:stdWrapBrDataProvider\\(\\) should return array\\<array\\<string\\>\\> but returns array\\<string, array\\<int, string\\|null\\>\\>\\.$#" - count: 1 - path: ../../typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php - - message: "#^Offset 'INTincScript' does not exist on array\\{\\}\\.$#" count: 1 diff --git a/composer.json b/composer.json index f56f0ac4f287..dba683a2a423 100644 --- a/composer.json +++ b/composer.json @@ -117,7 +117,7 @@ "php-webdriver/webdriver": "^1.12.0", "phpspec/prophecy": "^1.15.0", "phpspec/prophecy-phpunit": "^2.0.1", - "phpstan/phpstan": "^1.8.11", + "phpstan/phpstan": "^1.9.0", "phpstan/phpstan-phpunit": "^1.2.2", "phpunit/phpunit": "^9.5.21", "typo3/cms-styleguide": "~11.5.4", diff --git a/composer.lock b/composer.lock index 7c0f0151c0fe..cce873601480 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": "2b61de953f4218b608360922d4fc3c66", + "content-hash": "495d39ca752b613f3d1627aa15b6eaeb", "packages": [ { "name": "bacon/bacon-qr-code", @@ -7095,16 +7095,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.8.11", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "46e223dd68a620da18855c23046ddb00940b4014" + "reference": "e08de53a5eec983de78a787a88e72518cf8fe43a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/46e223dd68a620da18855c23046ddb00940b4014", - "reference": "46e223dd68a620da18855c23046ddb00940b4014", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e08de53a5eec983de78a787a88e72518cf8fe43a", + "reference": "e08de53a5eec983de78a787a88e72518cf8fe43a", "shasum": "" }, "require": { @@ -7134,7 +7134,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.11" + "source": "https://github.com/phpstan/phpstan/tree/1.9.0" }, "funding": [ { @@ -7150,7 +7150,7 @@ "type": "tidelift" } ], - "time": "2022-10-24T15:45:13+00:00" + "time": "2022-11-03T07:26:48+00:00" }, { "name": "phpstan/phpstan-phpunit", -- GitLab