From fe39d1d26a13df1a04ab76658326c3f9b630a8d1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 11:25:47 +0100 Subject: [PATCH] Fix quotes in exception messages --- Command/DebugCommand.php | 4 ++-- DependencyInjection/MessengerPass.php | 2 +- Envelope.php | 2 +- MessageBus.php | 2 +- Middleware/StackMiddleware.php | 2 +- Tests/Command/DebugCommandTest.php | 2 +- Tests/DependencyInjection/MessengerPassTest.php | 2 +- Tests/MessageBusTest.php | 2 +- Transport/AmqpExt/Connection.php | 2 +- Transport/Doctrine/DoctrineTransportFactory.php | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Command/DebugCommand.php b/Command/DebugCommand.php index b86dc4b5..6e9fc617 100644 --- a/Command/DebugCommand.php +++ b/Command/DebugCommand.php @@ -42,7 +42,7 @@ public function __construct(array $mapping) protected function configure() { $this - ->addArgument('bus', InputArgument::OPTIONAL, sprintf('The bus id (one of %s)', implode(', ', array_keys($this->mapping)))) + ->addArgument('bus', InputArgument::OPTIONAL, sprintf('The bus id (one of "%s")', implode('", "', array_keys($this->mapping)))) ->setDescription('Lists messages you can dispatch using the message buses') ->setHelp(<<<'EOF' The %command.name% command displays all messages that can be @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $mapping = $this->mapping; if ($bus = $input->getArgument('bus')) { if (!isset($mapping[$bus])) { - throw new RuntimeException(sprintf('Bus "%s" does not exist. Known buses are %s.', $bus, implode(', ', array_keys($this->mapping)))); + throw new RuntimeException(sprintf('Bus "%s" does not exist. Known buses are "%s".', $bus, implode('", "', array_keys($this->mapping)))); } $mapping = [$bus => $mapping[$bus]]; } diff --git a/DependencyInjection/MessengerPass.php b/DependencyInjection/MessengerPass.php index 4ab31e84..bf62b4c8 100644 --- a/DependencyInjection/MessengerPass.php +++ b/DependencyInjection/MessengerPass.php @@ -75,7 +75,7 @@ private function registerHandlers(ContainerBuilder $container, array $busIds) foreach ($container->findTaggedServiceIds($this->handlerTag, true) as $serviceId => $tags) { foreach ($tags as $tag) { if (isset($tag['bus']) && !\in_array($tag['bus'], $busIds, true)) { - throw new RuntimeException(sprintf('Invalid handler service "%s": bus "%s" specified on the tag "%s" does not exist (known ones are: %s).', $serviceId, $tag['bus'], $this->handlerTag, implode(', ', $busIds))); + throw new RuntimeException(sprintf('Invalid handler service "%s": bus "%s" specified on the tag "%s" does not exist (known ones are: "%s").', $serviceId, $tag['bus'], $this->handlerTag, implode('", "', $busIds))); } $className = $container->getDefinition($serviceId)->getClass(); diff --git a/Envelope.php b/Envelope.php index 833088b6..bf590cbe 100644 --- a/Envelope.php +++ b/Envelope.php @@ -30,7 +30,7 @@ final class Envelope public function __construct($message, array $stamps = []) { if (!\is_object($message)) { - throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object but got %s.', __METHOD__, \gettype($message))); + throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object but got "%s".', __METHOD__, \gettype($message))); } $this->message = $message; diff --git a/MessageBus.php b/MessageBus.php index e860457b..d8146070 100644 --- a/MessageBus.php +++ b/MessageBus.php @@ -62,7 +62,7 @@ public function getIterator(): \Traversable public function dispatch($message, array $stamps = []): Envelope { if (!\is_object($message)) { - throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object, but got %s.', __METHOD__, \gettype($message))); + throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object, but got "%s".', __METHOD__, \gettype($message))); } $envelope = Envelope::wrap($message, $stamps); $middlewareIterator = $this->middlewareAggregate->getIterator(); diff --git a/Middleware/StackMiddleware.php b/Middleware/StackMiddleware.php index 4debfd12..42aef7ee 100644 --- a/Middleware/StackMiddleware.php +++ b/Middleware/StackMiddleware.php @@ -37,7 +37,7 @@ public function __construct($middlewareIterator = null) } elseif ($middlewareIterator instanceof MiddlewareInterface) { $this->stack->stack[] = $middlewareIterator; } elseif (!is_iterable($middlewareIterator)) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be iterable of %s, %s given.', __METHOD__, MiddlewareInterface::class, \is_object($middlewareIterator) ? \get_class($middlewareIterator) : \gettype($middlewareIterator))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be iterable of "%s", "%s" given.', __METHOD__, MiddlewareInterface::class, \is_object($middlewareIterator) ? \get_class($middlewareIterator) : \gettype($middlewareIterator))); } else { $this->stack->iterator = (function () use ($middlewareIterator) { yield from $middlewareIterator; diff --git a/Tests/Command/DebugCommandTest.php b/Tests/Command/DebugCommandTest.php index e637d51d..83b1deff 100644 --- a/Tests/Command/DebugCommandTest.php +++ b/Tests/Command/DebugCommandTest.php @@ -142,7 +142,7 @@ public function testOutputWithoutMessages() public function testExceptionOnUnknownBusArgument() { $this->expectException('Symfony\Component\Console\Exception\RuntimeException'); - $this->expectExceptionMessage('Bus "unknown_bus" does not exist. Known buses are command_bus, query_bus.'); + $this->expectExceptionMessage('Bus "unknown_bus" does not exist. Known buses are "command_bus", "query_bus".'); $command = new DebugCommand(['command_bus' => [], 'query_bus' => []]); $tester = new CommandTester($command); diff --git a/Tests/DependencyInjection/MessengerPassTest.php b/Tests/DependencyInjection/MessengerPassTest.php index e87cbf18..3ec35297 100644 --- a/Tests/DependencyInjection/MessengerPassTest.php +++ b/Tests/DependencyInjection/MessengerPassTest.php @@ -156,7 +156,7 @@ public function testProcessHandlersByBus() public function testProcessTagWithUnknownBus() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler": bus "unknown_bus" specified on the tag "messenger.message_handler" does not exist (known ones are: command_bus).'); + $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler": bus "unknown_bus" specified on the tag "messenger.message_handler" does not exist (known ones are: "command_bus").'); $container = $this->getContainerBuilder($commandBusId = 'command_bus'); $container->register(DummyCommandHandler::class)->addTag('messenger.message_handler', ['bus' => 'unknown_bus']); diff --git a/Tests/MessageBusTest.php b/Tests/MessageBusTest.php index 4e1c2f69..531643bd 100644 --- a/Tests/MessageBusTest.php +++ b/Tests/MessageBusTest.php @@ -35,7 +35,7 @@ public function testItHasTheRightInterface() public function testItDispatchInvalidMessageType() { $this->expectException('TypeError'); - $this->expectExceptionMessage('Invalid argument provided to "Symfony\Component\Messenger\MessageBus::dispatch()": expected object, but got string.'); + $this->expectExceptionMessage('Invalid argument provided to "Symfony\Component\Messenger\MessageBus::dispatch()": expected object, but got "string".'); (new MessageBus())->dispatch('wrong'); } diff --git a/Transport/AmqpExt/Connection.php b/Transport/AmqpExt/Connection.php index 7664c53f..b2799af0 100644 --- a/Transport/AmqpExt/Connection.php +++ b/Transport/AmqpExt/Connection.php @@ -163,7 +163,7 @@ private static function normalizeQueueArguments(array $arguments): array } if (!is_numeric($arguments[$key])) { - throw new InvalidArgumentException(sprintf('Integer expected for queue argument "%s", %s given.', $key, \gettype($arguments[$key]))); + throw new InvalidArgumentException(sprintf('Integer expected for queue argument "%s", "%s" given.', $key, \gettype($arguments[$key]))); } $arguments[$key] = (int) $arguments[$key]; diff --git a/Transport/Doctrine/DoctrineTransportFactory.php b/Transport/Doctrine/DoctrineTransportFactory.php index b4455e04..6c4fa47b 100644 --- a/Transport/Doctrine/DoctrineTransportFactory.php +++ b/Transport/Doctrine/DoctrineTransportFactory.php @@ -28,7 +28,7 @@ class DoctrineTransportFactory implements TransportFactoryInterface public function __construct($registry) { if (!$registry instanceof RegistryInterface && !$registry instanceof ConnectionRegistry) { - throw new \TypeError(sprintf('Expected an instance of %s or %s, but got %s.', RegistryInterface::class, ConnectionRegistry::class, \is_object($registry) ? \get_class($registry) : \gettype($registry))); + throw new \TypeError(sprintf('Expected an instance of "%s" or "%s", but got "%s".', RegistryInterface::class, ConnectionRegistry::class, \is_object($registry) ? \get_class($registry) : \gettype($registry))); } $this->registry = $registry;