Repository: symfony/symfony
File: src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php (PHP)

Code before:
    }

    /**
     * @param bool $allowMultipleAttributes Whether to allow passing multiple values to the $attributes array
     */
    public function decide(TokenInterface $token, array $attributes, mixed $object = null, bool|AccessDecision|null $accessDecision = null, bool $allowMultipleAttributes = false): bool
    {
        if (\is_bool($accessDecision)) {
            $allowMultipleAttributes = $accessDecision;
            $accessDecision = null;
        }

        // Special case for AccessListener, do not remove the right side of the condition before 6.0
        if (\count($attributes) > 1 && !$allowMultipleAttributes) {
            throw new InvalidArgumentException(\sprintf('Passing more than one Security attribute to "%s()" is not supported.', __METHOD__));
        }

        $accessDecision ??= end($this->accessDecisionStack) ?: new AccessDecision();
        $this->accessDecisionStack[] = $accessDecision;

        $accessDecision->strategy = $this->strategy instanceof \Stringable ? $this->strategy : get_debug_type($this->strategy);

        try {
            return $accessDecision->isGranted = $this->strategy->decide(
                $this->collectResults($token, $attributes, $object, $accessDecision)
                , $accessDecision
            );
        } finally {
            array_pop($this->accessDecisionStack);
        }
    }

    /**
     * @return \Traversable<int, VoterInterface::ACCESS_*>
     */
    private function collectResults(TokenInterface $token, array $attributes, mixed $object, AccessDecision $accessDecision): \Traversable
    {
        foreach ($this->getVoters($attributes, $object) as $voter) {
            $vote = new Vote();
            $result = $voter->vote($token, $object, $attributes, $vote);

            if (!\is_int($result) || !(self::VALID_VOTES[$result] ?? false)) {
                throw new \LogicException(\sprintf('"%s::vote()" must return one of "%s" constants ("ACCESS_GRANTED", "ACCESS_DENIED" or "ACCESS_ABSTAIN"), "%s" returned.', get_debug_type($voter), VoterInterface::class, var_export($result, true)));
            }

            $voter = $voter instanceof TraceableVoter ? $voter->getDecoratedVoter() : $voter;
            $vote->voter = $voter instanceof \Stringable ? $voter : get_debug_type($voter);
            $vote->result = $result;
            $accessDecision->votes[] = $vote;

            yield $result;

Review comment (suggestion):
```suggestion
                $this->collectResults($token, $attributes, $object, $accessDecision),
                $accessDecision
```

Code after:
    }

    /**
     * @param bool $allowMultipleAttributes Whether to allow passing multiple values to the $attributes array
     */
    public function decide(TokenInterface $token, array $attributes, mixed $object = null, bool|AccessDecision|null $accessDecision = null, bool $allowMultipleAttributes = false): bool
    {
        if (\is_bool($accessDecision)) {
            $allowMultipleAttributes = $accessDecision;
            $accessDecision = null;
        }

        // Special case for AccessListener, do not remove the right side of the condition before 6.0
        if (\count($attributes) > 1 && !$allowMultipleAttributes) {
            throw new InvalidArgumentException(\sprintf('Passing more than one Security attribute to "%s()" is not supported.', __METHOD__));
        }

        $accessDecision ??= end($this->accessDecisionStack) ?: new AccessDecision();
        $this->accessDecisionStack[] = $accessDecision;

        $accessDecision->strategy = $this->strategy instanceof \Stringable ? $this->strategy : get_debug_type($this->strategy);

        try {
            return $accessDecision->isGranted = $this->strategy->decide(
                $this->collectResults($token, $attributes, $object, $accessDecision),
                $accessDecision,
            );
        } finally {
            array_pop($this->accessDecisionStack);
        }
    }

    /**
     * @return \Traversable<int, VoterInterface::ACCESS_*>
     */
    private function collectResults(TokenInterface $token, array $attributes, mixed $object, AccessDecision $accessDecision): \Traversable
    {
        foreach ($this->getVoters($attributes, $object) as $voter) {
            $vote = new Vote();
            $result = $voter->vote($token, $object, $attributes, $vote);

            if (!\is_int($result) || !(self::VALID_VOTES[$result] ?? false)) {
                throw new \LogicException(\sprintf('"%s::vote()" must return one of "%s" constants ("ACCESS_GRANTED", "ACCESS_DENIED" or "ACCESS_ABSTAIN"), "%s" returned.', get_debug_type($voter), VoterInterface::class, var_export($result, true)));
            }

            $voter = $voter instanceof TraceableVoter ? $voter->getDecoratedVoter() : $voter;
            $vote->voter = $voter instanceof \Stringable ? $voter : get_debug_type($voter);
            $vote->result = $result;
            $accessDecision->votes[] = $vote;

            yield $result;