8000 minor #36095 Quotes in exceptions messages (fabpot) · symfony/symfony@4efa287 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4efa287

Browse files
committed
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 ------- bc60b9c Fix quotes in exception messages 42df4f4 Fix quotes in exception messages
2 parents e903750 + bc60b9c commit 4efa287

File tree

13 files changed

+26
-26
lines changed

13 files changed

+26
-26
lines changed

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function warmUp(string $cacheDir)
4747
return;
4848
}
4949

50-
throw new \LogicException(sprintf('The router %s cannot be warmed up because it does not implement %s.', \get_class($router), WarmableInterface::class));
50+
throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', \get_class($router), WarmableInterface::class));
5151
}
5252

5353
/**

src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected function tearDown(): void
4141 6D40
protected static function createClient(array $options = [], array $server = [])
4242
{
4343
if (static::$booted) {
44-
throw new \LogicException(sprintf('Booting the kernel before calling %s() is not supported, the kernel should only be booted once.', __METHOD__));
44+
throw new \LogicException(sprintf('Booting the kernel before calling "%s()" is not supported, the kernel should only be booted once.', __METHOD__));
4545
}
4646

4747
$kernel = static::bootKernel($options);

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/RouterCacheWarmerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testWarmUpWithoutWarmebleInterface()
4040
$containerMock->expects($this->any())->method('get')->with('router')->willReturn($routerMock);
4141
$routerCacheWarmer = new RouterCacheWarmer($containerMock);
4242
$this->expectException(\LogicException::class);
43-
$this->expectExceptionMessage('cannot be warmed up because it does not implement Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface');
43+
$this->expectExceptionMessage('cannot be warmed up because it does not implement "Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface"');
4444
$routerCacheWarmer->warmUp('/tmp');
4545
}
4646
}

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TestAbstractController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public function setContainer(ContainerInterface $container): ?ContainerInterface
4141
continue;
4242
}
4343
if (!isset($expected[$id])) {
44-
throw new \UnexpectedValueException(sprintf('Service "%s" is not expected, as declared by %s::getSubscribedServices()', $id, AbstractController::class));
44+
throw new \UnexpectedValueException(sprintf('Service "%s" is not expected, as declared by "%s::getSubscribedServices()".', $id, AbstractController::class));
4545
}
4646
$type = substr($expected[$id], 1);
4747
if (!$container->get($id) instanceof $type) {
48-
throw new \UnexpectedValueException(sprintf('Service "%s" is expected to be an instance of "%s", as declared by %s::getSubscribedServices()', $id, $type, AbstractController::class));
48+
throw new \UnexpectedValueException(sprintf('Service "%s" is expected to be an instance of "%s", as declared by "%s::getSubscribedServices()".', $id, $type, AbstractController::class));
4949
}
5050
}
5151

src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php

Lines changed: 5 additions & 5 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static function createConnection($servers, array $options = [])
9292
if (\is_string($servers)) {
9393
$servers = [$servers];
9494
} elseif (!\is_array($servers)) {
95-
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers)));
95+
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, "%s" given.', \gettype($servers)));
9696
}
9797
if (!static::isSupported()) {
9898
throw new CacheException('Memcached >= 2.2.0 is required.');
@@ -110,7 +110,7 @@ public static function createConnection($servers, array $options = [])
110110
continue;
111111
}
112112
if (0 !== strpos($dsn, 'memcached:')) {
113-
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached:".', $dsn));
113+
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s" does not start with "memcached:".', $dsn));
114114
}
115115
$params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
116116
if (!empty($m[2])) {
@@ -120,15 +120,15 @@ public static function createConnection($servers, array $options = [])
120120
return 'file:'.($m[1] ?? '');
121121
}, $dsn);
122122
if (false === $params = parse_url($params)) {
123-
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s.', $dsn));
123+
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s".', $dsn));
124124
}
125125
$query = $hosts = [];
126126
if (isset($params['query'])) {
127127
parse_str($params['query'], $query);
128128

129129
if (isset($query['host'])) {
130130
if (!\is_array($hosts = $query['host'])) {
131-
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s.', $dsn));
131+
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s".', $dsn));
132132
}
133133
foreach ($hosts as $host => $weight) {
134134
if (false === $port = strrpos($host, ':')) {
@@ -147,7 +147,7 @@ public static function createConnection($servers, array $options = [])
147147
}
148148
}
149149
if (!isset($params['host']) && !isset($params['path'])) {
150-
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s.', $dsn));
150+
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s".', $dsn));
151151
}
152152
if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
153153
$params['weight'] = $m[1];

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,21 +296,21 @@ public function warmUp(array $values)
296296
{
297297
if (file_exists($this->file)) {
298298
if (!is_file($this->file)) {
299-
throw new InvalidArgumentException(sprintf('Cache path exists and is not a file: %s.', $this->file));
299+
throw new InvalidArgumentException(sprintf('Cache path exists and is not a file: "%s".', $this->file));
300300
}
301301

302302
if (!is_writable($this->file)) {
303-
throw new InvalidArgumentException(sprintf('Cache file is not writable: %s.', $this->file));
303+
throw new InvalidArgumentException(sprintf('Cache file is not writable: "%s".', $this->file));
304304
}
305305
} else {
306306
$directory = \dirname($this->file);
307307

308308
if (!is_dir($directory) && !@mkdir($directory, 0777, true)) {
309-
throw new InvalidArgumentException(sprintf('Cache directory does not exist and cannot be created: %s.', $directory));
309+
throw new InvalidArgumentException(sprintf('Cache directory does not exist and cannot be created: "%s".', $directory));
310310
}
311311

312312
if (!is_writable($directory)) {
313-
throw new InvalidArgumentException(sprintf('Cache directory is not writable: %s.', $directory));
313+
throw new InvalidArgumentException(sprintf('Cache directory is not writable: "%s".', $directory));
314314
}
315315
}
316316

@@ -336,7 +336,7 @@ public function warmUp(array $values)
336336
try {
337337
$value = VarExporter::export($value, $isStaticValue);
338338
} catch (\Exception $e) {
339-
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e);
339+
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e);
340340
}
341341
} elseif (\is_string($value)) {
342342
// Wrap "N;" in a closure to not confuse it with an encoded `null`
@@ -345,7 +345,7 @@ public function warmUp(array $values)
345345
}
346346
$value = var_export($value, true);
347347
} elseif (!is_scalar($value)) {
348-
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value)));
348+
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \gettype($value)));
349349
} else {
350350
$value = var_export($value, true);
351351
}

src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ protected function doSave(array $values, int $lifetime)
226226
try {
227227
$value = VarExporter::export($value, $isStaticValue);
228228
} catch (\Exception $e) {
229-
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e);
229+
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e);
230230
}
231231
} elseif (\is_string($value)) {
232232
// Wrap "N;" in a closure to not confuse it with an encoded `null`
@@ -235,7 +235,7 @@ protected function doSave(array $values, int $lifetime)
235235
}
236236
$value = var_export($value, true);
237237
} elseif (!is_scalar($value)) {
238-
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value)));
238+
throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable "%s" value.', $key, \gettype($value)));
239239
} else {
240240
$value = var_export($value, true);
241241
}

src/Symfony/Component/Console/Command/Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function run(InputInterface $input, OutputInterface $output)
255255
$statusCode = $this->execute($input, $output);
256256

257257
if (!\is_int($statusCode)) {
258-
throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, %s returned.', static::class, \gettype($statusCode)));
258+
throw new \TypeError 1241 (sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, \gettype($statusCode)));
259259
}
260260
}
261261

src/Symfony/Component/DependencyInjection/Loader/FileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function import($resource, $type = null, $ignoreErrors = false, $sourceRe
5757
if ($ignoreNotFound = 'not_found' === $ignoreErrors) {
5858
$args[2] = false;
5959
} elseif (!\is_bool($ignoreErrors)) {
60-
throw new \TypeError(sprintf('Invalid argument $ignoreErrors provided to %s::import(): boolean or "not_found" expected, %s given.', static::class, \gettype($ignoreErrors)));
60+
throw new \TypeError(sprintf('Invalid argument $ignoreErrors provided to "%s::import()": boolean or "not_found" expected, "%s" given.', static::class, \gettype($ignoreErrors)));
6161
}
6262

6363
try {

src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function testMergeWithDifferentIdentifiersForPlaceholders()
112112
public function testResolveEnvRequiresStrings()
113113
{
114114
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
115-
$this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, integer given.');
115+
$this->expectExceptionMessage('The default value of env parameter "INT_VAR" must be a string or null, "integer" given.');
116116

117117
$bag = new EnvPlaceholderParameterBag();
118118
$bag->get('env(INT_VAR)');
@@ -154,7 +154,7 @@ public function testResolveEnvAllowsNull()
154154
public function testResolveThrowsOnBadDefaultValue()
155155
{
156156
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
157-
$this->expectExceptionMessage('The default value of env parameter "ARRAY_VAR" must be a string or null, array given.');
157+
$this->expectExceptionMessage('The default value of env parameter "ARRAY_VAR" must be a string or null, "array" given.');
158158
$bag = new EnvPlaceholderParameterBag();
159159
$bag->get('env(ARRAY_VAR)');
160160
$bag->set('env(ARRAY_VAR)', []);

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ public function tempnam(string $dir, string $prefix)
640640
public function dumpFile(string $filename, $content)
641641
{
642642
if (\is_array($content)) {
643-
throw new \TypeError(sprintf('Argument 2 passed to %s() must be string or resource, array given.', __METHOD__));
643+
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
644644
}
645645

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

682682
$dir = \dirname($filename);

src/Symfony/Component/String/AbstractUnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function replaceMatches(string $fromRegexp, $to): parent
309309

310310
if (\is_array($to) || $to instanceof \Closure) {
311311
if (!\is_callable($to)) {
312-
throw new \TypeError(sprintf('Argument 2 passed to %s::replaceMatches() must be callable, array given.', static::class));
312+
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
313313
}
314314

315315
$replace = 'preg_replace_callback';

src/Symfony/Component/String/ByteString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function replaceMatches(string $fromRegexp, $to): parent
271271

272272
if (\is_array($to)) {
273273
if (!\is_callable($to)) {
274-
throw new \TypeError(sprintf('Argument 2 passed to %s::replaceMatches() must be callable, array given.', static::class));
274+
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
275275
}
276276

277277
$replace = 'preg_replace_callback';

0 commit comments

Comments
 (0)
0