From f5fd0ebbf078f916672171ecbcc9e871f7456500 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 11 Sep 2026 20:47:25 +0200 Subject: [PATCH 1/2] Move EnableValidationAttributesRector into composer-based upgrade path Bind the rule to symfony/framework-bundle >=6.4, the version that introduced the framework.validation.enable_attributes config key (replacing enable_annotations, removed in 7.0). Registered in the version-bound composer-based set instead of the flat configs set. Claude-Session: https://claude.ai/code/session_01WD78HWwUoj2bSAppDbaNa1 --- config/sets/symfony/composer-based.php | 4 ++++ config/sets/symfony/configs.php | 2 -- .../EnableValidationAttributesRectorTest.php | 5 +++++ .../config/composer.json | 5 +++++ .../MethodCall/EnableValidationAttributesRector.php | 10 +++++++++- 5 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 rules-tests/Configs/Rector/MethodCall/EnableValidationAttributesRector/config/composer.json diff --git a/config/sets/symfony/composer-based.php b/config/sets/symfony/composer-based.php index 0588e3629..fa5b9501d 100644 --- a/config/sets/symfony/composer-based.php +++ b/config/sets/symfony/composer-based.php @@ -44,6 +44,7 @@ use Rector\Symfony\CodeQuality\Rector\Class_\LoadValidatorMetadataToAttributeRector; use Rector\Symfony\CodeQuality\Rector\Class_\SplitAndSecurityAttributeToIsGrantedRector; use Rector\Symfony\CodeQuality\Rector\MethodCall\ParameterBagTypedGetMethodCallRector; +use Rector\Symfony\Configs\Rector\MethodCall\EnableValidationAttributesRector; use Rector\Symfony\JMS\Rector\Class_\AccessTypeAnnotationToAttributeRector; use Rector\Symfony\JMS\Rector\Property\AccessorAnnotationToAttributeRector; use Rector\Symfony\Symfony25\Rector\MethodCall\AddViolationToBuildViolationRector; @@ -305,6 +306,9 @@ // symfony/dependency-injection 6.3 ParamAndEnvAttributeRector::class, + // symfony/framework-bundle 6.4 + EnableValidationAttributesRector::class, + // symfony/http-foundation 7.2 PushRequestToRequestStackConstructorRector::class, diff --git a/config/sets/symfony/configs.php b/config/sets/symfony/configs.php index 217e2ffec..39398737d 100644 --- a/config/sets/symfony/configs.php +++ b/config/sets/symfony/configs.php @@ -10,7 +10,6 @@ use Rector\Symfony\Configs\Rector\Closure\ServiceSetStringNameToClassNameRector; use Rector\Symfony\Configs\Rector\Closure\ServiceSettersToSettersAutodiscoveryRector; use Rector\Symfony\Configs\Rector\Closure\ServiceTagsToDefaultsAutoconfigureRector; -use Rector\Symfony\Configs\Rector\MethodCall\EnableValidationAttributesRector; return static function (RectorConfig $rectorConfig): void { $rectorConfig->rules([ @@ -21,6 +20,5 @@ ServiceTagsToDefaultsAutoconfigureRector::class, RemoveConstructorAutowireServiceRector::class, FromServicePublicToDefaultsPublicRector::class, - EnableValidationAttributesRector::class, ]); }; diff --git a/rules-tests/Configs/Rector/MethodCall/EnableValidationAttributesRector/EnableValidationAttributesRectorTest.php b/rules-tests/Configs/Rector/MethodCall/EnableValidationAttributesRector/EnableValidationAttributesRectorTest.php index 7543e2f95..fff28f574 100644 --- a/rules-tests/Configs/Rector/MethodCall/EnableValidationAttributesRector/EnableValidationAttributesRectorTest.php +++ b/rules-tests/Configs/Rector/MethodCall/EnableValidationAttributesRector/EnableValidationAttributesRectorTest.php @@ -25,4 +25,9 @@ public function provideConfigFilePath(): string { return __DIR__ . '/config/configured_rule.php'; } + + protected function provideComposerJsonFilePath(): string + { + return __DIR__ . '/config/composer.json'; + } } diff --git a/rules-tests/Configs/Rector/MethodCall/EnableValidationAttributesRector/config/composer.json b/rules-tests/Configs/Rector/MethodCall/EnableValidationAttributesRector/config/composer.json new file mode 100644 index 000000000..81e1b643d --- /dev/null +++ b/rules-tests/Configs/Rector/MethodCall/EnableValidationAttributesRector/config/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "symfony/framework-bundle": "^6.4" + } +} diff --git a/rules/Configs/Rector/MethodCall/EnableValidationAttributesRector.php b/rules/Configs/Rector/MethodCall/EnableValidationAttributesRector.php index 454b2aa37..5cfb74be7 100644 --- a/rules/Configs/Rector/MethodCall/EnableValidationAttributesRector.php +++ b/rules/Configs/Rector/MethodCall/EnableValidationAttributesRector.php @@ -13,19 +13,27 @@ use PhpParser\Node\Name; use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Rector\AbstractRector; +use Rector\VersionBonding\Contract\ComposerPackageConstraintInterface; +use Rector\VersionBonding\ValueObject\ComposerPackageConstraint; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Symfony\Tests\Configs\Rector\MethodCall\EnableValidationAttributesRector\EnableValidationAttributesRectorTest */ -final class EnableValidationAttributesRector extends AbstractRector +final class EnableValidationAttributesRector extends AbstractRector implements ComposerPackageConstraintInterface { public function __construct( private readonly ValueResolver $valueResolver ) { } + public function provideComposerPackageConstraint(): ComposerPackageConstraint + { + // "enable_attributes" config key added in framework-bundle 6.4, replacing "enable_annotations" + return new ComposerPackageConstraint('symfony/framework-bundle', '>=6.4'); + } + public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( From 5214ebd40179159da2b917f155c2828242d860ce Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 11 Sep 2026 18:48:10 +0000 Subject: [PATCH 2/2] [rector] Rector fixes --- .../MethodCall/WebLinkStringRelationsToConstantsRector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/Symfony44/Rector/MethodCall/WebLinkStringRelationsToConstantsRector.php b/rules/Symfony44/Rector/MethodCall/WebLinkStringRelationsToConstantsRector.php index f6798bdf0..988ab7b26 100644 --- a/rules/Symfony44/Rector/MethodCall/WebLinkStringRelationsToConstantsRector.php +++ b/rules/Symfony44/Rector/MethodCall/WebLinkStringRelationsToConstantsRector.php @@ -94,7 +94,7 @@ public function refactor(Node $node): ?Node } $constFetch = $this->createConstantFetch($valueNode->value); - if (! $constFetch) { + if (!$constFetch instanceof Node) { return null; }