Repository: symfony/symfony
File: src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php (PHP)

Code before:

            $question = new ChoiceQuestion('Select receivers to consume:', $this->receiverNames, 0);
            $question->setMultiselect(true);

            $input->setArgument('receivers', $io->askQuestion($question));
        }

        if (!$input->getArgument('receivers')) {
            throw new RuntimeException('Please pass at least one receiver.');
        }
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        if ($input->getOption('exclude-receivers') && !$input->getOption('all')) {
            throw new InvalidOptionException('The --exclude-receivers option can only be used with the --all option.');
        }

        $receivers = [];
        $rateLimiters = [];
        $receiverNames = $input->getOption('all') ? $this->receiverNames : $input->getArgument('receivers');

        if ($input->getOption('all') && $excludedTransports = $input->getOption('exclude-receivers')) {
            $receiverNames = array_diff($receiverNames, $excludedTransports);

            if (empty($receiverNames)) {
                throw new RuntimeException('All transports/receivers have been excluded. Please specify at least one to consume from.');
            }
        }

        foreach ($receiverNames as $receiverName) {
            if (!$this->receiverLocator->has($receiverName)) {
                $message = \sprintf('The receiver "%s" does not exist.', $receiverName);
                if ($this->receiverNames) {
                    $message .= \sprintf(' Valid receivers are: %s.', implode(', ', $this->receiverNames));
                }

                throw new RuntimeException($message);
            }

            $receiver = $this->receiverLocator->get($receiverName);
            if ($receiver instanceof SyncTransport) {
                $idx = array_search($receiverName, $receiverNames);
                unset($receiverNames[$idx]);

                continue;
            }

            $receivers[$receiverName] = $receiver;
            if ($this->rateLimiterLocator?->has($receiverName)) {
                $rateLimiters[$receiverName] = $this->rateLimiterLocator->get($receiverName);

Review comment (suggestion):
```suggestion
            if (!$receiverNames) {
```

Code after:

            $question = new ChoiceQuestion('Select receivers to consume:', $this->receiverNames, 0);
            $question->setMultiselect(true);

            $input->setArgument('receivers', $io->askQuestion($question));
        }

        if (!$input->getArgument('receivers')) {
            throw new RuntimeException('Please pass at least one receiver.');
        }
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        if ($input->getOption('exclude-receivers') && !$input->getOption('all')) {
            throw new InvalidOptionException('The "--exclude-receivers" option can only be used with the "--all" option.');
        }

        $receivers = [];
        $rateLimiters = [];
        $receiverNames = $input->getOption('all') ? $this->receiverNames : $input->getArgument('receivers');

        if ($input->getOption('all') && $excludedTransports = $input->getOption('exclude-receivers')) {
            $receiverNames = array_diff($receiverNames, $excludedTransports);

            if (!$receiverNames) {
                throw new RuntimeException('All transports/receivers have been excluded, please specify at least one to consume from.');
            }
        }

        foreach ($receiverNames as $receiverName) {
            if (!$this->receiverLocator->has($receiverName)) {
                $message = \sprintf('The receiver "%s" does not exist.', $receiverName);
                if ($this->receiverNames) {
                    $message .= \sprintf(' Valid receivers are: %s.', implode(', ', $this->receiverNames));
                }

                throw new RuntimeException($message);
            }

            $receiver = $this->receiverLocator->get($receiverName);
            if ($receiver instanceof SyncTransport) {
                $idx = array_search($receiverName, $receiverNames);
                unset($receiverNames[$idx]);

                continue;
            }

            $receivers[$receiverName] = $receiver;
            if ($this->rateLimiterLocator?->has($receiverName)) {
                $rateLimiters[$receiverName] = $this->rateLimiterLocator->get($receiverName);