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

Found 4 rules:

RemoveEraseCredentialsRector

Remove unused UserInterface::eraseCredentials() method, make it part of serialize if needed

 use Symfony\Component\Security\Core\User\UserInterface;

 final class User implements UserInterface
 {
-    public function eraseCredentials()
-    {
-        // some logic here
-    }
 }
PACKAGE:  symfony/security-core >=8.0

AuthorizationCheckerToAccessDecisionManagerInVoterRector

Replaces AuthorizationCheckerInterface with AccessDecisionManagerInterface inside Symfony Voters

-use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
+use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
 use Symfony\Component\Security\Core\Authorization\Voter\Voter;
 use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;

 final class AuthorizationCheckerVoter extends Voter
 {
     public function __construct(
-        private AuthorizationCheckerInterface $authorizationChecker
+        private AccessDecisionManagerInterface $accessDecisionManager
     ) {}

     protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
     {
-        return $this->authorizationChecker->isGranted('ROLE_ADMIN', $subject);
+        return $this->accessDecisionManager->decide($token, ['ROLE_ADMIN'], $subject);
     }
 }
PACKAGE:  symfony/security-core >=7.3

AddVoteArgumentToVoteOnAttributeRector

Adds a new $voter argument in protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?Vote $vote = null): bool

 use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
 use Symfony\Component\Security\Core\Authorization\Voter\Voter;

 final class MyVoter extends Voter
 {
     protected function supports(string $attribute, mixed $subject): bool
     {
         return true;
     }

-    protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
+    protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
     {
         return true;
     }
 }
PACKAGE:  symfony/security-core >=7.3

AuthorizationCheckerIsGrantedExtractorRector

Change $this->authorizationChecker->isGranted([$a, $b]) to $this->authorizationChecker->isGranted($a) || $this->authorizationChecker->isGranted($b), also updates AbstractController usages

 use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

 final class SomeController
 {
     public function __construct(
         private AuthorizationCheckerInterface $authorizationChecker
     ) {
     }

     public function hasAccess(): bool
     {
-        if ($this->authorizationChecker->isGranted(['ROLE_USER', 'ROLE_ADMIN'])) {
+        if ($this->authorizationChecker->isGranted('ROLE_USER') || $this->authorizationChecker->isGranted('ROLE_ADMIN')) {
             return true;
         }

         return false;
     }
 }
PACKAGE:  symfony/security-core >=4.4