Skip to content

[composer-based] Add AuthorizationCheckerIsGrantedExtractorRector to the composer-based set - #985

Merged
TomasVotruba merged 1 commit into
mainfrom
composer-based-authorization-checker
Aug 2, 2026
Merged

[composer-based] Add AuthorizationCheckerIsGrantedExtractorRector to the composer-based set#985
TomasVotruba merged 1 commit into
mainfrom
composer-based-authorization-checker

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Bonds AuthorizationCheckerIsGrantedExtractorRector to symfony/security-core >=4.4 via ComposerPackageConstraintInterface, and registers it in config/sets/symfony/composer-based.php.

4.4 is the version that deprecated passing multiple attributes to AuthorizationCheckerInterface::isGranted(), see UPGRADE-4.4.md#security.

symfony/security-core is already a registered ComposerTriggeredSet package from >=4.3, so SymfonySetProvider needs no change.

What the rule does

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

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

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

Added a tests/ComposerBased fixture so the bonding is verified through the set itself, not only through the rule's own test.

…the composer-based set

Bond the rule to symfony/security-core >=4.4, the version that deprecated
passing multiple attributes to AuthorizationCheckerInterface::isGranted().

symfony/security-core is already a registered ComposerTriggeredSet package
from >=4.3, so no set provider change is needed.
@TomasVotruba
TomasVotruba merged commit 830de0d into main Aug 2, 2026
7 checks passed
@TomasVotruba
TomasVotruba deleted the composer-based-authorization-checker branch August 2, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant