From 4c929754e9aef732c24e8b80ff75b182cc543be1 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 23 Feb 2025 02:49:08 +0100 Subject: [PATCH] phpstan: Upgrade to version 2 https://github.com/phpstan/phpstan/blob/2.1.x/UPGRADING.md Required also bumping Rector since it uses PHPStan internally. --- composer.json | 6 +++--- phpstan.dist.neon | 2 -- rector.php | 27 +++++++-------------------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index dd26256..29c9abd 100644 --- a/composer.json +++ b/composer.json @@ -33,9 +33,9 @@ "friendsofphp/php-cs-fixer": "^3.0", "monolog/monolog": "^1.24|^2.1", "symfony/phpunit-bridge": "^4.4|^5.3|^6.0", - "phpstan/phpstan": "^1.3", - "phpstan/phpstan-phpunit": "^1.0", - "rector/rector": "^0.15.0" + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "rector/rector": "^2.0.0" }, "suggest": { "ext-tidy": "Used to clean up given HTML and to avoid problems with bad HTML structure." diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 895d58d..7e5d5d8 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -8,8 +8,6 @@ parameters: bootstrapFiles: - vendor/bin/.phpunit/phpunit/vendor/autoload.php - checkMissingIterableValueType: false - includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon diff --git a/rector.php b/rector.php index 8c99642..a01eb15 100644 --- a/rector.php +++ b/rector.php @@ -3,29 +3,16 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Core\ValueObject\PhpVersion; use Rector\Set\ValueObject\LevelSetList; -return static function (RectorConfig $rectorConfig): void { - // paths to refactor; solid alternative to CLI arguments - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/src', __DIR__ . '/tests', - ]); - - // Path to phpstan with extensions, that PHPSTan in Rector uses to determine types - $rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon'); - - $rectorConfig->bootstrapFiles([ + ]) + ->withBootstrapFiles([ __DIR__ . '/vendor/bin/.phpunit/phpunit/vendor/autoload.php', __DIR__ . '/vendor/autoload.php', - ]); - - // Define what rule sets will be applied - $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_74, - ]); - - // is your PHP version different from the one your refactor to? - $rectorConfig->phpVersion(PhpVersion::PHP_74); -}; + ]) + ->withSets([LevelSetList::UP_TO_PHP_74]) +;