From 37422a3a159d9567784173e7dd4262a787e95b32 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Fri, 20 Nov 2026 17:35:40 +0100 Subject: [PATCH] Fix rector CI check rector 2.7.0 with phpstan 2.3.7 fails to process several files (CallableTypeNode type error inside phpstan). Bump rector-setup to ~2.8.0, which works with phpstan 2.3. Apply its one new finding in Manager and skip the parent return type rule for Config::offsetGet(): adding a native mixed return type would break subclasses that override it without one. Drop two skipped rules that rector 2.8 no longer registers. --- composer.json | 2 +- rector.php | 9 +++++---- src/Migration/Manager.php | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index d4e58905..407fe41a 100644 --- a/composer.json +++ b/composer.json @@ -76,7 +76,7 @@ "stan-setup": "phive install", "lowest": "validate-prefer-lowest", "lowest-setup": "composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction && cp composer.json composer.backup && composer require --dev dereuromark/composer-prefer-lowest && mv composer.backup composer.json", - "rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.7.0\" phpstan/phpstan:\"~2.3.0\" && mv composer.backup composer.json", + "rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.8.0\" phpstan/phpstan:\"~2.3.0\" && mv composer.backup composer.json", "rector-check": "vendor/bin/rector process --dry-run", "rector-fix": "vendor/bin/rector process", "test": "phpunit", diff --git a/rector.php b/rector.php index fd378e4a..d3901ca9 100644 --- a/rector.php +++ b/rector.php @@ -4,12 +4,10 @@ use Rector\Caching\ValueObject\Storage\FileCacheStorage; use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector; use Rector\CodeQuality\Rector\If_\ArrayExplicitBoolCompareRector; -use Rector\CodeQuality\Rector\If_\ObjectExplicitBoolCompareRector; use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector; use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector; use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; use Rector\Config\RectorConfig; -use Rector\DeadCode\Rector\ClassMethod\RemoveDuplicatedReturnSelfDocblockRector; use Rector\DeadCode\Rector\ClassMethod\RemoveMixedDocblockOverruledByNativeTypeRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUselessUnionReturnDocblockRector; @@ -17,6 +15,7 @@ use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; use Rector\Set\ValueObject\SetList; use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector; $cacheDir = getenv('RECTOR_CACHE_DIR') ?: sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'rector'; @@ -55,8 +54,10 @@ NewlineAfterStatementRector::class, TypedPropertyFromCreateMockAssignRector::class, ArrayExplicitBoolCompareRector::class, - ObjectExplicitBoolCompareRector::class, RemoveUselessUnionReturnDocblockRector::class, RemoveMixedDocblockOverruledByNativeTypeRector::class, - RemoveDuplicatedReturnSelfDocblockRector::class, + // A native `mixed` return type would break subclasses overriding offsetGet() without one. + AddReturnTypeDeclarationBasedOnParentClassMethodRector::class => [ + __DIR__ . '/src/Config/Config.php', + ], ]); diff --git a/src/Migration/Manager.php b/src/Migration/Manager.php index 65ef382f..0b313e0d 100644 --- a/src/Migration/Manager.php +++ b/src/Migration/Manager.php @@ -838,6 +838,7 @@ public function getEnvironment(): Environment $environment = new Environment('default', $envOptions); $environment->setIo($this->getIo()); + $this->environment = $environment; return $environment;