Repository: symfony/symfony
File: src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php (PHP)

Code before:

    public function ack(\AMQPEnvelope $message, string $queueName): bool
    {
        return $this->queue($queueName)->ack($message->getDeliveryTag()) ?? true;
    }

    public function nack(\AMQPEnvelope $message, string $queueName, int $flags = \AMQP_NOPARAM): bool
    {
        return $this->queue($queueName)->nack($message->getDeliveryTag(), $flags) ?? true;
    }

    public function setup(): void
    {
        $this->setupExchangeAndQueues();
        $this->setupDelayExchange();
    }

    private function setupExchangeAndQueues(): void
    {
        $exchange = $this->exchange();
        if ('' !== $this->exchangeOptions['name']) {
            $exchange->declareExchange();
        }

        foreach ($this->exchangeOptions['bindings'] ?? [] as $exchangeName => $exchangeConfig) {
            if (!\is_array($exchangeConfig['binding_keys'] ?? false) || 0 === \count($exchangeConfig['binding_keys'])) {
                throw new InvalidArgumentException(\sprintf('The "binding_keys" option must be set to a non-empty array for exchange "%s".', $exchangeName));
            }
            foreach ($exchangeConfig['binding_keys'] as $bindingKey) {
                $this->exchange()->bind($exchangeName, $bindingKey, $exchangeConfig['binding_arguments'] ?? []);
            }
        }

        foreach ($this->queuesOptions as $queueName => $queueConfig) {
            $this->queue($queueName)->declareQueue();
            if ('' !== $this->exchangeOptions['name']) {
                foreach ($queueConfig['binding_keys'] ?? [null] as $bindingKey) {
                    $this->queue($queueName)->bind($this->exchangeOptions['name'], $bindingKey, $queueConfig['binding_arguments'] ?? []);
                }
            }
        }
        $this->autoSetupExchange = false;
    }

    private function setupDelayExchange(): void
    {
        $this->getDelayExchange()->declareExchange();
        $this->autoSetupDelayExchange = false;
    }

    /**

Review comment (suggestion):
```suggestion
            if (!\is_array($exchangeConfig['binding_keys'] ?? false) || !$exchangeConfig['binding_keys']) {
```

Code after:

    public function ack(\AMQPEnvelope $message, string $queueName): bool
    {
        return $this->queue($queueName)->ack($message->getDeliveryTag()) ?? true;
    }

    public function nack(\AMQPEnvelope $message, string $queueName, int $flags = \AMQP_NOPARAM): bool
    {
        return $this->queue($queueName)->nack($message->getDeliveryTag(), $flags) ?? true;
    }

    public function setup(): void
    {
        $this->setupExchangeAndQueues();
        $this->setupDelayExchange();
    }

    private function setupExchangeAndQueues(): void
    {
        $exchange = $this->exchange();
        if ('' !== $this->exchangeOptions['name']) {
            $exchange->declareExchange();
        }

        foreach ($this->exchangeOptions['bindings'] ?? [] as $exchangeName => $exchangeConfig) {
            if (!\is_array($exchangeConfig['binding_keys'] ?? false) || !$exchangeConfig['binding_keys']) {
                throw new InvalidArgumentException(\sprintf('The "binding_keys" option must be set to a non-empty array for exchange "%s".', $exchangeName));
            }
            foreach ($exchangeConfig['binding_keys'] as $bindingKey) {
                $this->exchange()->bind($exchangeName, $bindingKey, $exchangeConfig['binding_arguments'] ?? []);
            }
        }

        foreach ($this->queuesOptions as $queueName => $queueConfig) {
            $this->queue($queueName)->declareQueue();
            if ('' !== $this->exchangeOptions['name']) {
                foreach ($queueConfig['binding_keys'] ?? [null] as $bindingKey) {
                    $this->queue($queueName)->bind($this->exchangeOptions['name'], $bindingKey, $queueConfig['binding_arguments'] ?? []);
                }
            }
        }
        $this->autoSetupExchange = false;
    }

    private function setupDelayExchange(): void
    {
        $this->getDelayExchange()->declareExchange();
        $this->autoSetupDelayExchange = false;
    }

    /**