Repository: symfony/symfony
File: src/Symfony/Bundle/SecurityBundle/Security.php (PHP)

Code before:
        private readonly ContainerInterface $container,
        private readonly array $authenticators = [],
    ) {
    }

    public function getUser(): ?UserInterface
    {
        if (!$token = $this->getToken()) {
            return null;
        }

        return $token->getUser();
    }

    /**
     * Checks if the attributes are granted against the current authentication token and optionally supplied subject.
     */
    public function isGranted(mixed $attributes, mixed $subject = null, ?AccessDecision $accessDecision = null): bool
    {
        return $this->container->get('security.authorization_checker')
            ->isGranted($attributes, $subject, $accessDecision);
    }

    public function accessDecision(mixed $attributes, mixed $subject = null, ?AccessDecision $accessDecision = null): AccessDecision
    {
        $accessDecision = $accessDecision ?? new AccessDecision();
        $this->isGranted($attributes, $subject, $accessDecision);

        return $accessDecision;
    }

    /**
     * Checks if the attribute is granted against the user and optionally supplied subject.
     *
     * This should be used over isGranted() when checking permissions against a user that is not currently logged in or while in a CLI context.
     */
    public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool
    {
        return $this->container->get('security.user_authorization_checker')
            ->isGrantedForUser($user, $attribute, $subject, $accessDecision);
    }

    public function accessDecisionForUser(UserInterface $user, mixed $attributes, mixed $subject = null, ?AccessDecision $accessDecision = null): AccessDecision
    {
        $accessDecision = $accessDecision ?? new AccessDecision();
        $this->isGrantedForUser($user, $attributes, $subject, $accessDecision);

        return $accessDecision;
    }



Review comment (suggestion):
```suggestion
    public function accessDecision(mixed $attributes, mixed $subject = null): AccessDecision
    {
        $accessDecision = new AccessDecision();
```

Code after:
        private readonly ContainerInterface $container,
        private readonly array $authenticators = [],
    ) {
    }

    public function getUser(): ?UserInterface
    {
        if (!$token = $this->getToken()) {
            return null;
        }

        return $token->getUser();
    }

    /**
     * Checks if the attributes are granted against the current authentication token and optionally supplied subject.
     */
    public function isGranted(mixed $attributes, mixed $subject = null, ?AccessDecision $accessDecision = null): bool
    {
        return $this->container->get('security.authorization_checker')
            ->isGranted($attributes, $subject, $accessDecision);
    }

    public function getAccessDecision(mixed $attributes, mixed $subject = null): AccessDecision
    {
        $accessDecision = new AccessDecision();
        $this->isGranted($attributes, $subject, $accessDecision);

        return $accessDecision;
    }

    /**
     * Checks if the attribute is granted against the user and optionally supplied subject.
     *
     * This should be used over isGranted() when checking permissions against a user that is not currently logged in or while in a CLI context.
     */
    public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null, ?AccessDecision $accessDecision = null): bool
    {
        return $this->container->get('security.user_authorization_checker')
            ->isGrantedForUser($user, $attribute, $subject, $accessDecision);
    }

    public function getAccessDecisionForUser(UserInterface $user, mixed $attributes, mixed $subject = null): AccessDecision
    {
        $accessDecision = new AccessDecision();
        $this->isGrantedForUser($user, $attributes, $subject, $accessDecision);

        return $accessDecision;
    }

    public function getToken(): ?TokenInterface