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 messages42df4f434b
Fix quotes in exception messages
This commit is contained in:
commit
4efa287574
@ -47,7 +47,7 @@ class RouterCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterf
|
|||||||
return;
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,7 @@ abstract class WebTestCase extends KernelTestCase
|
|||||||
protected static function createClient(array $options = [], array $server = [])
|
protected static function createClient(array $options = [], array $server = [])
|
||||||
{
|
{
|
||||||
if (static::$booted) {
|
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);
|
$kernel = static::bootKernel($options);
|
||||||
|
@ -40,7 +40,7 @@ class RouterCacheWarmerTest extends TestCase
|
|||||||
$containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock);
|
$containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock);
|
||||||
$routerCacheWarmer = new RouterCacheWarmer($containerMock);
|
$routerCacheWarmer = new RouterCacheWarmer($containerMock);
|
||||||
$this->expectException(\LogicException::class);
|
$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');
|
$routerCacheWarmer->warmUp('/tmp');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,11 @@ class TestAbstractController extends AbstractController
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!isset($expected[$id])) {
|
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);
|
$type = substr($expected[$id], 1);
|
||||||
if (!$container->get($id) instanceof $type) {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class MemcachedAdapter extends AbstractAdapter
|
|||||||
if (\is_string($servers)) {
|
if (\is_string($servers)) {
|
||||||
$servers = [$servers];
|
$servers = [$servers];
|
||||||
} elseif (!\is_array($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()) {
|
if (!static::isSupported()) {
|
||||||
throw new CacheException('Memcached >= 2.2.0 is required.');
|
throw new CacheException('Memcached >= 2.2.0 is required.');
|
||||||
@ -110,7 +110,7 @@ class MemcachedAdapter extends AbstractAdapter
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (0 !== strpos($dsn, 'memcached:')) {
|
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) {
|
$params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
|
||||||
if (!empty($m[2])) {
|
if (!empty($m[2])) {
|
||||||
@ -120,7 +120,7 @@ class MemcachedAdapter extends AbstractAdapter
|
|||||||
return 'file:'.($m[1] ?? '');
|
return 'file:'.($m[1] ?? '');
|
||||||
}, $dsn);
|
}, $dsn);
|
||||||
if (false === $params = parse_url($params)) {
|
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 = [];
|
$query = $hosts = [];
|
||||||
if (isset($params['query'])) {
|
if (isset($params['query'])) {
|
||||||
@ -128,7 +128,7 @@ class MemcachedAdapter extends AbstractAdapter
|
|||||||
|
|
||||||
if (isset($query['host'])) {
|
if (isset($query['host'])) {
|
||||||
if (!\is_array($hosts = $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) {
|
foreach ($hosts as $host => $weight) {
|
||||||
if (false === $port = strrpos($host, ':')) {
|
if (false === $port = strrpos($host, ':')) {
|
||||||
@ -147,7 +147,7 @@ class MemcachedAdapter extends AbstractAdapter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isset($params['host']) && !isset($params['path'])) {
|
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)) {
|
if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
|
||||||
$params['weight'] = $m[1];
|
$params['weight'] = $m[1];
|
||||||
|
@ -296,21 +296,21 @@ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInte
|
|||||||
{
|
{
|
||||||
if (file_exists($this->file)) {
|
if (file_exists($this->file)) {
|
||||||
if (!is_file($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)) {
|
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 {
|
} else {
|
||||||
$directory = \dirname($this->file);
|
$directory = \dirname($this->file);
|
||||||
|
|
||||||
if (!is_dir($directory) && !@mkdir($directory, 0777, true)) {
|
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)) {
|
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 {
|
try {
|
||||||
$value = VarExporter::export($value, $isStaticValue);
|
$value = VarExporter::export($value, $isStaticValue);
|
||||||
} catch (\Exception $e) {
|
} 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)) {
|
} elseif (\is_string($value)) {
|
||||||
// Wrap "N;" in a closure to not confuse it with an encoded `null`
|
// Wrap "N;" in a closure to not confuse it with an encoded `null`
|
||||||
@ -345,7 +345,7 @@ EOF;
|
|||||||
}
|
}
|
||||||
$value = var_export($value, true);
|
$value = var_export($value, true);
|
||||||
} elseif (!is_scalar($value)) {
|
} 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 {
|
} else {
|
||||||
$value = var_export($value, true);
|
$value = var_export($value, true);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
|
|||||||
try {
|
try {
|
||||||
$value = VarExporter::export($value, $isStaticValue);
|
$value = VarExporter::export($value, $isStaticValue);
|
||||||
} catch (\Exception $e) {
|
} 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)) {
|
} elseif (\is_string($value)) {
|
||||||
// Wrap "N;" in a closure to not confuse it with an encoded `null`
|
// 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);
|
$value = var_export($value, true);
|
||||||
} elseif (!is_scalar($value)) {
|
} 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 {
|
} else {
|
||||||
$value = var_export($value, true);
|
$value = var_export($value, true);
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ class Command
|
|||||||
$statusCode = $this->execute($input, $output);
|
$statusCode = $this->execute($input, $output);
|
||||||
|
|
||||||
if (!\is_int($statusCode)) {
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ abstract class FileLoader extends BaseFileLoader
|
|||||||
if ($ignoreNotFound = 'not_found' === $ignoreErrors) {
|
if ($ignoreNotFound = 'not_found' === $ignoreErrors) {
|
||||||
$args[2] = false;
|
$args[2] = false;
|
||||||
} elseif (!\is_bool($ignoreErrors)) {
|
} 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 {
|
try {
|
||||||
|
@ -112,7 +112,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
|||||||
public function testResolveEnvRequiresStrings()
|
public function testResolveEnvRequiresStrings()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
|
$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 = new EnvPlaceholderParameterBag();
|
||||||
$bag->get('env(INT_VAR)');
|
$bag->get('env(INT_VAR)');
|
||||||
@ -154,7 +154,7 @@ class EnvPlaceholderParameterBagTest extends TestCase
|
|||||||
public function testResolveThrowsOnBadDefaultValue()
|
public function testResolveThrowsOnBadDefaultValue()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
|
$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 = new EnvPlaceholderParameterBag();
|
||||||
$bag->get('env(ARRAY_VAR)');
|
$bag->get('env(ARRAY_VAR)');
|
||||||
$bag->set('env(ARRAY_VAR)', []);
|
$bag->set('env(ARRAY_VAR)', []);
|
||||||
|
@ -640,7 +640,7 @@ class Filesystem
|
|||||||
public function dumpFile(string $filename, $content)
|
public function dumpFile(string $filename, $content)
|
||||||
{
|
{
|
||||||
if (\is_array($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);
|
$dir = \dirname($filename);
|
||||||
@ -676,7 +676,7 @@ class Filesystem
|
|||||||
public function appendToFile(string $filename, $content)
|
public function appendToFile(string $filename, $content)
|
||||||
{
|
{
|
||||||
if (\is_array($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);
|
$dir = \dirname($filename);
|
||||||
|
@ -309,7 +309,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
|||||||
|
|
||||||
if (\is_array($to) || $to instanceof \Closure) {
|
if (\is_array($to) || $to instanceof \Closure) {
|
||||||
if (!\is_callable($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';
|
$replace = 'preg_replace_callback';
|
||||||
|
@ -271,7 +271,7 @@ class ByteString extends AbstractString
|
|||||||
|
|
||||||
if (\is_array($to)) {
|
if (\is_array($to)) {
|
||||||
if (!\is_callable($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';
|
$replace = 'preg_replace_callback';
|
||||||
|
Reference in New Issue
Block a user