From 229e8ca92e4066832d932c6c005196818563c37a Mon Sep 17 00:00:00 2001 From: Alexander Schnitzler <git@alexanderschnitzler.de> Date: Wed, 10 Jun 2020 17:09:22 +0200 Subject: [PATCH] [TASK] Update phpstan to at least 0.12.37 Updating phpstan to version 0.12.37 lets phpstan benefit from static reflection which does no longer come with the need to load analyzed classes and use the native reflection api of php. Instead, roave/better-reflection is used, which does a better job and reduces false positives. Since phpstan has been updated, the rules which have been copied over from the vendor package had to be updated as well. And since phpstan does find more errors now, a few rules had to be disabled again. Used commands: - composer require phpstan/phpstan:^0.12.37 --dev - composer require friendsoftypo3/phpstan-typo3:^0.4.0 --dev Releases: master Resolves: #91635 Change-Id: Ia6b68e7ed1428fbc40ae4d1b9eb3a13d212a3a5c Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64851 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Benni Mack <benni@typo3.org> --- Build/phpstan.level2.neon | 12 ++- Build/phpstan.level3.neon | 21 ++--- Build/phpstan.level4.neon | 2 +- composer.json | 4 +- composer.lock | 135 ++++++++++++++++++++++++++++---- phpstan.neon | 4 +- typo3/sysext/core/composer.json | 2 +- 7 files changed, 146 insertions(+), 34 deletions(-) diff --git a/Build/phpstan.level2.neon b/Build/phpstan.level2.neon index 514b6d12b2c2..67d2e22afbd9 100644 --- a/Build/phpstan.level2.neon +++ b/Build/phpstan.level2.neon @@ -1,7 +1,7 @@ parameters: checkClassCaseSensitivity: true # checkThisOnly: false - checkPhpDocMissingReturn: true + checkPhpDocMissingReturn: false # todo: set to true rules: - PHPStan\Rules\Cast\EchoRule @@ -22,7 +22,7 @@ rules: - PHPStan\Rules\Operators\InvalidBinaryOperationRule - PHPStan\Rules\Operators\InvalidUnaryOperationRule - PHPStan\Rules\Operators\InvalidComparisonOperationRule - - PHPStan\Rules\PhpDoc\IncompatiblePhpDocTypeRule +# - PHPStan\Rules\PhpDoc\IncompatiblePhpDocTypeRule - PHPStan\Rules\PhpDoc\IncompatiblePropertyPhpDocTypeRule - PHPStan\Rules\PhpDoc\InvalidPhpDocTagValueRule - PHPStan\Rules\PhpDoc\InvalidPHPStanDocTagRule @@ -30,6 +30,14 @@ rules: - PHPStan\Rules\PhpDoc\WrongVariableNameInVarTagRule services: + - + class: PHPStan\Rules\Classes\MixinRule + arguments: + checkClassCaseSensitivity: %checkClassCaseSensitivity% + + tags: + - phpstan.rules.rule + - class: PHPStan\Rules\Functions\CallCallablesRule arguments: diff --git a/Build/phpstan.level3.neon b/Build/phpstan.level3.neon index d07dd93948d2..a93009e2bd2c 100644 --- a/Build/phpstan.level3.neon +++ b/Build/phpstan.level3.neon @@ -10,7 +10,6 @@ rules: - PHPStan\Rules\Arrays\UnpackIterableInArrayRule - PHPStan\Rules\Functions\ArrowFunctionReturnTypeRule - PHPStan\Rules\Functions\ClosureReturnTypeRule - - PHPStan\Rules\Functions\ReturnTypeRule - PHPStan\Rules\Generators\YieldTypeRule # - PHPStan\Rules\Methods\ReturnTypeRule - PHPStan\Rules\Properties\DefaultValueTypesAssignedToPropertiesRule @@ -18,6 +17,9 @@ rules: - PHPStan\Rules\Variables\ThrowTypeRule - PHPStan\Rules\Variables\VariableCloningRule +parameters: + checkPhpDocMethodSignatures: false # todo: set to true + services: - class: PHPStan\Rules\Arrays\AppendedArrayKeyTypeRule @@ -51,6 +53,14 @@ services: tags: - phpstan.rules.rule +# - +# class: PHPStan\Rules\Functions\ReturnTypeRule +# arguments: +# functionReflector: @betterReflectionFunctionReflector +# +# tags: +# - phpstan.rules.rule + - class: PHPStan\Rules\Generators\YieldFromTypeRule arguments: @@ -66,12 +76,3 @@ services: tags: - phpstan.rules.rule - -# - -# class: PHPStan\Rules\Methods\MethodSignatureRule -# arguments: -# reportMaybes: %reportMaybesInMethodSignatures% -# reportStatic: %reportStaticMethodSignatures% -# -# tags: -# - phpstan.rules.rule diff --git a/Build/phpstan.level4.neon b/Build/phpstan.level4.neon index f57d4a31fa69..58723da96242 100644 --- a/Build/phpstan.level4.neon +++ b/Build/phpstan.level4.neon @@ -5,7 +5,7 @@ rules: # - PHPStan\Rules\Arrays\DeadForeachRule # - PHPStan\Rules\Comparison\NumberComparisonOperatorsConstantConditionRule - PHPStan\Rules\DeadCode\NoopRule - - PHPStan\Rules\DeadCode\UnreachableStatementRule +# - PHPStan\Rules\DeadCode\UnreachableStatementRule - PHPStan\Rules\Exceptions\DeadCatchRule # - PHPStan\Rules\Functions\CallToFunctionStamentWithoutSideEffectsRule - PHPStan\Rules\Methods\CallToMethodStamentWithoutSideEffectsRule diff --git a/composer.json b/composer.json index 93e4aca65f6a..394011110153 100644 --- a/composer.json +++ b/composer.json @@ -85,10 +85,10 @@ "codeception/module-webdriver": "^1.0.1", "composer/package-versions-deprecated": "^1.10", "friendsofphp/php-cs-fixer": "^2.16.1", - "friendsoftypo3/phpstan-typo3": "^0.3.0", + "friendsoftypo3/phpstan-typo3": "^0.4.0", "php-webdriver/webdriver": "^1.8", "phpspec/prophecy": "^1.7.5", - "phpstan/phpstan": "^0.12.13", + "phpstan/phpstan": "^0.12.37", "rector/rector": "^0.7.14", "typo3/cms-styleguide": "~10.0.2", "typo3/testing-framework": "^6.3.3" diff --git a/composer.lock b/composer.lock index 6f27576d4e04..95df8d166233 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": "9f1a24a857fcd910af3c87ab1fced394", + "content-hash": "44f430feb41c47dfb37d4e426a945c54", "packages": [ { "name": "cogpowered/finediff", @@ -2601,6 +2601,20 @@ "polyfill", "portable" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-02-27T09:26:54+00:00" }, { @@ -2659,6 +2673,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-02-27T09:26:54+00:00" }, { @@ -2721,6 +2749,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-09T19:04:49+00:00" }, { @@ -2780,6 +2822,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-09T19:04:49+00:00" }, { @@ -2835,6 +2891,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-02-27T09:26:54+00:00" }, { @@ -2893,6 +2963,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-02-27T09:26:54+00:00" }, { @@ -4800,23 +4884,23 @@ }, { "name": "friendsoftypo3/phpstan-typo3", - "version": "0.3.0", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/FriendsOfTYPO3/phpstan-typo3.git", - "reference": "d5db3d0b4d5b1db1cf9e4c4139d808d9a105eaf4" + "reference": "634dafe109923ee4a556200ddf80951f3714c935" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfTYPO3/phpstan-typo3/zipball/d5db3d0b4d5b1db1cf9e4c4139d808d9a105eaf4", - "reference": "d5db3d0b4d5b1db1cf9e4c4139d808d9a105eaf4", + "url": "https://api.github.com/repos/FriendsOfTYPO3/phpstan-typo3/zipball/634dafe109923ee4a556200ddf80951f3714c935", + "reference": "634dafe109923ee4a556200ddf80951f3714c935", "shasum": "" }, "require": { "php": "^7.2", - "phpstan/phpstan": "^0.12.14", - "typo3/cms-core": "^10.0 || 11.0.*@dev", - "typo3/cms-extbase": "^10.0 || 11.0.*@dev" + "phpstan/phpstan": "^0.12.28", + "typo3/cms-core": "11.0.*@dev", + "typo3/cms-extbase": "11.0.*@dev" }, "require-dev": { "ergebnis/composer-normalize": "^2.3", @@ -4835,7 +4919,7 @@ "GPL-2.0-or-later" ], "description": "TYPO3 rules for PHPStan", - "time": "2020-05-26T08:20:57+00:00" + "time": "2020-06-10T15:34:04+00:00" }, { "name": "jean85/pretty-package-versions", @@ -5947,20 +6031,23 @@ }, { "name": "phpstan/phpstan", - "version": "0.12.14", + "version": "0.12.37", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "37bdd26a80235d0f9045b49f4151102b7831cbe2" + "reference": "5e16d83e6eb2dd784fbdaeaece5e2bca72e4f68a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/37bdd26a80235d0f9045b49f4151102b7831cbe2", - "reference": "37bdd26a80235d0f9045b49f4151102b7831cbe2", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/5e16d83e6eb2dd784fbdaeaece5e2bca72e4f68a", + "reference": "5e16d83e6eb2dd784fbdaeaece5e2bca72e4f68a", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" }, "bin": [ "phpstan", @@ -5982,7 +6069,21 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2020-03-02T22:29:43+00:00" + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2020-08-09T14:32:41+00:00" }, { "name": "phpstan/phpstan-phpunit", @@ -8109,8 +8210,8 @@ "authors": [ { "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "role": "Developer", + "email": "arne@blankerts.de" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", diff --git a/phpstan.neon b/phpstan.neon index de9b75a86863..12b88e37a611 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,6 +10,8 @@ parameters: # Set to true during local runs to find unmatched ignored errors. bamboo needs this to be set to false. reportUnmatchedIgnoredErrors: false + scanDirectories: + - %currentWorkingDirectory%/typo3/sysext/ paths: - %currentWorkingDirectory%/typo3/sysext/ @@ -21,7 +23,7 @@ parameters: ignoreErrors: # ignored errors for level 0 - - '#Undefined variable: \$_EXTKEY#' + - '#Variable \$_EXTKEY might not be defined\.#' - message: '#Instantiated class Composer\\Util\\Filesystem not found\.#' path: %currentWorkingDirectory%/typo3/sysext/core/Classes/Composer/CliEntryPoint.php diff --git a/typo3/sysext/core/composer.json b/typo3/sysext/core/composer.json index 45544f3fb486..2414454cb147 100644 --- a/typo3/sysext/core/composer.json +++ b/typo3/sysext/core/composer.json @@ -68,7 +68,7 @@ "codeception/module-webdriver": "^1.0.1", "friendsofphp/php-cs-fixer": "^2.16.1", "phpspec/prophecy": "^1.7.5", - "phpstan/phpstan": "^0.12.13", + "phpstan/phpstan": "^0.12.37", "typo3/cms-styleguide": "~10.0.2", "typo3/testing-framework": "^6.3.3" }, -- GitLab