minor #36095 Quotes in exceptions messages (fabpot)

This PR was squashed before being merged into the 5.0 branch.

Discussion
----------

Quotes in exceptions messages

| Q             | A
| ------------- | ---
| Branch?       | 5.0 <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | n/a

Commits
-------

bc60b9c5e4 Fix quotes in exception messages
42df4f434b Fix quotes in exception messages
This commit is contained in:
Fabien Potencier 2020-03-16 14:11:08 +01:00
commit 4efa287574
13 changed files with 26 additions and 26 deletions

View File

@ -47,7 +47,7 @@ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterf
return;
}
throw new \LogicException(sprintf('The router %s cannot be warmed up because it does not implement %s.', \get_class($router), WarmableInterface::class));
throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', \get_class($router), WarmableInterface::class));
}
/**

View File

@ -41,7 +41,7 @@ abstract class WebTestCase extends KernelTestCase
protected static function createClient(array $options = [], array $server = [])
{
if (static::$booted) {
throw new \LogicException(sprintf('Booting the kernel before calling %s() is not supported, the kernel should only be booted once.', __METHOD__));
throw new \LogicException(sprintf('Booting the kernel before calling "%s()" is not supported, the kernel should only be booted once.', __METHOD__));
}
$kernel = static::bootKernel($options);

View File

@ -40,7 +40,7 @@ class RouterCacheWarmerTest extends TestCase
$containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock);
$routerCacheWarmer = new RouterCacheWarmer($containerMock);
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('cannot be warmed up because it does not implement Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface');
$this->expectExceptionMessage('cannot be warmed up because it does not implement "Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface"');
$routerCacheWarmer->warmUp('/tmp');
}
}

View File

@ -41,11 +41,11 @@ class TestAbstractController extends AbstractController
continue;
}
if (!isset($expected[$id])) {
throw new \UnexpectedValueException(sprintf('Service "%s" is not expected, as declared by %s::getSubscribedServices()', $id, AbstractController::class));
throw new \UnexpectedValueException(sprintf('Service "%s" is not expected, as declared by "%s::getSubscribedServices()".', $id, AbstractController::class));
}
$type = substr($expected[$id], 1);
if (!$container->get($id) instanceof $type) {
throw new \UnexpectedValueException(sprintf('Service "%s" is expected to be an instance of "%s", as declared by %s::getSubscribedServices()', $id, $type, AbstractController::class));
throw new \UnexpectedValueException(sprintf('Service "%s" is expected to be an instance of "%s", as declared by "%s::getSubscribedServices()".', $id, $type, AbstractController::class));
}
}

View File

@ -92,7 +92,7 @@ class MemcachedAdapter extends AbstractAdapter
if (\is_string($servers)) {
$servers = [$servers];
} elseif (!\is_array($servers)) {
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers)));
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, "%s" given.', \gettype($servers)));
}
if (!static::isSupported()) {
throw new CacheException('Memcached >= 2.2.0 is required.');
@ -110,7 +110,7 @@ class MemcachedAdapter extends AbstractAdapter
continue;
}
if (0 !== strpos($dsn, 'memcached:')) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached:".', $dsn));
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s" does not start with "memcached:".', $dsn));
}
$params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
if (!empty($m[2])) {
@ -120,7 +120,7 @@ class MemcachedAdapter extends AbstractAdapter
return 'file:'.($m[1] ?? '');
}, $dsn);
if (false === $params = parse_url($params)) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s.', $dsn));
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s".', $dsn));
}
$query = $hosts = [];
if (isset($params['query'])) {
@ -128,7 +128,7 @@ class MemcachedAdapter extends AbstractAdapter
if (isset($query['host'])) {
if (!\is_array($hosts = $query['host'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s.', $dsn));
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s".', $dsn));
}
foreach ($hosts as $host => $weight) {
if (false === $port = strrpos($host, ':')) {
@ -147,7 +147,7 @@ class MemcachedAdapter extends AbstractAdapter
}
}
if (!isset($params['host']) && !isset($params['path'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s.', $dsn));
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s".', $dsn));
}
if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
$params['weight'] = $m[1];

View File

@ -296,21 +296,21 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
{
if (file_exists($this->file)) {
if (!is_file($this->file)) {
throw new InvalidArgumentException(sprintf('Cache path exists and is not a file: %s.', $this->file));
throw new InvalidArgumentException(sprintf('Cache path exists and is not a file: "%s".', $this->file));
}
if (!is_writable($this->file)) {
throw new InvalidArgumentException(sprintf('Cache file is not writable: %s.', $this->file));
throw new InvalidArgumentException(sprintf('Cache file is not writable: "%s".', $this->file));
}
} else {
$directory = \dirname($this->file);
if (!is_dir($directory) && !@mkdir($directory, 0777, true)) {
throw new InvalidArgumentException(sprintf('Cache directory does not exist and cannot be created: %s.', $directory));
throw new InvalidArgumentException(sprintf('Cache directory does not exist and cannot be created: "%s".', $directory));
}
if (!is_writable($directory)) {
throw new InvalidArgumentException(sprintf('Cache directory is not writable: %s.', $directory));
throw new InvalidArgumentException(sprintf('Cache directory is not writable: "%s".', $directory));
}
}
@ -336,7 +336,7 @@ EOF;
try {
$value = VarExporter::export($value, $isStaticValue);
} catch (\Exception $e) {
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e);
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e);
}
} elseif (\is_string($value)) {
// Wrap "N;" in a closure to not confuse it with an encoded `null`
@ -345,7 +345,7 @@ EOF;
}
$value = var_export($value, true);
} elseif (!is_scalar($value)) {
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value)));
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \gettype($value)));
} else {
$value = var_export($value, true);
}

View File

@ -226,7 +226,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
try {
$value = VarExporter::export($value, $isStaticValue);
} catch (\Exception $e) {
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e);
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e);
}
} elseif (\is_string($value)) {
// Wrap "N;" in a closure to not confuse it with an encoded `null`
@ -235,7 +235,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
}
$value = var_export($value, true);
} elseif (!is_scalar($value)) {
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value)));
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \gettype($value)));
} else {
$value = var_export($value, true);
}

View File

@ -255,7 +255,7 @@ class Command
$statusCode = $this->execute($input, $output);
if (!\is_int($statusCode)) {
throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, %s returned.', static::class, \gettype($statusCode)));
throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, \gettype($statusCode)));
}
}

View File

@ -57,7 +57,7 @@ abstract class FileLoader extends BaseFileLoader
if ($ignoreNotFound = 'not_found' === $ignoreErrors) {
$args[2] = false;
} elseif (!\is_bool($ignoreErrors)) {
throw new \TypeError(sprintf('Invalid argument $ignoreErrors provided to %s::import(): boolean or "not_found" expected, %s given.', static::class, \gettype($ignoreErrors)));
throw new \TypeError(sprintf('Invalid argument $ignoreErrors provided to "%s::import()": boolean or "not_found" expected, "%s" given.', static::class, \gettype($ignoreErrors)));
}
try {

View File

@ -112,7 +112,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
public function testResolveEnvRequiresStrings()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
$this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, integer given.');
$this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, "integer" given.');
$bag = new EnvPlaceholderParameterBag();
$bag->get('env(INT_VAR)');
@ -154,7 +154,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
public function testResolveThrowsOnBadDefaultValue()
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
$this->expectExceptionMessage('The default value of env parameter "ARRAY_VAR" must be a string or null, array given.');
$this->expectExceptionMessage('The default value of env parameter "ARRAY_VAR" must be a string or null, "array" given.');
$bag = new EnvPlaceholderParameterBag();
$bag->get('env(ARRAY_VAR)');
$bag->set('env(ARRAY_VAR)', []);

View File

@ -640,7 +640,7 @@ class Filesystem
public function dumpFile(string $filename, $content)
{
if (\is_array($content)) {
throw new \TypeError(sprintf('Argument 2 passed to %s() must be string or resource, array given.', __METHOD__));
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
}
$dir = \dirname($filename);
@ -676,7 +676,7 @@ class Filesystem
public function appendToFile(string $filename, $content)
{
if (\is_array($content)) {
throw new \TypeError(sprintf('Argument 2 passed to %s() must be string or resource, array given.', __METHOD__));
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
}
$dir = \dirname($filename);

View File

@ -309,7 +309,7 @@ abstract class AbstractUnicodeString extends AbstractString
if (\is_array($to) || $to instanceof \Closure) {
if (!\is_callable($to)) {
throw new \TypeError(sprintf('Argument 2 passed to %s::replaceMatches() must be callable, array given.', static::class));
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
}
$replace = 'preg_replace_callback';

View File

@ -271,7 +271,7 @@ class ByteString extends AbstractString
if (\is_array($to)) {
if (!\is_callable($to)) {
throw new \TypeError(sprintf('Argument 2 passed to %s::replaceMatches() must be callable, array given.', static::class));
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
}
$replace = 'preg_replace_callback';