Find the best Rector rule to solve your problem. Searching through 1009 rules.

Found 6 rules:

RemoveEraseCredentialsFromAuthenticatorManagerRector

Remove unused $eraseCredentials argument from AuthenticatorManager constructor

 use Symfony\Component\Security\Http\Authentication\AuthenticatorManager;

 final class Foo
 {
     public function bar(): void
     {
         new AuthenticatorManager(
             $authenticators,
             $tokenStorage,
             $eventDispatcher,
             $firewallName,
-            true
         );
     }
 }
PACKAGE:  symfony/security-http >=8.1

SecurityAttributeToIsGrantedAttributeRector

Replaces #[Security] framework-bundle attribute with Symfony native #[IsGranted] one

-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
+use Symfony\Component\ExpressionLanguage\Expression;
+use Symfony\Component\Security\Http\Attribute\IsGranted;

 class PostController extends Controller
 {
-    #[Security("is_granted('ROLE_ADMIN')")]
+    #[IsGranted(attribute: 'ROLE_ADMIN')]
     public function index()
     {
     }

-    #[Security("is_granted('ROLE_ADMIN') and is_granted('ROLE_FRIENDLY_USER')")]
+    #[IsGranted(attribute: new Expression("is_granted('ROLE_ADMIN') and is_granted('ROLE_FRIENDLY_USER')"))]
     public function list()
     {
     }
 }
PACKAGE:  symfony/security-http >=6.2

SingleConditionSecurityAttributeToIsGrantedRector

Narrow #[Security] attribute with inner single "is_granted/has_role" condition string to #[IsGranted] attribute

-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
+use Symfony\Component\Security\Http\Attribute\IsGranted;

-#[Security("is_granted('ROLE_USER')")]
+#[IsGranted('ROLE_USER')]
 class SomeClass
 {
 }
PACKAGE:  symfony/security-http >=6.2

SplitAndSecurityAttributeToIsGrantedRector

Split #[Security] attribute with "and" condition string to multiple #[IsGranted] attributes with sole values

-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
+use Symfony\Component\Security\Http\Attribute\IsGranted;

-#[Security("is_granted('ROLE_USER') and has_role('ROLE_ADMIN')")]
+#[IsGranted('ROLE_USER')]
+#[IsGranted('ROLE_ADMIN')]
 class SomeClass
 {
 }
PACKAGE:  symfony/security-http >=6.2

LogoutHandlerToLogoutEventSubscriberRector

Change logout handler to an event listener that listens to LogoutEvent

-use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\Security\Http\Event\LogoutEvent;

-final class SomeLogoutHandler implements LogoutHandlerInterface
+final class SomeLogoutHandler implements EventSubscriberInterface
 {
-    public function logout(Request $request, Response $response, TokenInterface $token)
+    public function onLogout(LogoutEvent $logoutEvent): void
+    {
+        $request = $logoutEvent->getRequest();
+        $response = $logoutEvent->getResponse();
+        $token = $logoutEvent->getToken();
+    }
+
+    /**
+     * @return array<string, string[]>
+     */
+    public static function getSubscribedEvents(): array
     {
+        return [
+            LogoutEvent::class => ['onLogout'],
+        ];
     }
 }
PACKAGE:  symfony/security-http >=5.1

LogoutSuccessHandlerToLogoutEventSubscriberRector

Change logout success handler to an event listener that listens to LogoutEvent

-use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\Security\Http\Event\LogoutEvent;

-final class SomeLogoutHandler implements LogoutSuccessHandlerInterface
+final class SomeLogoutHandler implements EventSubscriberInterface
 {
     /**
       * @var HttpUtils
       */
     private $httpUtils;

-    public function __construct(HttpUtils $httpUtils)
+    public function onLogout(LogoutEvent $logoutEvent): void
     {
-        $this->httpUtils = $httpUtils;
+        if ($logoutEvent->getResponse() !== null) {
+            return;
+        }
+
+        $response = $this->httpUtils->createRedirectResponse($logoutEvent->getRequest(), 'some_url');
+        $logoutEvent->setResponse($response);
     }

-    public function onLogoutSuccess(Request $request)
+    /**
+     * @return array<string, mixed>
+     */
+    public static function getSubscribedEvents(): array
     {
-        $response = $this->httpUtils->createRedirectResponse($request, 'some_url');
-        return $response;
+        return [
+            LogoutEvent::class => [['onLogout', 64]],
+        ];
     }
 }
PACKAGE:  symfony/security-http >=5.1