diff --git a/rector.php b/rector.php index 95f52ad3e7f..1cde3342073 100644 --- a/rector.php +++ b/rector.php @@ -8,6 +8,7 @@ use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; use Rector\Php84\Rector\Class_\DeprecatedAnnotationToDeprecatedAttributeRector; +use Rector\Symfony\Symfony61\Rector\Class_\CommandConfigureToAttributeRector; return RectorConfig::configure() ->withPreparedSets( @@ -24,7 +25,7 @@ phpunitCodeQuality: true ) ->withAttributesSets() - ->withComposerBased(phpunit: true) + ->withComposerBased(phpunit: true, symfony: true) ->withPhpSets() ->withPaths([ __DIR__ . '/bin', @@ -41,6 +42,10 @@ ->withImportNames() ->withSkip([ StringClassNameToClassConstantRector::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)); }