From 5d0fd8b60d111c8314b0f239a58636bc576607ef Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 3 Aug 2026 19:02:51 +0200 Subject: [PATCH 1/2] Enable symfony composer-based set in rector.php - add symfony: true to withComposerBased() - fix fatal error in "composer-based" command on lazily-initialized typed properties (PHPStan UnionType::$normalized) - skip ConsoleExecuteReturnIntRector, it adds a redundant (int) cast that RecastingRemovalRector removes again --- rector.php | 10 +++++++++- src/Console/Command/ComposerBasedCommand.php | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/rector.php b/rector.php index 95f52ad3e7f..059af6df7b8 100644 --- a/rector.php +++ b/rector.php @@ -8,6 +8,8 @@ use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php84\Rector\Class_\DeprecatedAnnotationToDeprecatedAttributeRector; +use Rector\Symfony\Symfony44\Rector\ClassMethod\ConsoleExecuteReturnIntRector; +use Rector\Symfony\Symfony61\Rector\Class_\CommandConfigureToAttributeRector; return RectorConfig::configure() ->withPreparedSets( @@ -24,7 +26,7 @@ phpunitCodeQuality: true ) ->withAttributesSets() - ->withComposerBased(phpunit: true) + ->withComposerBased(phpunit: true, symfony: true) ->withPhpSets() ->withPaths([ __DIR__ . '/bin', @@ -41,6 +43,12 @@ ->withImportNames() ->withSkip([ StringClassNameToClassConstantRector::class, + + // adds (int) cast to methods that already return int, ping-pongs with RecastingRemovalRector + ConsoleExecuteReturnIntRector::class, + + // keep console command metadata in configure(), as more readable than a single long attribute + CommandConfigureToAttributeRector::class, // tests '*/Fixture*', '*/Source*', diff --git a/src/Console/Command/ComposerBasedCommand.php b/src/Console/Command/ComposerBasedCommand.php index 5ecb8c52153..31b06dce6f1 100644 --- a/src/Console/Command/ComposerBasedCommand.php +++ b/src/Console/Command/ComposerBasedCommand.php @@ -206,6 +206,11 @@ private function printConfigurationValue(mixed $value): string $reflectionObject = new ReflectionObject($value); foreach ($reflectionObject->getProperties() as $reflectionProperty) { + // lazy-initialized property, e.g. PHPStan UnionType::$normalized + if (! $reflectionProperty->isInitialized($value)) { + continue; + } + $printedPropertyValues[] = $this->printConfigurationValue($reflectionProperty->getValue($value)); } From 1d338acc7dae5e00f0b86f46faa397edce639bbe Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 3 Aug 2026 19:13:14 +0200 Subject: [PATCH 2/2] Drop ConsoleExecuteReturnIntRector skip, redundant cast fixed upstream --- rector.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rector.php b/rector.php index 059af6df7b8..1cde3342073 100644 --- a/rector.php +++ b/rector.php @@ -8,7 +8,6 @@ use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php84\Rector\Class_\DeprecatedAnnotationToDeprecatedAttributeRector; -use Rector\Symfony\Symfony44\Rector\ClassMethod\ConsoleExecuteReturnIntRector; use Rector\Symfony\Symfony61\Rector\Class_\CommandConfigureToAttributeRector; return RectorConfig::configure() @@ -44,11 +43,9 @@ ->withSkip([ StringClassNameToClassConstantRector::class, - // adds (int) cast to methods that already return int, ping-pongs with RecastingRemovalRector - ConsoleExecuteReturnIntRector::class, - // keep console command metadata in configure(), as more readable than a single long attribute CommandConfigureToAttributeRector::class, + // tests '*/Fixture*', '*/Source*',