From 293607e889ec5a6576e95ccbd16c3dee0fc89222 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Tue, 23 Sep 2025 19:35:17 +0700 Subject: [PATCH] [Symfony 6.2] Move symfony/security-core to security-http and security-bundle as target class/contant exists there --- config/sets/symfony/symfony6/symfony62.php | 2 +- .../symfony62/symfony62-security-bundle.php | 17 +++++++ .../symfony62/symfony62-security-core.php | 48 ------------------- .../symfony62/symfony62-security-http.php | 31 ++++++++++++ .../Fixture/some_class.php | 28 ----------- src/Set/SetProvider/Symfony6SetProvider.php | 4 +- 6 files changed, 51 insertions(+), 79 deletions(-) create mode 100644 config/sets/symfony/symfony6/symfony62/symfony62-security-bundle.php delete mode 100644 config/sets/symfony/symfony6/symfony62/symfony62-security-core.php delete mode 100644 rules-tests/Symfony51/Rector/ClassMethod/RouteCollectionBuilderToRoutingConfiguratorRector/Fixture/some_class.php diff --git a/config/sets/symfony/symfony6/symfony62.php b/config/sets/symfony/symfony6/symfony62.php index fd8a16d76..e6fc3d84f 100644 --- a/config/sets/symfony/symfony6/symfony62.php +++ b/config/sets/symfony/symfony6/symfony62.php @@ -19,7 +19,7 @@ new AnnotationToAttribute('Sensio\Bundle\FrameworkExtraBundle\Configuration\Template'), ]); - $rectorConfig->import(__DIR__ . '/symfony62/symfony62-security-core.php'); + $rectorConfig->import(__DIR__ . '/symfony62/symfony62-security-bundle.php'); $rectorConfig->import(__DIR__ . '/symfony62/symfony62-security-http.php'); $rectorConfig->import(__DIR__ . '/symfony62/symfony62-mime.php'); $rectorConfig->import(__DIR__ . '/symfony62/symfony62-http-kernel.php'); diff --git a/config/sets/symfony/symfony6/symfony62/symfony62-security-bundle.php b/config/sets/symfony/symfony6/symfony62/symfony62-security-bundle.php new file mode 100644 index 000000000..73d1a7a7b --- /dev/null +++ b/config/sets/symfony/symfony6/symfony62/symfony62-security-bundle.php @@ -0,0 +1,17 @@ +ruleWithConfiguration( + RenameClassRector::class, + [ + // @see https://github.com/symfony/symfony/pull/46094 + 'Symfony\Component\Security\Core\Security' => 'Symfony\Bundle\SecurityBundle\Security', + ], + ); +}; diff --git a/config/sets/symfony/symfony6/symfony62/symfony62-security-core.php b/config/sets/symfony/symfony6/symfony62/symfony62-security-core.php deleted file mode 100644 index 68be856b3..000000000 --- a/config/sets/symfony/symfony6/symfony62/symfony62-security-core.php +++ /dev/null @@ -1,48 +0,0 @@ -ruleWithConfiguration( - RenameClassRector::class, - [ - // @see https://github.com/symfony/symfony/pull/46094 - 'Symfony\Component\Security\Core\Security' => 'Symfony\Bundle\SecurityBundle\Security', - ], - ); - - // @see https://github.com/symfony/symfony/pull/46094 - // @see https://github.com/symfony/symfony/pull/48554 - $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [ - new RenameClassAndConstFetch( - 'Symfony\Component\Security\Core\Security', - 'ACCESS_DENIED_ERROR', - 'Symfony\Component\Security\Http\SecurityRequestAttributes', - 'ACCESS_DENIED_ERROR' - ), - new RenameClassAndConstFetch( - 'Symfony\Component\Security\Core\Security', - 'AUTHENTICATION_ERROR', - 'Symfony\Component\Security\Http\SecurityRequestAttributes', - 'AUTHENTICATION_ERROR' - ), - new RenameClassAndConstFetch( - 'Symfony\Component\Security\Core\Security', - 'LAST_USERNAME', - 'Symfony\Component\Security\Http\SecurityRequestAttributes', - 'LAST_USERNAME' - ), - new RenameClassAndConstFetch( - 'Symfony\Component\Security\Core\Security', - 'MAX_USERNAME_LENGTH', - 'Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge', - 'MAX_USERNAME_LENGTH' - ), - ]); -}; diff --git a/config/sets/symfony/symfony6/symfony62/symfony62-security-http.php b/config/sets/symfony/symfony6/symfony62/symfony62-security-http.php index add1d3093..832ff71c1 100644 --- a/config/sets/symfony/symfony6/symfony62/symfony62-security-http.php +++ b/config/sets/symfony/symfony6/symfony62/symfony62-security-http.php @@ -5,6 +5,8 @@ use Rector\Config\RectorConfig; use Rector\Renaming\Rector\Name\RenameClassRector; use Rector\Symfony\Symfony62\Rector\Class_\SecurityAttributeToIsGrantedAttributeRector; +use Rector\Renaming\Rector\ClassConstFetch\RenameClassConstFetchRector; +use Rector\Renaming\ValueObject\RenameClassAndConstFetch; return static function (RectorConfig $rectorConfig): void { $rectorConfig->rule(SecurityAttributeToIsGrantedAttributeRector::class); @@ -16,4 +18,33 @@ 'Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted' => 'Symfony\Component\Security\Http\Attribute\IsGranted', ], ); + + // @see https://github.com/symfony/symfony/pull/46094 + // @see https://github.com/symfony/symfony/pull/48554 + $rectorConfig->ruleWithConfiguration(RenameClassConstFetchRector::class, [ + new RenameClassAndConstFetch( + 'Symfony\Component\Security\Core\Security', + 'ACCESS_DENIED_ERROR', + 'Symfony\Component\Security\Http\SecurityRequestAttributes', + 'ACCESS_DENIED_ERROR' + ), + new RenameClassAndConstFetch( + 'Symfony\Component\Security\Core\Security', + 'AUTHENTICATION_ERROR', + 'Symfony\Component\Security\Http\SecurityRequestAttributes', + 'AUTHENTICATION_ERROR' + ), + new RenameClassAndConstFetch( + 'Symfony\Component\Security\Core\Security', + 'LAST_USERNAME', + 'Symfony\Component\Security\Http\SecurityRequestAttributes', + 'LAST_USERNAME' + ), + new RenameClassAndConstFetch( + 'Symfony\Component\Security\Core\Security', + 'MAX_USERNAME_LENGTH', + 'Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge', + 'MAX_USERNAME_LENGTH' + ), + ]); }; diff --git a/rules-tests/Symfony51/Rector/ClassMethod/RouteCollectionBuilderToRoutingConfiguratorRector/Fixture/some_class.php b/rules-tests/Symfony51/Rector/ClassMethod/RouteCollectionBuilderToRoutingConfiguratorRector/Fixture/some_class.php deleted file mode 100644 index a178e7c60..000000000 --- a/rules-tests/Symfony51/Rector/ClassMethod/RouteCollectionBuilderToRoutingConfiguratorRector/Fixture/some_class.php +++ /dev/null @@ -1,28 +0,0 @@ -add('/admin', 'App\Controller\AdminController::dashboard', 'admin_dashboard'); - } - - public function registerBundles() - { - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } -} - -?> diff --git a/src/Set/SetProvider/Symfony6SetProvider.php b/src/Set/SetProvider/Symfony6SetProvider.php index 3a19376a4..f52fb7e15 100644 --- a/src/Set/SetProvider/Symfony6SetProvider.php +++ b/src/Set/SetProvider/Symfony6SetProvider.php @@ -200,9 +200,9 @@ public function provide(): array ), new ComposerTriggeredSet( SetGroup::SYMFONY, - 'symfony/security-core', + 'symfony/security-bundle', '6.2', - __DIR__ . '/../../../config/sets/symfony/symfony6/symfony62/symfony62-security-core.php' + __DIR__ . '/../../../config/sets/symfony/symfony6/symfony62/symfony62-security-bundle.php' ), new ComposerTriggeredSet( SetGroup::SYMFONY,