Fix quotes in exception messages

This commit is contained in:
Fabien Potencier 2020-03-16 14:24:44 +01:00
parent 1866a2a88c
commit 6c37f66f3f
11 changed files with 17 additions and 17 deletions

View File

@ -62,7 +62,7 @@ class CouchbaseBucketAdapter extends AbstractAdapter
if (\is_string($servers)) { if (\is_string($servers)) {
$servers = [$servers]; $servers = [$servers];
} elseif (!\is_array($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()) { if (!static::isSupported()) {
@ -83,7 +83,7 @@ class CouchbaseBucketAdapter extends AbstractAdapter
foreach ($servers as $dsn) { foreach ($servers as $dsn) {
if (0 !== strpos($dsn, 'couchbase:')) { 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); preg_match($dsnPattern, $dsn, $matches);

View File

@ -133,7 +133,7 @@ class AmpBody implements RequestBody, InputStream
} }
if (!\is_string($data)) { 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); return new Success($data);

View File

@ -54,7 +54,7 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, LoggerAwa
public function __construct(HttpClientInterface $client, $subnets = null) public function __construct(HttpClientInterface $client, $subnets = null)
{ {
if (!(\is_array($subnets) || \is_string($subnets) || null === $subnets)) { 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)) { if (!class_exists(IpUtils::class)) {
@ -72,7 +72,7 @@ final class NoPrivateNetworkHttpClient implements HttpClientInterface, LoggerAwa
{ {
$onProgress = $options['on_progress'] ?? null; $onProgress = $options['on_progress'] ?? null;
if (null !== $onProgress && !\is_callable($onProgress)) { 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; $subnets = $this->subnets;

View File

@ -113,7 +113,7 @@ class NoPrivateNetworkHttpClientTest extends TestCase
$customCallback = sprintf('cb_%s', microtime(true)); $customCallback = sprintf('cb_%s', microtime(true));
$this->expectException(InvalidArgumentException::class); $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 = new NoPrivateNetworkHttpClient(new MockHttpClient());
$client->request('GET', $url, ['on_progress' => $customCallback]); $client->request('GET', $url, ['on_progress' => $customCallback]);
@ -122,7 +122,7 @@ class NoPrivateNetworkHttpClientTest extends TestCase
public function testConstructor() public function testConstructor()
{ {
$this->expectException(\TypeError::class); $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); new NoPrivateNetworkHttpClient(new MockHttpClient(), 3);
} }

View File

@ -67,13 +67,13 @@ final class TraceableHttpClient implements HttpClientInterface, ResetInterface,
if ($responses instanceof TraceableResponse) { if ($responses instanceof TraceableResponse) {
$responses = [$responses]; $responses = [$responses];
} elseif (!is_iterable($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) { return $this->client->stream(\Closure::bind(static function () use ($responses) {
foreach ($responses as $k => $r) { foreach ($responses as $k => $r) {
if (!$r instanceof TraceableResponse) { 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; yield $k => $r->response;

View File

@ -249,7 +249,7 @@ class Connection
} }
if (!is_numeric($arguments[$key])) { 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]; $arguments[$key] = (int) $arguments[$key];

View File

@ -28,7 +28,7 @@ class DoctrineTransportFactory implements TransportFactoryInterface
public function __construct($registry) public function __construct($registry)
{ {
if (!$registry instanceof RegistryInterface && !$registry instanceof ConnectionRegistry) { 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; $this->registry = $registry;

View File

@ -28,7 +28,7 @@ class LazyString implements \Stringable, \JsonSerializable
public static function fromCallable($callback, ...$arguments): self public static function fromCallable($callback, ...$arguments): self
{ {
if (!\is_callable($callback) && !(\is_array($callback) && isset($callback[0]) && $callback[0] instanceof \Closure && 2 >= \count($callback))) { 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(); $lazyString = new static();
@ -57,7 +57,7 @@ class LazyString implements \Stringable, \JsonSerializable
public static function fromStringable($value): self public static function fromStringable($value): self
{ {
if (!self::isStringable($value)) { 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)) { if (\is_object($value)) {

View File

@ -27,7 +27,7 @@ abstract class Compound extends Composite
public function __construct($options = null) public function __construct($options = null)
{ {
if (isset($options[$this->getCompositeOption()])) { 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)); $this->constraints = $this->getConstraints($this->normalizeOptions($options));

View File

@ -22,7 +22,7 @@ class CompoundTest extends TestCase
public function testItCannotRedefineConstraintsOption() public function testItCannotRedefineConstraintsOption()
{ {
$this->expectException(ConstraintDefinitionException::class); $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()]]); new EmptyCompound(['constraints' => [new NotBlank()]]);
} }

View File

@ -21,7 +21,7 @@ class SequentiallyTest extends TestCase
public function testRejectNonConstraints() public function testRejectNonConstraints()
{ {
$this->expectException(ConstraintDefinitionException::class); $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([ new Sequentially([
'foo', 'foo',
]); ]);
@ -30,7 +30,7 @@ class SequentiallyTest extends TestCase
public function testRejectValidConstraint() public function testRejectValidConstraint()
{ {
$this->expectException(ConstraintDefinitionException::class); $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 Sequentially([
new Valid(), new Valid(),
]); ]);