diff --git a/composer.json b/composer.json index 2f8dcd0..612a83a 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "guzzlehttp/guzzle": "^8.0@dev", "guzzlehttp/promises": "^3.0@dev", "guzzlehttp/psr7": "^3.0@dev", - "psr/http-client": "^1.0" + "psr/http-client": "^1.0", + "symfony/polyfill-php80": "^1.25" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", diff --git a/src/ServiceClient.php b/src/ServiceClient.php index 8e9c7a3..daeb7d8 100644 --- a/src/ServiceClient.php +++ b/src/ServiceClient.php @@ -157,8 +157,7 @@ public function executeAllAsync(iterable $commands, array $options = []): Promis $promises = function () use ($commands): \Generator { foreach ($commands as $key => $command) { if (!$command instanceof CommandInterface) { - throw new \InvalidArgumentException('The iterator must ' - .'yield instances of '.CommandInterface::class); + throw new \InvalidArgumentException(\sprintf('The iterator must yield instances of %s; got %s', CommandInterface::class, \get_debug_type($command))); } yield $key => $this->executeAsync($command); } @@ -181,7 +180,7 @@ public function executeAllAsync(iterable $commands, array $options = []): Promis public function __call(string $name, array $args) { $args = isset($args[0]) ? $args[0] : []; - if (substr($name, -5) === 'Async') { + if (str_ends_with($name, 'Async')) { $command = $this->getCommand(substr($name, 0, -5), $args); return $this->executeAsync($command); diff --git a/tests/ServiceClientTest.php b/tests/ServiceClientTest.php index a3a7cc9..a8a0c30 100644 --- a/tests/ServiceClientTest.php +++ b/tests/ServiceClientTest.php @@ -274,6 +274,7 @@ public function testMultipleCommandsFailsForNonCommands(): void }; $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('got string'); $client = $this->getServiceClient([]); $client->executeAll($generateCommands());