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('ROLE_ADMIN')]
     public function index()
     {
     }

-    #[Security("is_granted('ROLE_ADMIN') and is_granted('ROLE_FRIENDLY_USER')")]
+    #[IsGranted(new Expression("is_granted('ROLE_ADMIN') and is_granted('ROLE_FRIENDLY_USER')"))]
     public function list()
     {
     }
 }

Configure your rector.php:

<?php

use Rector\Config\RectorConfig;
use Rector\Symfony\Symfony62\Rector\Class_\SecurityAttributeToIsGrantedAttributeRector;

return RectorConfig::configure()
    ->withRules([
        SecurityAttributeToIsGrantedAttributeRector::class,
    ]);
SETS:  symfony/* 6.2