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');
+        return $this->accessDecisionManager->decide($token, ['ROLE_ADMIN']);
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony73\Rector\Class_\AuthorizationCheckerToAccessDecisionManagerInVoterRector;

return RectorConfig::configure()
    ->withRules([
        AuthorizationCheckerToAccessDecisionManagerInVoterRector::class,
    ]);