From 6c37f66f3f25616b1658b19be9122e93095afb74 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 16 Mar 2020 14:24:44 +0100 Subject: [PATCH] Fix quotes in exception messages --- .../Component/Cache/Adapter/CouchbaseBucketAdapter.php | 4 ++-- src/Symfony/Component/HttpClient/Internal/AmpBody.php | 2 +- .../Component/HttpClient/NoPrivateNetworkHttpClient.php | 4 ++-- .../HttpClient/Tests/NoPrivateNetworkHttpClientTest.php | 4 ++-- src/Symfony/Component/HttpClient/TraceableHttpClient.php | 4 ++-- .../Component/Messenger/Bridge/Amqp/Transport/Connection.php | 2 +- .../Bridge/Doctrine/Transport/DoctrineTransportFactory.php | 2 +- src/Symfony/Component/String/LazyString.php | 4 ++-- src/Symfony/Component/Validator/Constraints/Compound.php | 2 +- .../Component/Validator/Tests/Constraints/CompoundTest.php | 2 +- .../Validator/Tests/Constraints/SequentiallyTest.php | 4 ++-- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php index b3e6f16b19..55390b5343 100644 --- a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php @@ -62,7 +62,7 @@ class CouchbaseBucketAdapter extends AbstractAdapter if (\is_string($servers)) { $servers = [$servers]; } elseif (!\is_array($servers)) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be array or string, %s given.', __METHOD__, \gettype($servers))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be array or string, "%s" given.', __METHOD__, \gettype($servers))); } if (!static::isSupported()) { @@ -83,7 +83,7 @@ class CouchbaseBucketAdapter extends AbstractAdapter foreach ($servers as $dsn) { if (0 !== strpos($dsn, 'couchbase:')) { - throw new InvalidArgumentException(sprintf('Invalid Couchbase DSN: %s does not start with "couchbase:".', $dsn)); + throw new InvalidArgumentException(sprintf('Invalid Couchbase DSN: "%s" does not start with "couchbase:".', $dsn)); } preg_match($dsnPattern, $dsn, $matches); diff --git a/src/Symfony/Component/HttpClient/Internal/AmpBody.php b/src/Symfony/Component/HttpClient/Internal/AmpBody.php index 6f820e932e..5f9f81cac9 100644 --- a/src/Symfony/Component/HttpClient/Internal/AmpBody.php +++ b/src/Symfony/Component/HttpClient/Internal/AmpBody.php @@ -133,7 +133,7 @@ class AmpBody implements RequestBody, InputStream } if (!\is_string($data)) { - throw new TransportException(sprintf('Return value of the "body" option callback must be string, %s returned.', \gettype($data))); + throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', \gettype($data))); } return new Success($data); diff --git a/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php b/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php index c01b906a00..215990beea 100644 --- a/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php +++ b/src/Symfony/Component/HttpClient/NoPrivateNetworkHttpClient.php @@ -54,7 +54,7 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, LoggerAwa public function __construct(HttpClientInterface $client, $subnets = null) { if (!(\is_array($subnets) || \is_string($subnets) || null === $subnets)) { - throw new \TypeError(sprintf('Argument 2 passed to %s() must be of the type array, string or null. %s given.', __METHOD__, \is_object($subnets) ? \get_class($subnets) : \gettype($subnets))); + throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be of the type array, string or null. "%s" given.', __METHOD__, \is_object($subnets) ? \get_class($subnets) : \gettype($subnets))); } if (!class_exists(IpUtils::class)) { @@ -72,7 +72,7 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, LoggerAwa { $onProgress = $options['on_progress'] ?? null; if (null !== $onProgress && !\is_callable($onProgress)) { - throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, %s given.', \is_object($onProgress) ? \get_class($onProgress) : \gettype($onProgress))); + throw new InvalidArgumentException(sprintf('Option "on_progress" must be callable, "%s" given.', \is_object($onProgress) ? \get_class($onProgress) : \gettype($onProgress))); } $subnets = $this->subnets; diff --git a/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php index 926dead34f..77c4461aa1 100755 --- a/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php @@ -113,7 +113,7 @@ class NoPrivateNetworkHttpClientTest extends TestCase $customCallback = sprintf('cb_%s', microtime(true)); $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Option "on_progress" must be callable, string given.'); + $this->expectExceptionMessage('Option "on_progress" must be callable, "string" given.'); $client = new NoPrivateNetworkHttpClient(new MockHttpClient()); $client->request('GET', $url, ['on_progress' => $customCallback]); @@ -122,7 +122,7 @@ class NoPrivateNetworkHttpClientTest extends TestCase public function testConstructor() { $this->expectException(\TypeError::class); - $this->expectExceptionMessage('Argument 2 passed to Symfony\Component\HttpClient\NoPrivateNetworkHttpClient::__construct() must be of the type array, string or null. integer given.'); + $this->expectExceptionMessage('Argument 2 passed to "Symfony\Component\HttpClient\NoPrivateNetworkHttpClient::__construct()" must be of the type array, string or null. "integer" given.'); new NoPrivateNetworkHttpClient(new MockHttpClient(), 3); } diff --git a/src/Symfony/Component/HttpClient/TraceableHttpClient.php b/src/Symfony/Component/HttpClient/TraceableHttpClient.php index 70e22091d6..f609c5bef3 100644 --- a/src/Symfony/Component/HttpClient/TraceableHttpClient.php +++ b/src/Symfony/Component/HttpClient/TraceableHttpClient.php @@ -67,13 +67,13 @@ final class TraceableHttpClient implements HttpClientInterface, ResetInterface, if ($responses instanceof TraceableResponse) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of TraceableResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); + throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } return $this->client->stream(\Closure::bind(static function () use ($responses) { foreach ($responses as $k => $r) { if (!$r instanceof TraceableResponse) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of TraceableResponse objects, %s given.', __METHOD__, \is_object($r) ? \get_class($r) : \gettype($r))); + throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of TraceableResponse objects, "%s" given.', __METHOD__, \is_object($r) ? \get_class($r) : \gettype($r))); } yield $k => $r->response; diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php index 319ad88907..7c49c2b248 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php @@ -249,7 +249,7 @@ class Connection } 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/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php index ed8f9b16f5..efa84f73d1 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/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; diff --git a/src/Symfony/Component/String/LazyString.php b/src/Symfony/Component/String/LazyString.php index 51680e6553..22fd212d58 100644 --- a/src/Symfony/Component/String/LazyString.php +++ b/src/Symfony/Component/String/LazyString.php @@ -28,7 +28,7 @@ class LazyString implements \Stringable, \JsonSerializable public static function fromCallable($callback, ...$arguments): self { if (!\is_callable($callback) && !(\is_array($callback) && isset($callback[0]) && $callback[0] instanceof \Closure && 2 >= \count($callback))) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be a callable or a [Closure, method] lazy-callable, %s given.', __METHOD__, \gettype($callback))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, \gettype($callback))); } $lazyString = new static(); @@ -57,7 +57,7 @@ class LazyString implements \Stringable, \JsonSerializable public static function fromStringable($value): self { if (!self::isStringable($value)) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be a scalar or a stringable object, %s given.', __METHOD__, \is_object($value) ? \get_class($value) : \gettype($value))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a scalar or a stringable object, "%s" given.', __METHOD__, \is_object($value) ? \get_class($value) : \gettype($value))); } if (\is_object($value)) { diff --git a/src/Symfony/Component/Validator/Constraints/Compound.php b/src/Symfony/Component/Validator/Constraints/Compound.php index c6a875d9d4..042da1dd57 100644 --- a/src/Symfony/Component/Validator/Constraints/Compound.php +++ b/src/Symfony/Component/Validator/Constraints/Compound.php @@ -27,7 +27,7 @@ abstract class Compound extends Composite public function __construct($options = null) { if (isset($options[$this->getCompositeOption()])) { - throw new ConstraintDefinitionException(sprintf('You can\'t redefine the "%s" option. Use the %s::getConstraints() method instead.', $this->getCompositeOption(), __CLASS__)); + throw new ConstraintDefinitionException(sprintf('You can\'t redefine the "%s" option. Use the "%s::getConstraints()" method instead.', $this->getCompositeOption(), __CLASS__)); } $this->constraints = $this->getConstraints($this->normalizeOptions($options)); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CompoundTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CompoundTest.php index f9e2284089..5f8f8456ad 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CompoundTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CompoundTest.php @@ -22,7 +22,7 @@ class CompoundTest extends TestCase public function testItCannotRedefineConstraintsOption() { $this->expectException(ConstraintDefinitionException::class); - $this->expectExceptionMessage('You can\'t redefine the "constraints" option. Use the Symfony\Component\Validator\Constraints\Compound::getConstraints() method instead.'); + $this->expectExceptionMessage('You can\'t redefine the "constraints" option. Use the "Symfony\Component\Validator\Constraints\Compound::getConstraints()" method instead.'); new EmptyCompound(['constraints' => [new NotBlank()]]); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/SequentiallyTest.php b/src/Symfony/Component/Validator/Tests/Constraints/SequentiallyTest.php index f699a5abdc..62b23513f1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/SequentiallyTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/SequentiallyTest.php @@ -21,7 +21,7 @@ class SequentiallyTest extends TestCase public function testRejectNonConstraints() { $this->expectException(ConstraintDefinitionException::class); - $this->expectExceptionMessage('The value foo is not an instance of Constraint in constraint Symfony\Component\Validator\Constraints\Sequentially'); + $this->expectExceptionMessage('The value "foo" is not an instance of Constraint in constraint "Symfony\Component\Validator\Constraints\Sequentially"'); new Sequentially([ 'foo', ]); @@ -30,7 +30,7 @@ class SequentiallyTest extends TestCase public function testRejectValidConstraint() { $this->expectException(ConstraintDefinitionException::class); - $this->expectExceptionMessage('The constraint Valid cannot be nested inside constraint Symfony\Component\Validator\Constraints\Sequentially'); + $this->expectExceptionMessage('The constraint Valid cannot be nested inside constraint "Symfony\Component\Validator\Constraints\Sequentially"'); new Sequentially([ new Valid(), ]);