diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 23230f7e22..0a50e9d48b 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -429,7 +429,7 @@ abstract class AbstractDoctrineExtension extends Extension } if (null !== $autoMappedManager) { - throw new \LogicException(sprintf('You cannot enable "auto_mapping" on more than one manager at the same time (found in "%s" and %s").', $autoMappedManager, $name)); + throw new \LogicException(sprintf('You cannot enable "auto_mapping" on more than one manager at the same time (found in "%s" and "%s"").', $autoMappedManager, $name)); } $autoMappedManager = $name; diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php index 5933fc43b1..c1bbde27aa 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php @@ -69,7 +69,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface $connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections); foreach ($connections as $con) { if (!isset($this->connections[$con])) { - throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s.', $con, $id, implode(', ', array_keys($this->connections)))); + throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: "%s".', $con, $id, implode('", "', array_keys($this->connections)))); } $this->getEventManagerDef($container, $con)->addMethodCall('addEventSubscriber', [new Reference($id)]); @@ -92,7 +92,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface $connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections); foreach ($connections as $con) { if (!isset($this->connections[$con])) { - throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s.', $con, $id, implode(', ', array_keys($this->connections)))); + throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: "%s".', $con, $id, implode('", "', array_keys($this->connections)))); } $listenerRefs[$con][$id] = new Reference($id); diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php index 259f257760..8f04409ef5 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php @@ -53,7 +53,7 @@ class EntityType extends DoctrineType public function getLoader(ObjectManager $manager, $queryBuilder, string $class) { if (!$queryBuilder instanceof QueryBuilder) { - throw new \TypeError(sprintf('Expected an instance of %s, but got %s.', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder))); + throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder))); } return new ORMQueryBuilderLoader($queryBuilder); @@ -79,7 +79,7 @@ class EntityType extends DoctrineType public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array { if (!$queryBuilder instanceof QueryBuilder) { - throw new \TypeError(sprintf('Expected an instance of %s, but got %s.', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder))); + throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, \is_object($queryBuilder) ? \get_class($queryBuilder) : \gettype($queryBuilder))); } return [ diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php index a663396493..6e4807c58f 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php @@ -50,7 +50,7 @@ class DoctrineFooType extends Type return null; } if (!$value instanceof Foo) { - throw new ConversionException(sprintf('Expected %s, got %s', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', \gettype($value))); + throw new ConversionException(sprintf('Expected "%s", got "%s"', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', \gettype($value))); } return $foo->bar; diff --git a/src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php b/src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php index 458472c6e0..b8b0f7b9e9 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php @@ -52,7 +52,7 @@ class ElasticsearchLogstashHandler extends AbstractHandler public function __construct(string $endpoint = 'http://127.0.0.1:9200', string $index = 'monolog', HttpClientInterface $client = null, int $level = Logger::DEBUG, bool $bubble = true) { if (!interface_exists(HttpClientInterface::class)) { - throw new \LogicException(sprintf('The %s handler needs an HTTP client. Try running "composer require symfony/http-client".', __CLASS__)); + throw new \LogicException(sprintf('The "%s" handler needs an HTTP client. Try running "composer require symfony/http-client".', __CLASS__)); } parent::__construct($level, $bubble); diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php index 5a63746148..2ff31bbda3 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php @@ -88,7 +88,7 @@ class LazyLoadingValueHolderGenerator extends BaseGenerator $newBody = preg_replace('/^(\$this->initializer[a-zA-Z0-9]++) && .*;\n\nreturn (\$this->valueHolder)/', '$1 || $2', $body); if ($body === $newBody) { - throw new \UnexpectedValueException(sprintf('Unexpected lazy-proxy format generated for method %s::__destruct().', $originalClass->name)); + throw new \UnexpectedValueException(sprintf('Unexpected lazy-proxy format generated for method "%s::__destruct()".', $originalClass->name)); } $destructor->setBody($newBody); diff --git a/src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php b/src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php index d149c626a0..5a79062d36 100644 --- a/src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php +++ b/src/Symfony/Bridge/Twig/ErrorRenderer/TwigErrorRenderer.php @@ -35,7 +35,7 @@ class TwigErrorRenderer implements ErrorRendererInterface public function __construct(Environment $twig, HtmlErrorRenderer $fallbackErrorRenderer = null, $debug = false) { if (!\is_bool($debug) && !\is_callable($debug)) { - throw new \TypeError(sprintf('Argument 3 passed to %s() must be a boolean or a callable, %s given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); + throw new \TypeError(sprintf('Argument 3 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); } $this->twig = $twig; diff --git a/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php b/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php index 7329163e17..6d9bffcfcc 100644 --- a/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php +++ b/src/Symfony/Bridge/Twig/Mime/NotificationEmail.php @@ -51,7 +51,7 @@ class NotificationEmail extends TemplatedEmail } if ($missingPackages) { - throw new \LogicException(sprintf('You cannot use "%s" if the %s Twig extension%s not available; try running "composer require %s".', static::class, implode(' and ', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', implode(' ', array_keys($missingPackages)))); + throw new \LogicException(sprintf('You cannot use "%s" if the "%s" Twig extension%s not available; try running "composer require "%s"".', static::class, implode('" and "', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', implode(' ', array_keys($missingPackages)))); } parent::__construct($headers, $body); diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php index fecce2759f..5b4b6e5097 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php @@ -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)); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index f9def3da5b..e934e1bc21 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -171,7 +171,7 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI return (string) $this->resolve($resolved); } - throw new RuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type %s.', $match[1], $value, \gettype($resolved))); + throw new RuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type "%s".', $match[1], $value, \gettype($resolved))); }, $value); return str_replace('%%', '%', $escapedValue); diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php index e393b27ed4..0bbfa08080 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php @@ -34,7 +34,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface public function __construct(string $secretsDir, $decryptionKey = null) { if (null !== $decryptionKey && !\is_string($decryptionKey) && !(\is_object($decryptionKey) && method_exists($decryptionKey, '__toString'))) { - throw new \TypeError(sprintf('Decryption key should be a string or an object that implements the __toString() method, %s given.', \gettype($decryptionKey))); + throw new \TypeError(sprintf('Decryption key should be a string or an object that implements the __toString() method, "%s" given.', \gettype($decryptionKey))); } $this->pathPrefix = rtrim(strtr($secretsDir, '/', \DIRECTORY_SEPARATOR), \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.basename($secretsDir).'.'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php index dd1b77d541..809a85dfdf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php @@ -57,11 +57,11 @@ abstract class KernelTestCase extends TestCase protected static function getKernelClass() { if (!isset($_SERVER['KERNEL_CLASS']) && !isset($_ENV['KERNEL_CLASS'])) { - throw new \LogicException(sprintf('You must set the KERNEL_CLASS environment variable to the fully-qualified class name of your Kernel in phpunit.xml / phpunit.xml.dist or override the %1$s::createKernel() or %1$s::getKernelClass() method.', static::class)); + throw new \LogicException(sprintf('You must set the KERNEL_CLASS environment variable to the fully-qualified class name of your Kernel in phpunit.xml / phpunit.xml.dist or override the "%1$s::createKernel()" or "%1$s::getKernelClass()" method.', static::class)); } if (!class_exists($class = $_ENV['KERNEL_CLASS'] ?? $_SERVER['KERNEL_CLASS'])) { - throw new \RuntimeException(sprintf('Class "%s" doesn\'t exist or cannot be autoloaded. Check that the KERNEL_CLASS value in phpunit.xml matches the fully-qualified class name of your Kernel or override the %s::createKernel() method.', $class, static::class)); + throw new \RuntimeException(sprintf('Class "%s" doesn\'t exist or cannot be autoloaded. Check that the KERNEL_CLASS value in phpunit.xml matches the fully-qualified class name of your Kernel or override the "%s::createKernel()" method.', $class, static::class)); } return $class; diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index 856417c0e2..085eeae94d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -40,7 +40,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); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/RouterCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/RouterCacheWarmerTest.php index 43e8a8123b..9e792eb278 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/RouterCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/RouterCacheWarmerTest.php @@ -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'); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TestAbstractController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TestAbstractController.php index 30480d9f1d..5238aee8ff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TestAbstractController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TestAbstractController.php @@ -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)); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index b9b057da20..f7971cb733 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -390,7 +390,7 @@ class RouterTest extends TestCase public function testExceptionOnNonStringParameter() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type object.'); + $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".'); $routes = new RouteCollection(); $routes->add('foo', new Route('/%object%')); @@ -405,7 +405,7 @@ class RouterTest extends TestCase public function testExceptionOnNonStringParameterWithSfContainer() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type object.'); + $this->expectExceptionMessage('The container parameter "object", used in the route configuration value "/%object%", must be a string or numeric, but it is of type "object".'); $routes = new RouteCollection(); $routes->add('foo', new Route('/%object%')); diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSecurityVotersPass.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSecurityVotersPass.php index 87103c37a3..c3c7b86ab2 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSecurityVotersPass.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSecurityVotersPass.php @@ -52,7 +52,7 @@ class AddSecurityVotersPass implements CompilerPassInterface $class = $container->getParameterBag()->resolveValue($definition->getClass()); if (!is_a($class, VoterInterface::class, true)) { - throw new LogicException(sprintf('%s must implement the %s when used as a voter.', $class, VoterInterface::class)); + throw new LogicException(sprintf('"%s" must implement the "%s" when used as a voter.', $class, VoterInterface::class)); } if ($debug) { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php index 997174080c..ed435f7fa9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSecurityVotersPassTest.php @@ -130,7 +130,7 @@ class AddSecurityVotersPassTest extends TestCase public function testVoterMissingInterface() { $exception = LogicException::class; - $message = 'stdClass must implement the Symfony\Component\Security\Core\Authorization\Voter\VoterInterface when used as a voter.'; + $message = '"stdClass" must implement the "Symfony\Component\Security\Core\Authorization\Voter\VoterInterface" when used as a voter.'; $this->expectException($exception); $this->expectExceptionMessage($message); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 74bf224cfd..12eaa4ba4c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -308,7 +308,7 @@ class TwigExtensionTest extends TestCase $loader = new YamlFileLoader($container, $locator); break; default: - throw new \InvalidArgumentException(sprintf('Unsupported format: %s', $format)); + throw new \InvalidArgumentException(sprintf('Unsupported format: "%s"', $format)); } $loader->load($file.'.'.$format); diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index b713c02878..7a4cf7f8ee 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -134,7 +134,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg return CouchbaseBucketAdapter::createConnection($dsn, $options); } - throw new InvalidArgumentException(sprintf('Unsupported DSN: %s.', $dsn)); + throw new InvalidArgumentException(sprintf('Unsupported DSN: "%s".', $dsn)); } /** diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index 1ac98405a0..1233fc7afc 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -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]; diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 84946f6446..2c337b6259 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -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); } diff --git a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php index 71e52d43d4..013df35ba6 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php @@ -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); } diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index b4cb0eb4ee..d147a95b07 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -130,7 +130,7 @@ final class CacheItem implements ItemInterface throw new InvalidArgumentException('Cache tag length must be greater than zero.'); } if (false !== strpbrk($tag, self::RESERVED_CHARACTERS)) { - throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters %s.', $tag, self::RESERVED_CHARACTERS)); + throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters "%s".', $tag, self::RESERVED_CHARACTERS)); } $this->newMetadata[self::METADATA_TAGS][$tag] = $tag; } @@ -162,7 +162,7 @@ final class CacheItem implements ItemInterface throw new InvalidArgumentException('Cache key length must be greater than zero.'); } if (false !== strpbrk($key, self::RESERVED_CHARACTERS)) { - throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters %s.', $key, self::RESERVED_CHARACTERS)); + throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters "%s".', $key, self::RESERVED_CHARACTERS)); } return $key; diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 1ee96147a6..a7431f4d01 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -56,7 +56,7 @@ trait RedisTrait } if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy && !$redisClient instanceof RedisClusterProxy) { - throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, %s given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient))); + throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient))); } if ($redisClient instanceof \Predis\ClientInterface && $redisClient->getOptions()->exceptions) { @@ -93,11 +93,11 @@ trait RedisTrait } elseif (0 === strpos($dsn, 'rediss:')) { $scheme = 'rediss'; } else { - throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s does not start with "redis:" or "rediss".', $dsn)); + throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s" does not start with "redis:" or "rediss".', $dsn)); } if (!\extension_loaded('redis') && !class_exists(\Predis\Client::class)) { - throw new CacheException(sprintf('Cannot find the "redis" extension nor the "predis/predis" package: %s.', $dsn)); + throw new CacheException(sprintf('Cannot find the "redis" extension nor the "predis/predis" package: "%s".', $dsn)); } $params = preg_replace_callback('#^'.$scheme.':(//)?(?:(?:[^:@]*+:)?([^@]*+)@)?#', function ($m) use (&$auth) { @@ -109,7 +109,7 @@ trait RedisTrait }, $dsn); if (false === $params = parse_url($params)) { - throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s.', $dsn)); + throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s".', $dsn)); } $query = $hosts = []; @@ -119,7 +119,7 @@ trait RedisTrait if (isset($query['host'])) { if (!\is_array($hosts = $query['host'])) { - throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s.', $dsn)); + throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s".', $dsn)); } foreach ($hosts as $host => $parameters) { if (\is_string($parameters)) { @@ -151,11 +151,11 @@ trait RedisTrait } if (!$hosts) { - throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s.', $dsn)); + throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s".', $dsn)); } if (isset($params['redis_sentinel']) && !class_exists(\Predis\Client::class)) { - throw new CacheException(sprintf('Redis Sentinel support requires the "predis/predis" package: %s.', $dsn)); + throw new CacheException(sprintf('Redis Sentinel support requires the "predis/predis" package: "%s".', $dsn)); } $params += $query + $options + self::$defaultConnectionOptions; @@ -174,7 +174,7 @@ trait RedisTrait try { @$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']); } catch (\RedisException $e) { - throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s.', $e->getMessage(), $dsn)); + throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn)); } set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; }); @@ -182,7 +182,7 @@ trait RedisTrait restore_error_handler(); if (!$isConnected) { $error = preg_match('/^Redis::p?connect\(\): (.*)/', $error, $error) ? sprintf(' (%s)', $error[1]) : ''; - throw new InvalidArgumentException(sprintf('Redis connection failed%s: %s.', $error, $dsn)); + throw new InvalidArgumentException(sprintf('Redis connection failed%s: "%s".', $error, $dsn)); } if ((null !== $auth && !$redis->auth($auth)) @@ -190,7 +190,7 @@ trait RedisTrait || ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout'])) ) { $e = preg_replace('/^ERR /', '', $redis->getLastError()); - throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s.', $e, $dsn)); + throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e, $dsn)); } if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) { @@ -215,7 +215,7 @@ trait RedisTrait try { $redis = new $class($hosts, $params); } catch (\RedisClusterException $e) { - throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s.', $e->getMessage(), $dsn)); + throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn)); } if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) { @@ -230,7 +230,7 @@ trait RedisTrait try { $redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']); } catch (\RedisClusterException $e) { - throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s.', $e->getMessage(), $dsn)); + throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn)); } if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) { @@ -250,7 +250,7 @@ trait RedisTrait if ($params['redis_cluster']) { $params['cluster'] = 'redis'; if (isset($params['redis_sentinel'])) { - throw new InvalidArgumentException(sprintf('Cannot use both "redis_cluster" and "redis_sentinel" at the same time: %s.', $dsn)); + throw new InvalidArgumentException(sprintf('Cannot use both "redis_cluster" and "redis_sentinel" at the same time: "%s".', $dsn)); } } elseif (isset($params['redis_sentinel'])) { $params['replication'] = 'sentinel'; diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 9f2c24bb68..36ec517cb6 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -207,7 +207,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface protected function finalizeValue($value) { if (false === $value) { - throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value))); + throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), json_encode($value))); } foreach ($this->children as $name => $child) { diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index 8e18d077d3..cad428f72c 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -175,7 +175,7 @@ class PrototypedArrayNode extends ArrayNode protected function finalizeValue($value) { if (false === $value) { - throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s.', $this->getPath(), json_encode($value))); + throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: "%s".', $this->getPath(), json_encode($value))); } foreach ($value as $k => $v) { diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index 965f940d45..2e82bf0bea 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -68,7 +68,7 @@ class FileLocator implements FileLocatorInterface } if (!$filepaths) { - throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)), 0, null, $notfound); + throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist (in: "%s").', $name, implode('", "', $paths)), 0, null, $notfound); } return $filepaths; diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 866f3e2873..29a9415b81 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -258,7 +258,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))); } } diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php index af88363912..d361b48901 100644 --- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php +++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -77,7 +77,7 @@ class ApplicationDescription public function getCommand(string $name): Command { if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { - throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name)); + throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name)); } return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index ad8a797fef..8fc9f286ec 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -113,7 +113,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface public function getStyle(string $name) { if (!$this->hasStyle($name)) { - throw new InvalidArgumentException(sprintf('Undefined style: %s.', $name)); + throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name)); } return $this->styles[strtolower($name)]; diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index 5aefa3d7b9..8fc1d74296 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -606,7 +606,7 @@ class Table $unmergedRows = []; foreach ($rows[$line] as $column => $cell) { if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) { - throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing __toString, %s given.', \gettype($cell))); + throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', \gettype($cell))); } if ($cell instanceof TableCell && $cell->getRowspan() > 1) { $nbLines = $cell->getRowspan() - 1; diff --git a/src/Symfony/Component/Console/Question/ChoiceQuestion.php b/src/Symfony/Component/Console/Question/ChoiceQuestion.php index 020b733f13..24e6604946 100644 --- a/src/Symfony/Component/Console/Question/ChoiceQuestion.php +++ b/src/Symfony/Component/Console/Question/ChoiceQuestion.php @@ -150,7 +150,7 @@ class ChoiceQuestion extends Question } if (\count($results) > 1) { - throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results))); + throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of "%s".', implode('" or "', $results))); } $result = array_search($value, $choices); diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 35c1d3482d..8acc911677 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -630,7 +630,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest public function testAmbiguousChoiceFromChoicelist() { $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage('The provided answer is ambiguous. Value should be one of env_2 or env_3.'); + $this->expectExceptionMessage('The provided answer is ambiguous. Value should be one of "env_2" or "env_3".'); $possibleChoices = [ 'env_1' => 'My first environment', 'env_2' => 'My environment', diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index c4acc3fbff..daa09feed0 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -770,7 +770,7 @@ TABLE; public function testThrowsWhenTheCellInAnArray() { $this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('A cell must be a TableCell, a scalar or an object implementing __toString, array given.'); + $this->expectExceptionMessage('A cell must be a TableCell, a scalar or an object implementing "__toString()", "array" given.'); $table = new Table($output = $this->getOutputStream()); $table ->setHeaders(['ISBN', 'Title', 'Author', 'Price']) diff --git a/src/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php b/src/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php index 38c8dc1548..6ce83cdc9b 100644 --- a/src/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php +++ b/src/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php @@ -55,7 +55,7 @@ class StringHandler implements HandlerInterface $match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote)); if (!$match) { - throw new InternalErrorException(sprintf('Should have found at least an empty match at %s.', $reader->getPosition())); + throw new InternalErrorException(sprintf('Should have found at least an empty match at %d.', $reader->getPosition())); } // check unclosed strings diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php index 570ea1579a..2b79aaafc9 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php @@ -53,7 +53,7 @@ class FunctionExtension extends AbstractExtension try { list($a, $b) = Parser::parseSeries($function->getArguments()); } catch (SyntaxErrorException $e) { - throw new ExpressionErrorException(sprintf('Invalid series: %s.', implode(', ', $function->getArguments())), 0, $e); + throw new ExpressionErrorException(sprintf('Invalid series: "%s".', implode('", "', $function->getArguments())), 0, $e); } $xpath->addStarPrefix(); diff --git a/src/Symfony/Component/DependencyInjection/Argument/ReferenceSetArgumentTrait.php b/src/Symfony/Component/DependencyInjection/Argument/ReferenceSetArgumentTrait.php index 6f8d5d97e5..e3946ab394 100644 --- a/src/Symfony/Component/DependencyInjection/Argument/ReferenceSetArgumentTrait.php +++ b/src/Symfony/Component/DependencyInjection/Argument/ReferenceSetArgumentTrait.php @@ -45,7 +45,7 @@ trait ReferenceSetArgumentTrait { foreach ($values as $k => $v) { if (null !== $v && !$v instanceof Reference) { - throw new InvalidArgumentException(sprintf('A %s must hold only Reference instances, "%s" given.', __CLASS__, \is_object($v) ? \get_class($v) : \gettype($v))); + throw new InvalidArgumentException(sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, \is_object($v) ? \get_class($v) : \gettype($v))); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php index 0d00d52dca..a992d26ae1 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php @@ -209,7 +209,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface $arg = $this->processValue(new Reference($id)); $this->inExpression = false; if (!$arg instanceof Reference) { - throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, %s returned for service("%s").', static::class, \is_object($arg) ? \get_class($arg) : \gettype($arg), $id)); + throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, \is_object($arg) ? \get_class($arg) : \gettype($arg), $id)); } $arg = sprintf('"%s"', $arg); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php b/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php index 121b1dc716..c24d5976b3 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php @@ -125,7 +125,7 @@ class PriorityTaggedServiceUtil $defaultIndex = $rm->invoke(null); if (!\is_string($defaultIndex)) { - throw new InvalidArgumentException(sprintf('Either method "%s::%s()" should return a string (got %s) or tag "%s" on service "%s" is missing attribute "%s".', $class, $defaultIndexMethod, \gettype($defaultIndex), $tagName, $serviceId, $indexAttribute)); + throw new InvalidArgumentException(sprintf('Either method "%s::%s()" should return a string (got "%s") or tag "%s" on service "%s" is missing attribute "%s".', $class, $defaultIndexMethod, \gettype($defaultIndex), $tagName, $serviceId, $indexAttribute)); } return $defaultIndex; @@ -154,7 +154,7 @@ class PriorityTaggedServiceUtil $defaultPriority = $rm->invoke(null); if (!\is_int($defaultPriority)) { - throw new InvalidArgumentException(sprintf('Method "%s::%s()" should return an integer (got %s) or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, \gettype($defaultPriority), $tagName, $serviceId)); + throw new InvalidArgumentException(sprintf('Method "%s::%s()" should return an integer (got "%s") or tag "%s" on service "%s" is missing attribute "priority".', $class, $defaultPriorityMethod, \gettype($defaultPriority), $tagName, $serviceId)); } return $defaultPriority; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php index 761aa314fa..4e9ebb3933 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php @@ -134,7 +134,7 @@ class ResolveBindingsPass extends AbstractRecursivePass } if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) { - throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, %s, %s, %s or ServiceLocatorArgument, %s given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, \gettype($bindingValue))); + throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, "%s", "%s", "%s" or ServiceLocatorArgument, "%s" given.', $key, $this->currentId, Reference::class, Definition::class, TaggedIteratorArgument::class, \gettype($bindingValue))); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php index 8fa3868c5a..2c4abec518 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php @@ -76,7 +76,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass } if (null !== $argument && !$argument instanceof Reference && !$argument instanceof Definition) { - throw new InvalidArgumentException(sprintf('Invalid service "%s": the value of argument "%s" of method "%s()" must be null, an instance of %s or an instance of %s, %s given.', $this->currentId, $key, $class !== $this->currentId ? $class.'::'.$method : $method, Reference::class, Definition::class, \gettype($argument))); + throw new InvalidArgumentException(sprintf('Invalid service "%s": the value of argument "%s" of method "%s()" must be null, an instance of "%s" or an instance of "%s", "%s" given.', $this->currentId, $key, $class !== $this->currentId ? $class.'::'.$method : $method, Reference::class, Definition::class, \gettype($argument))); } $typeFound = false; diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index bc57201d3c..05750bb910 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -1390,7 +1390,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface $completed = true; } else { if (!\is_string($resolved) && !is_numeric($resolved)) { - throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "env(%s)" of type %s inside string value "%s".', $env, \gettype($resolved), $this->resolveEnvPlaceholders($value))); + throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "env(%s)" of type "%s" inside string value "%s".', $env, \gettype($resolved), $this->resolveEnvPlaceholders($value))); } $value = str_ireplace($placeholder, $resolved, $value); } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 9ef6422623..82cedc381c 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1377,7 +1377,7 @@ EOF; foreach ($this->container->getParameterBag()->all() as $key => $value) { if ($key !== $resolvedKey = $this->container->resolveEnvPlaceholders($key)) { - throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: %s.', $resolvedKey)); + throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: "%s".', $resolvedKey)); } $export = $this->exportParameters([$value]); $export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2); diff --git a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php index 31f92c088a..f54c2603dd 100644 --- a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php +++ b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php @@ -184,7 +184,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface } if (!is_scalar($env)) { - throw new RuntimeException(sprintf('Non-scalar env var "%s" cannot be cast to %s.', $name, $prefix)); + throw new RuntimeException(sprintf('Non-scalar env var "%s" cannot be cast to "%s".', $name, $prefix)); } if ('string' === $prefix) { @@ -231,7 +231,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface } if (null !== $env && !\is_array($env)) { - throw new RuntimeException(sprintf('Invalid JSON env var "%s": array or null expected, %s given.', $name, \gettype($env))); + throw new RuntimeException(sprintf('Invalid JSON env var "%s": array or null expected, "%s" given.', $name, \gettype($env))); } return $env; @@ -244,7 +244,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface throw new RuntimeException(sprintf('Invalid URL in env var "%s".', $name)); } if (!isset($parsedEnv['scheme'], $parsedEnv['host'])) { - throw new RuntimeException(sprintf('Invalid URL env var "%s": schema and host expected, %s given.', $name, $env)); + throw new RuntimeException(sprintf('Invalid URL env var "%s": schema and host expected, "%s" given.', $name, $env)); } $parsedEnv += [ 'port' => null, diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php index dbc8e1cc53..6f9323f1c2 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php @@ -36,7 +36,7 @@ abstract class AbstractConfigurator return $this->{'set'.$method}(...$args); } - throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s().', static::class, $method)); + throw new \BadMethodCallException(sprintf('Call to undefined method "%s::%s()".', static::class, $method)); } /** diff --git a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php index 30e030b738..66aadc1cf4 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php +++ b/src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php @@ -48,7 +48,7 @@ class ContainerConfigurator extends AbstractConfigurator { if (!$this->container->hasExtension($namespace)) { $extensions = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); - throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s.', $namespace, $this->file, $namespace, $extensions ? sprintf('"%s"', implode('", "', $extensions)) : 'none')); + throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $this->file, $namespace, $extensions ? implode('", "', $extensions) : 'none')); } $this->container->loadFromExtension($namespace, static::processValue($config)); diff --git a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php index 7b9581e82e..c8b1ce9805 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -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 { @@ -90,10 +90,10 @@ abstract class FileLoader extends BaseFileLoader public function registerClasses(Definition $prototype, $namespace, $resource, $exclude = null) { if ('\\' !== substr($namespace, -1)) { - throw new InvalidArgumentException(sprintf('Namespace prefix must end with a "\\": %s.', $namespace)); + throw new InvalidArgumentException(sprintf('Namespace prefix must end with a "\\": "%s".', $namespace)); } if (!preg_match('/^(?:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+\\\\)++$/', $namespace)) { - throw new InvalidArgumentException(sprintf('Namespace is not a valid PSR-4 prefix: %s.', $namespace)); + throw new InvalidArgumentException(sprintf('Namespace is not a valid PSR-4 prefix: "%s".', $namespace)); } $classes = $this->findClasses($namespace, $resource, (array) $exclude); diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 8025c9839f..8cd315c5d7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -172,7 +172,7 @@ class XmlFileLoader extends FileLoader foreach ($defaults['tags'] as $tag) { if ('' === $tag->getAttribute('name')) { - throw new InvalidArgumentException(sprintf('The tag name for tag "" in %s must be a non-empty string.', $file)); + throw new InvalidArgumentException(sprintf('The tag name for tag "" in "%s" must be a non-empty string.', $file)); } } @@ -345,7 +345,7 @@ class XmlFileLoader extends FileLoader } if ('' === $tag->getAttribute('name')) { - throw new InvalidArgumentException(sprintf('The tag name for service "%s" in %s must be a non-empty string.', (string) $service->getAttribute('id'), $file)); + throw new InvalidArgumentException(sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', (string) $service->getAttribute('id'), $file)); } $definition->addTag($tag->getAttribute('name'), $parameters); @@ -396,7 +396,7 @@ class XmlFileLoader extends FileLoader try { $dom = XmlUtils::loadFile($file, [$this, 'validateSchema']); } catch (\InvalidArgumentException $e) { - throw new InvalidArgumentException(sprintf('Unable to parse file "%s": %s.', $file, $e->getMessage()), $e->getCode(), $e); + throw new InvalidArgumentException(sprintf('Unable to parse file "%s": "%s".', $file, $e->getMessage()), $e->getCode(), $e); } $this->validateExtensions($dom, $file); @@ -438,7 +438,7 @@ class XmlFileLoader extends FileLoader // anonymous services "in the wild" if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) { foreach ($nodes as $node) { - throw new InvalidArgumentException(sprintf('Top-level services must have "id" attribute, none found in %s at line %d.', $file, $node->getLineNo())); + throw new InvalidArgumentException(sprintf('Top-level services must have "id" attribute, none found in "%s" at line %d.', $file, $node->getLineNo())); } } @@ -683,7 +683,7 @@ EOF // can it be handled by an extension? if (!$this->container->hasExtension($node->namespaceURI)) { $extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getNamespace(); }, $this->container->getExtensions())); - throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s.', $node->tagName, $file, $node->namespaceURI, $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none')); + throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $node->tagName, $file, $node->namespaceURI, $extensionNamespaces ? implode('", "', $extensionNamespaces) : 'none')); } } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 6152fac720..459aa71107 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -135,7 +135,7 @@ class YamlFileLoader extends FileLoader // parameters if (isset($content['parameters'])) { if (!\is_array($content['parameters'])) { - throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $path)); + throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in "%s". Check your YAML syntax.', $path)); } foreach ($content['parameters'] as $key => $value) { @@ -181,7 +181,7 @@ class YamlFileLoader extends FileLoader } if (!\is_array($content['imports'])) { - throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file)); + throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in "%s". Check your YAML syntax.', $file)); } $defaultDirectory = \dirname($file); @@ -190,7 +190,7 @@ class YamlFileLoader extends FileLoader $import = ['resource' => $import]; } if (!isset($import['resource'])) { - throw new InvalidArgumentException(sprintf('An import should provide a resource in %s. Check your YAML syntax.', $file)); + throw new InvalidArgumentException(sprintf('An import should provide a resource in "%s". Check your YAML syntax.', $file)); } $this->setCurrentDir($defaultDirectory); @@ -205,7 +205,7 @@ class YamlFileLoader extends FileLoader } if (!\is_array($content['services'])) { - throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file)); + throw new InvalidArgumentException(sprintf('The "services" key should contain an array in "%s". Check your YAML syntax.', $file)); } if (\array_key_exists('_instanceof', $content['services'])) { @@ -219,10 +219,10 @@ class YamlFileLoader extends FileLoader $this->isLoadingInstanceof = true; foreach ($instanceof as $id => $service) { if (!$service || !\is_array($service)) { - throw new InvalidArgumentException(sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in %s. Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in "%s". Check your YAML syntax.', $id, $file)); } if (\is_string($service) && 0 === strpos($service, '@')) { - throw new InvalidArgumentException(sprintf('Type definition "%s" cannot be an alias within "_instanceof" in %s. Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id, $file)); } $this->parseDefinition($id, $service, $file, []); } @@ -258,7 +258,7 @@ class YamlFileLoader extends FileLoader if (isset($defaults['tags'])) { if (!\is_array($tags = $defaults['tags'])) { - throw new InvalidArgumentException(sprintf('Parameter "tags" in "_defaults" must be an array in %s. Check your YAML syntax.', $file)); + throw new InvalidArgumentException(sprintf('Parameter "tags" in "_defaults" must be an array in "%s". Check your YAML syntax.', $file)); } foreach ($tags as $tag) { @@ -267,18 +267,18 @@ class YamlFileLoader extends FileLoader } if (!isset($tag['name'])) { - throw new InvalidArgumentException(sprintf('A "tags" entry in "_defaults" is missing a "name" key in %s.', $file)); + throw new InvalidArgumentException(sprintf('A "tags" entry in "_defaults" is missing a "name" key in "%s".', $file)); } $name = $tag['name']; unset($tag['name']); if (!\is_string($name) || '' === $name) { - throw new InvalidArgumentException(sprintf('The tag name in "_defaults" must be a non-empty string in %s.', $file)); + throw new InvalidArgumentException(sprintf('The tag name in "_defaults" must be a non-empty string in "%s".', $file)); } foreach ($tag as $attribute => $value) { if (!is_scalar($value) && null !== $value) { - throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in %s. Check your YAML syntax.', $name, $attribute, $file)); + throw new InvalidArgumentException(sprintf('Tag "%s", attribute "%s" in "_defaults" must be of a scalar-type in "%s". Check your YAML syntax.', $name, $attribute, $file)); } } } @@ -286,7 +286,7 @@ class YamlFileLoader extends FileLoader if (isset($defaults['bind'])) { if (!\is_array($defaults['bind'])) { - throw new InvalidArgumentException(sprintf('Parameter "bind" in "_defaults" must be an array in %s. Check your YAML syntax.', $file)); + throw new InvalidArgumentException(sprintf('Parameter "bind" in "_defaults" must be an array in "%s". Check your YAML syntax.', $file)); } foreach ($this->resolveServices($defaults['bind'], $file) as $argument => $value) { @@ -339,7 +339,7 @@ class YamlFileLoader extends FileLoader } if (!\is_array($service)) { - throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but %s found for service "%s" in %s. Check your YAML syntax.', \gettype($service), $id, $file)); + throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but "%s" found for service "%s" in "%s". Check your YAML syntax.', \gettype($service), $id, $file)); } $this->checkDefinition($id, $service, $file); @@ -460,16 +460,16 @@ class YamlFileLoader extends FileLoader if (isset($service['calls'])) { if (!\is_array($service['calls'])) { - throw new InvalidArgumentException(sprintf('Parameter "calls" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(sprintf('Parameter "calls" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } foreach ($service['calls'] as $k => $call) { if (!\is_array($call) && (!\is_string($k) || !$call instanceof TaggedValue)) { - throw new InvalidArgumentException(sprintf('Invalid method call for service "%s": expected map or array, %s given in %s.', $id, $call instanceof TaggedValue ? '!'.$call->getTag() : \gettype($call), $file)); + throw new InvalidArgumentException(sprintf('Invalid method call for service "%s": expected map or array, "%s" given in "%s".', $id, $call instanceof TaggedValue ? '!'.$call->getTag() : \gettype($call), $file)); } if (\is_string($k)) { - throw new InvalidArgumentException(sprintf('Invalid method call for service "%s", did you forgot a leading dash before "%s: ..." in %s?', $id, $k, $file)); + throw new InvalidArgumentException(sprintf('Invalid method call for service "%s", did you forgot a leading dash before "%s: ..." in "%s"?', $id, $k, $file)); } if (isset($call['method'])) { @@ -483,7 +483,7 @@ class YamlFileLoader extends FileLoader if ($args instanceof TaggedValue) { if ('returns_clone' !== $args->getTag()) { - throw new InvalidArgumentException(sprintf('Unsupported tag "!%s", did you mean "!returns_clone" for service "%s" in %s?', $args->getTag(), $id, $file)); + throw new InvalidArgumentException(sprintf('Unsupported tag "!%s", did you mean "!returns_clone" for service "%s" in "%s"?', $args->getTag(), $id, $file)); } $returnsClone = true; @@ -492,7 +492,7 @@ class YamlFileLoader extends FileLoader $returnsClone = false; } } elseif (empty($call[0])) { - throw new InvalidArgumentException(sprintf('Invalid call for service "%s": the method must be defined as the first index of an array or as the only key of a map in %s.', $id, $file)); + throw new InvalidArgumentException(sprintf('Invalid call for service "%s": the method must be defined as the first index of an array or as the only key of a map in "%s".', $id, $file)); } else { $method = $call[0]; $args = $call[1] ?? []; @@ -501,7 +501,7 @@ class YamlFileLoader extends FileLoader } if (!\is_array($args)) { - throw new InvalidArgumentException(sprintf('The second parameter for function call "%s" must be an array of its arguments for service "%s" in %s. Check your YAML syntax.', $method, $id, $file)); + throw new InvalidArgumentException(sprintf('The second parameter for function call "%s" must be an array of its arguments for service "%s" in "%s". Check your YAML syntax.', $method, $id, $file)); } $args = $this->resolveServices($args, $file); @@ -511,7 +511,7 @@ class YamlFileLoader extends FileLoader $tags = isset($service['tags']) ? $service['tags'] : []; if (!\is_array($tags)) { - throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } if (isset($defaults['tags'])) { @@ -524,18 +524,18 @@ class YamlFileLoader extends FileLoader } if (!isset($tag['name'])) { - throw new InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key for service "%s" in %s.', $id, $file)); + throw new InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key for service "%s" in "%s".', $id, $file)); } $name = $tag['name']; unset($tag['name']); if (!\is_string($name) || '' === $name) { - throw new InvalidArgumentException(sprintf('The tag name for service "%s" in %s must be a non-empty string.', $id, $file)); + throw new InvalidArgumentException(sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $id, $file)); } foreach ($tag as $attribute => $value) { if (!is_scalar($value) && null !== $value) { - throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in %s. Check your YAML syntax.', $id, $name, $attribute, $file)); + throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s" in "%s". Check your YAML syntax.', $id, $name, $attribute, $file)); } } @@ -576,7 +576,7 @@ class YamlFileLoader extends FileLoader if (isset($service['bind'])) { if (!\is_array($service['bind'])) { - throw new InvalidArgumentException(sprintf('Parameter "bind" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(sprintf('Parameter "bind" must be an array for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } $bindings = array_merge($bindings, $this->resolveServices($service['bind'], $file)); @@ -600,12 +600,12 @@ class YamlFileLoader extends FileLoader } if (\array_key_exists('namespace', $service) && !\array_key_exists('resource', $service)) { - throw new InvalidArgumentException(sprintf('A "resource" attribute must be set when the "namespace" attribute is set for service "%s" in %s. Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(sprintf('A "resource" attribute must be set when the "namespace" attribute is set for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } if (\array_key_exists('resource', $service)) { if (!\is_string($service['resource'])) { - throw new InvalidArgumentException(sprintf('A "resource" attribute must be of type string for service "%s" in %s. Check your YAML syntax.', $id, $file)); + throw new InvalidArgumentException(sprintf('A "resource" attribute must be of type string for service "%s" in "%s". Check your YAML syntax.', $id, $file)); } $exclude = isset($service['exclude']) ? $service['exclude'] : null; $namespace = isset($service['namespace']) ? $service['namespace'] : $id; @@ -647,10 +647,10 @@ class YamlFileLoader extends FileLoader return $callable; } - throw new InvalidArgumentException(sprintf('Parameter "%s" must contain an array with two elements for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file)); + throw new InvalidArgumentException(sprintf('Parameter "%s" must contain an array with two elements for service "%s" in "%s". Check your YAML syntax.', $parameter, $id, $file)); } - throw new InvalidArgumentException(sprintf('Parameter "%s" must be a string or an array for service "%s" in %s. Check your YAML syntax.', $parameter, $id, $file)); + throw new InvalidArgumentException(sprintf('Parameter "%s" must be a string or an array for service "%s" in "%s". Check your YAML syntax.', $parameter, $id, $file)); } /** @@ -683,7 +683,7 @@ class YamlFileLoader extends FileLoader try { $configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS); } catch (ParseException $e) { - throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s.', $file, $e->getMessage()), 0, $e); + throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: "%s".', $file, $e->getMessage()), 0, $e); } return $this->validate($configuration, $file); @@ -711,7 +711,7 @@ class YamlFileLoader extends FileLoader if (!$this->container->hasExtension($namespace)) { $extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); - throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s.', $namespace, $file, $namespace, $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none')); + throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $file, $namespace, $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none')); } } diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php index defedbbd28..8012a21fb5 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php @@ -147,7 +147,7 @@ class EnvPlaceholderParameterBag extends ParameterBag foreach ($this->envPlaceholders as $env => $placeholders) { if ($this->has($name = "env($env)") && null !== ($default = $this->parameters[$name]) && !\is_string($default)) { - throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, %s given.', $env, \gettype($default))); + throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, "%s" given.', $env, \gettype($default))); } } } diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 643424ad55..ce63e3cf50 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -227,7 +227,7 @@ class ParameterBag implements ParameterBagInterface $resolved = $this->get($key); if (!\is_string($resolved) && !is_numeric($resolved)) { - throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type %s inside string value "%s".', $key, \gettype($resolved), $value)); + throw new RuntimeException(sprintf('A string value must be composed of strings and/or numbers, but found parameter "%s" of type "%s" inside string value "%s".', $key, \gettype($resolved), $value)); } $resolved = (string) $resolved; diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 5763b1d4f5..174fa81d10 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -752,7 +752,7 @@ class ContainerBuilderTest extends TestCase public function testCompileWithArrayInStringResolveEnv() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('A string value must be composed of strings and/or numbers, but found parameter "env(json:ARRAY)" of type array inside string value "ABC %env(json:ARRAY)%".'); + $this->expectExceptionMessage('A string value must be composed of strings and/or numbers, but found parameter "env(json:ARRAY)" of type "array" inside string value "ABC %env(json:ARRAY)%".'); putenv('ARRAY={"foo":"bar"}'); $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index d2e81db377..0a56e7a4ac 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -589,7 +589,7 @@ class YamlFileLoaderTest extends TestCase public function testInvalidTagsWithDefaults() { $this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); - $this->expectExceptionMessageRegExp('/Parameter "tags" must be an array for service "Foo\\\Bar" in .+services31_invalid_tags\.yml\. Check your YAML syntax./'); + $this->expectExceptionMessageRegExp('/Parameter "tags" must be an array for service "Foo\\\Bar" in ".+services31_invalid_tags\.yml"\. Check your YAML syntax./'); $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('services31_invalid_tags.yml'); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php index ea6e3814af..8d3c48165f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php @@ -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)', []); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php index b96cdd50ff..1a442967a4 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php @@ -162,7 +162,7 @@ class ParameterBagTest extends TestCase $bag->resolveValue('%foo%'); $this->fail('->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); } catch (RuntimeException $e) { - $this->assertEquals('A string value must be composed of strings and/or numbers, but found parameter "bar" of type array inside string value "a %bar%".', $e->getMessage(), '->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); + $this->assertEquals('A string value must be composed of strings and/or numbers, but found parameter "bar" of type "array" inside string value "a %bar%".', $e->getMessage(), '->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); } $bag = new ParameterBag(['foo' => '%bar%', 'bar' => '%foobar%', 'foobar' => '%foo%']); diff --git a/src/Symfony/Component/DomCrawler/AbstractUriElement.php b/src/Symfony/Component/DomCrawler/AbstractUriElement.php index 2afc822c57..ac77724a60 100644 --- a/src/Symfony/Component/DomCrawler/AbstractUriElement.php +++ b/src/Symfony/Component/DomCrawler/AbstractUriElement.php @@ -49,7 +49,7 @@ abstract class AbstractUriElement $elementUriIsRelative = null === parse_url(trim($this->getRawUri()), PHP_URL_SCHEME); $baseUriIsAbsolute = \in_array(strtolower(substr($this->currentUri, 0, 4)), ['http', 'file']); if ($elementUriIsRelative && !$baseUriIsAbsolute) { - throw new \InvalidArgumentException(sprintf('The URL of the element is relative, so you must define its base URI passing an absolute URL to the constructor of the %s class ("%s" was passed).', __CLASS__, $this->currentUri)); + throw new \InvalidArgumentException(sprintf('The URL of the element is relative, so you must define its base URI passing an absolute URL to the constructor of the "%s" class ("%s" was passed).', __CLASS__, $this->currentUri)); } } diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index c4b08c88b9..9b763ab20a 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -133,11 +133,11 @@ class ChoiceFormField extends FormField foreach ($value as $v) { if (!$this->containsOption($v, $this->options)) { - throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $v, implode(', ', $this->availableOptionValues()))); + throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: "%s").', $this->name, $v, implode('", "', $this->availableOptionValues()))); } } } elseif (!$this->containsOption($value, $this->options)) { - throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $value, implode(', ', $this->availableOptionValues()))); + throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: "%s").', $this->name, $value, implode('", "', $this->availableOptionValues()))); } if ($this->multiple) { @@ -205,7 +205,7 @@ class ChoiceFormField extends FormField } if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) { - throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type'))); + throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is "%s").', $this->node->getAttribute('type'))); } $this->value = null; diff --git a/src/Symfony/Component/DomCrawler/Field/FileFormField.php b/src/Symfony/Component/DomCrawler/Field/FileFormField.php index f38aca3f4e..d4d60be227 100644 --- a/src/Symfony/Component/DomCrawler/Field/FileFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/FileFormField.php @@ -29,7 +29,7 @@ class FileFormField extends FormField { $codes = [UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION]; if (!\in_array($error, $codes)) { - throw new \InvalidArgumentException(sprintf('The error code %s is not valid.', $error)); + throw new \InvalidArgumentException(sprintf('The error code "%s" is not valid.', $error)); } $this->value = ['name' => '', 'type' => '', 'tmp_name' => '', 'error' => $error, 'size' => 0]; @@ -94,7 +94,7 @@ class FileFormField extends FormField } if ('file' !== strtolower($this->node->getAttribute('type'))) { - throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $this->node->getAttribute('type'))); + throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is "%s").', $this->node->getAttribute('type'))); } $this->setValue(null); diff --git a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php index 17cf3d92f5..96ac3729e1 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php @@ -46,11 +46,11 @@ class HtmlErrorRenderer implements ErrorRendererInterface public function __construct($debug = false, string $charset = null, $fileLinkFormat = null, string $projectDir = null, $outputBuffer = '', LoggerInterface $logger = null) { if (!\is_bool($debug) && !\is_callable($debug)) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be a boolean or a callable, %s given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); } if (!\is_string($outputBuffer) && !\is_callable($outputBuffer)) { - throw new \TypeError(sprintf('Argument 5 passed to %s() must be a string or a callable, %s given.', __METHOD__, \is_object($outputBuffer) ? \get_class($outputBuffer) : \gettype($outputBuffer))); + throw new \TypeError(sprintf('Argument 5 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, \is_object($outputBuffer) ? \get_class($outputBuffer) : \gettype($outputBuffer))); } $this->debug = $debug; diff --git a/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php b/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php index e29a070ac1..de68354329 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php @@ -35,11 +35,11 @@ class SerializerErrorRenderer implements ErrorRendererInterface public function __construct(SerializerInterface $serializer, $format, ErrorRendererInterface $fallbackErrorRenderer = null, $debug = false) { if (!\is_string($format) && !\is_callable($format)) { - throw new \TypeError(sprintf('Argument 2 passed to %s() must be a string or a callable, %s given.', __METHOD__, \is_object($format) ? \get_class($format) : \gettype($format))); + throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a string or a callable, "%s" given.', __METHOD__, \is_object($format) ? \get_class($format) : \gettype($format))); } if (!\is_bool($debug) && !\is_callable($debug)) { - throw new \TypeError(sprintf('Argument 4 passed to %s() must be a boolean or a callable, %s given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); + throw new \TypeError(sprintf('Argument 4 passed to "%s()" must be a boolean or a callable, "%s" given.', __METHOD__, \is_object($debug) ? \get_class($debug) : \gettype($debug))); } $this->serializer = $serializer; diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 22e4670b1c..39608c5913 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -369,10 +369,10 @@ class Filesystem { if (self::$lastError) { if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) { - throw new IOException(sprintf('Unable to create %s link due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', $linkType), 0, null, $target); + throw new IOException(sprintf('Unable to create "%s" link due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', $linkType), 0, null, $target); } } - throw new IOException(sprintf('Failed to create %s link from "%s" to "%s".', $linkType, $origin, $target), 0, null, $target); + throw new IOException(sprintf('Failed to create "%s" link from "%s" to "%s".', $linkType, $origin, $target), 0, null, $target); } /** @@ -642,7 +642,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); @@ -678,7 +678,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); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php index c95eb7db21..4727c42e54 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php @@ -43,13 +43,13 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface try { new \DateTimeZone($this->inputTimezone); } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Input timezone is invalid: %s.', $this->inputTimezone), $e->getCode(), $e); + throw new InvalidArgumentException(sprintf('Input timezone is invalid: "%s".', $this->inputTimezone), $e->getCode(), $e); } try { new \DateTimeZone($this->outputTimezone); } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Output timezone is invalid: %s.', $this->outputTimezone), $e->getCode(), $e); + throw new InvalidArgumentException(sprintf('Output timezone is invalid: "%s".', $this->outputTimezone), $e->getCode(), $e); } } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index d26d0fd575..ba673728e3 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -311,28 +311,28 @@ class DateTimeType extends AbstractType $resolver->setNormalizer('date_format', function (Options $options, $dateFormat) { if (null !== $dateFormat && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { - throw new LogicException(sprintf('Cannot use the "date_format" option of the %s with an HTML5 date.', self::class)); + throw new LogicException(sprintf('Cannot use the "date_format" option of the "%s" with an HTML5 date.', self::class)); } return $dateFormat; }); $resolver->setNormalizer('date_widget', function (Options $options, $dateWidget) { if (null !== $dateWidget && 'single_text' === $options['widget']) { - throw new LogicException(sprintf('Cannot use the "date_widget" option of the %s when the "widget" option is set to "single_text".', self::class)); + throw new LogicException(sprintf('Cannot use the "date_widget" option of the "%s" when the "widget" option is set to "single_text".', self::class)); } return $dateWidget; }); $resolver->setNormalizer('time_widget', function (Options $options, $timeWidget) { if (null !== $timeWidget && 'single_text' === $options['widget']) { - throw new LogicException(sprintf('Cannot use the "time_widget" option of the %s when the "widget" option is set to "single_text".', self::class)); + throw new LogicException(sprintf('Cannot use the "time_widget" option of the "%s" when the "widget" option is set to "single_text".', self::class)); } return $timeWidget; }); $resolver->setNormalizer('html5', function (Options $options, $html5) { if ($html5 && self::HTML5_FORMAT !== $options['format']) { - throw new LogicException(sprintf('Cannot use the "format" option of %s when the "html5" option is enabled.', self::class)); + throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class)); } return $html5; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index a187798cdb..f7a55ffe74 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -325,7 +325,7 @@ class DateType extends AbstractType $resolver->setNormalizer('html5', function (Options $options, $html5) { if ($html5 && 'single_text' === $options['widget'] && self::HTML5_FORMAT !== $options['format']) { - throw new LogicException(sprintf('Cannot use the "format" option of %s when the "html5" option is enabled.', self::class)); + throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class)); } return $html5; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/WeekType.php b/src/Symfony/Component/Form/Extension/Core/Type/WeekType.php index 70e0000ad9..bae115756a 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/WeekType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/WeekType.php @@ -161,7 +161,7 @@ class WeekType extends AbstractType $resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer); $resolver->setNormalizer('html5', function (Options $options, $html5) { if ($html5 && 'single_text' !== $options['widget']) { - throw new LogicException(sprintf('The "widget" option of %s must be set to "single_text" when the "html5" option is enabled.', self::class)); + throw new LogicException(sprintf('The "widget" option of "%s" must be set to "single_text" when the "html5" option is enabled.', self::class)); } return $html5; diff --git a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php index 969fcd066f..43fd327e5d 100644 --- a/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php +++ b/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php @@ -70,7 +70,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf public function __construct(FormDataExtractorInterface $dataExtractor) { if (!class_exists(ClassStub::class)) { - throw new \LogicException(sprintf('The VarDumper component is needed for using the %s class. Install symfony/var-dumper version 3.4 or above.', __CLASS__)); + throw new \LogicException(sprintf('The VarDumper component is needed for using the "%s" class. Install symfony/var-dumper version 3.4 or above.', __CLASS__)); } $this->dataExtractor = $dataExtractor; diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php index 8b77116cb7..6e318a62da 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php @@ -163,7 +163,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface public function getElement(int $index) { if (!isset($this->elements[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path.', $index)); + throw new OutOfBoundsException(sprintf('The index "%s" is not within the violation path.', $index)); } return $this->elements[$index]; @@ -175,7 +175,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface public function isProperty(int $index) { if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path.', $index)); + throw new OutOfBoundsException(sprintf('The index "%s" is not within the violation path.', $index)); } return !$this->isIndex[$index]; @@ -187,7 +187,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface public function isIndex(int $index) { if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path.', $index)); + throw new OutOfBoundsException(sprintf('The index "%s" is not within the violation path.', $index)); } return $this->isIndex[$index]; @@ -210,7 +210,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface public function mapsForm(int $index) { if (!isset($this->mapsForm[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path.', $index)); + throw new OutOfBoundsException(sprintf('The index "%s" is not within the violation path.', $index)); } return $this->mapsForm[$index]; diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 0c76bd816b..60a33115d6 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -1067,7 +1067,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac $value = $transformer->transform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException('Unable to transform data for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters()); + throw new TransformationFailedException(sprintf('Unable to transform data for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters()); } return $value; @@ -1089,7 +1089,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac $value = $transformers[$i]->reverseTransform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters()); + throw new TransformationFailedException(sprintf('Unable to reverse value for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters()); } return $value; @@ -1118,7 +1118,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac $value = $transformer->transform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException('Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters()); + throw new TransformationFailedException(sprintf('Unable to transform value for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters()); } return $value; @@ -1142,7 +1142,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac $value = $transformers[$i]->reverseTransform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters()); + throw new TransformationFailedException(sprintf('Unable to reverse value for property path "%s": %s', $this->getPropertyPath(), $exception->getMessage()), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters()); } return $value; diff --git a/src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php b/src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php index 6bf7993c0c..5d9ddfd89c 100644 --- a/src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php +++ b/src/Symfony/Component/Form/Test/Traits/ValidatorExtensionTrait.php @@ -31,7 +31,7 @@ trait ValidatorExtensionTrait } if (!$this instanceof TypeTestCase) { - throw new \Exception(sprintf('The trait "ValidatorExtensionTrait" can only be added to a class that extends %s.', TypeTestCase::class)); + throw new \Exception(sprintf('The trait "ValidatorExtensionTrait" can only be added to a class that extends "%s".', TypeTestCase::class)); } $this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock(); diff --git a/src/Symfony/Component/HttpClient/CachingHttpClient.php b/src/Symfony/Component/HttpClient/CachingHttpClient.php index a6af1b5f2d..0327791193 100644 --- a/src/Symfony/Component/HttpClient/CachingHttpClient.php +++ b/src/Symfony/Component/HttpClient/CachingHttpClient.php @@ -114,7 +114,7 @@ class CachingHttpClient implements HttpClientInterface if ($responses instanceof ResponseInterface) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of ResponseInterface 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 ResponseInterface objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } $mockResponses = []; diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index d20d8b6f32..9f9fbd0a8a 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -156,14 +156,14 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, if (\is_array($options['auth_ntlm'])) { $count = \count($options['auth_ntlm']); if ($count <= 0 || $count > 2) { - throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must contain 1 or 2 elements, %s given.', $count)); + throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must contain 1 or 2 elements, %d given.', $count)); } $options['auth_ntlm'] = implode(':', $options['auth_ntlm']); } if (!\is_string($options['auth_ntlm'])) { - throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must be a string or an array, %s given.', \gettype($options['auth_ntlm']))); + throw new InvalidArgumentException(sprintf('Option "auth_ntlm" must be a string or an array, "%s" given.', \gettype($options['auth_ntlm']))); } $curlopts[CURLOPT_USERPWD] = $options['auth_ntlm']; @@ -319,7 +319,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, if ($responses instanceof CurlResponse) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse 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 CurlResponse objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } $active = 0; @@ -439,7 +439,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface, { if (!$eof && \strlen($buffer) < $length) { if (!\is_string($data = $body($length))) { - throw new TransportException(sprintf('The return value of the "body" option callback must be a string, %s returned.', \gettype($data))); + throw new TransportException(sprintf('The return value of the "body" option callback must be a string, "%s" returned.', \gettype($data))); } $buffer .= $data; diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 1a4106ccac..7ccc435e6b 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -49,7 +49,7 @@ trait HttpClientTrait $options['buffer'] = static function (array $headers) use ($buffer) { if (!\is_bool($buffer = $buffer($headers))) { if (!\is_array($bufferInfo = @stream_get_meta_data($buffer))) { - throw new \LogicException(sprintf('The closure passed as option "buffer" must return bool or stream resource, got %s.', \is_resource($buffer) ? get_resource_type($buffer).' resource' : \gettype($buffer))); + throw new \LogicException(sprintf('The closure passed as option "buffer" must return bool or stream resource, got "%s".', \is_resource($buffer) ? get_resource_type($buffer).' resource' : \gettype($buffer))); } if (false === strpbrk($bufferInfo['mode'], 'acew+')) { @@ -61,7 +61,7 @@ trait HttpClientTrait }; } elseif (!\is_bool($buffer)) { if (!\is_array($bufferInfo = @stream_get_meta_data($buffer))) { - throw new InvalidArgumentException(sprintf('Option "buffer" must be bool, stream resource or Closure, %s given.', \is_resource($buffer) ? get_resource_type($buffer).' resource' : \gettype($buffer))); + throw new InvalidArgumentException(sprintf('Option "buffer" must be bool, stream resource or Closure, "%s" given.', \is_resource($buffer) ? get_resource_type($buffer).' resource' : \gettype($buffer))); } if (false === strpbrk($bufferInfo['mode'], 'acew+')) { @@ -95,24 +95,24 @@ trait HttpClientTrait // Validate on_progress if (!\is_callable($onProgress = $options['on_progress'] ?? 'var_dump')) { - 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))); } if (\is_array($options['auth_basic'] ?? null)) { $count = \count($options['auth_basic']); if ($count <= 0 || $count > 2) { - throw new InvalidArgumentException(sprintf('Option "auth_basic" must contain 1 or 2 elements, %s given.', $count)); + throw new InvalidArgumentException(sprintf('Option "auth_basic" must contain 1 or 2 elements, "%s" given.', $count)); } $options['auth_basic'] = implode(':', $options['auth_basic']); } if (!\is_string($options['auth_basic'] ?? '')) { - throw new InvalidArgumentException(sprintf('Option "auth_basic" must be string or an array, %s given.', \gettype($options['auth_basic']))); + throw new InvalidArgumentException(sprintf('Option "auth_basic" must be string or an array, "%s" given.', \gettype($options['auth_basic']))); } if (isset($options['auth_bearer']) && (!\is_string($options['auth_bearer']) || !preg_match('{^[-._=~+/0-9a-zA-Z]++$}', $options['auth_bearer']))) { - throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, %s given.', \is_string($options['auth_bearer']) ? 'invalid string' : \gettype($options['auth_bearer']))); + throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, %s given.', \is_string($options['auth_bearer']) ? 'invalid string' : '"'.\gettype($options['auth_bearer']).'"')); } if (isset($options['auth_basic'], $options['auth_bearer'])) { @@ -207,10 +207,10 @@ trait HttpClientTrait } if ('auth_ntlm' === $name) { - throw new InvalidArgumentException(sprintf('Option "auth_ntlm" is not supported by %s, try using CurlHttpClient instead.', __CLASS__)); + throw new InvalidArgumentException(sprintf('Option "auth_ntlm" is not supported by "%s", try using CurlHttpClient instead.', __CLASS__)); } - throw new InvalidArgumentException(sprintf('Unsupported option "%s" passed to %s, did you mean "%s"?', $name, __CLASS__, implode('", "', $alternatives ?: array_keys($defaultOptions)))); + throw new InvalidArgumentException(sprintf('Unsupported option "%s" passed to "%s", did you mean "%s"?', $name, __CLASS__, implode('", "', $alternatives ?: array_keys($defaultOptions)))); } return $options; @@ -232,13 +232,13 @@ trait HttpClientTrait if (\is_int($name)) { if (!\is_string($values)) { - throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, %s given.', $name, \gettype($values))); + throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, "%s" given.', $name, \gettype($values))); } [$name, $values] = explode(':', $values, 2); $values = [ltrim($values)]; } elseif (!is_iterable($values)) { if (\is_object($values)) { - throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, %s given.', $name, \get_class($values))); + throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, "%s" given.', $name, \get_class($values))); } $values = (array) $values; @@ -313,7 +313,7 @@ trait HttpClientTrait } if (!\is_array(@stream_get_meta_data($body))) { - throw new InvalidArgumentException(sprintf('Option "body" must be string, stream resource, iterable or callable, %s given.', \is_resource($body) ? get_resource_type($body) : \gettype($body))); + throw new InvalidArgumentException(sprintf('Option "body" must be string, stream resource, iterable or callable, "%s" given.', \is_resource($body) ? get_resource_type($body) : \gettype($body))); } return $body; @@ -339,7 +339,7 @@ trait HttpClientTrait $fingerprint[$algo] = 'pin-sha256' === $algo ? (array) $hash : str_replace(':', '', $hash); } } else { - throw new InvalidArgumentException(sprintf('Option "peer_fingerprint" must be string or array, %s given.', \gettype($fingerprint))); + throw new InvalidArgumentException(sprintf('Option "peer_fingerprint" must be string or array, "%s" given.', \gettype($fingerprint))); } return $fingerprint; diff --git a/src/Symfony/Component/HttpClient/HttplugClient.php b/src/Symfony/Component/HttpClient/HttplugClient.php index 08023b9c42..ec00b3234a 100644 --- a/src/Symfony/Component/HttpClient/HttplugClient.php +++ b/src/Symfony/Component/HttpClient/HttplugClient.php @@ -184,7 +184,7 @@ final class HttplugClient implements HttplugInterface, HttpAsyncClient, RequestF } elseif (\is_resource($body)) { $stream = $this->streamFactory->createStreamFromResource($body); } else { - throw new \InvalidArgumentException(sprintf('%s() expects string, resource or StreamInterface, %s given.', __METHOD__, \gettype($body))); + throw new \InvalidArgumentException(sprintf('"%s()" expects string, resource or StreamInterface, "%s" given.', __METHOD__, \gettype($body))); } if ($stream->isSeekable()) { diff --git a/src/Symfony/Component/HttpClient/MockHttpClient.php b/src/Symfony/Component/HttpClient/MockHttpClient.php index d69276ffb2..2d929ebfc3 100644 --- a/src/Symfony/Component/HttpClient/MockHttpClient.php +++ b/src/Symfony/Component/HttpClient/MockHttpClient.php @@ -82,7 +82,7 @@ class MockHttpClient implements HttpClientInterface if ($responses instanceof ResponseInterface) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of MockResponse 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 MockResponse objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } return new ResponseStream(MockResponse::stream($responses, $timeout)); diff --git a/src/Symfony/Component/HttpClient/NativeHttpClient.php b/src/Symfony/Component/HttpClient/NativeHttpClient.php index 55e208bd7c..bea05f65e0 100644 --- a/src/Symfony/Component/HttpClient/NativeHttpClient.php +++ b/src/Symfony/Component/HttpClient/NativeHttpClient.php @@ -235,7 +235,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac if ($responses instanceof NativeResponse) { $responses = [$responses]; } elseif (!is_iterable($responses)) { - throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of NativeResponse 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 NativeResponse objects, "%s" given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); } return new ResponseStream(NativeResponse::stream($responses, $timeout)); @@ -255,7 +255,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac while ('' !== $data = $body(self::$CHUNK_SIZE)) { 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))); } $result .= $data; diff --git a/src/Symfony/Component/HttpClient/Response/MockResponse.php b/src/Symfony/Component/HttpClient/Response/MockResponse.php index b458665d44..0f359f30b3 100644 --- a/src/Symfony/Component/HttpClient/Response/MockResponse.php +++ b/src/Symfony/Component/HttpClient/Response/MockResponse.php @@ -228,7 +228,7 @@ class MockResponse implements ResponseInterface } elseif ($body instanceof \Closure) { while ('' !== $data = $body(16372)) { 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))); } // "notify" upload progress @@ -295,7 +295,7 @@ class MockResponse implements ResponseInterface $onProgress($offset, $dlSize, $response->info); if ($dlSize && $offset !== $dlSize) { - throw new TransportException(sprintf('Transfer closed with %s bytes remaining to read.', $dlSize - $offset)); + throw new TransportException(sprintf('Transfer closed with %d bytes remaining to read.', $dlSize - $offset)); } } } diff --git a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php index 595ac9737c..f49ca68338 100644 --- a/src/Symfony/Component/HttpClient/Response/ResponseTrait.php +++ b/src/Symfony/Component/HttpClient/Response/ResponseTrait.php @@ -161,7 +161,7 @@ trait ResponseTrait } if (!\is_array($content)) { - throw new JsonException(sprintf('JSON content was expected to decode to an array, %s returned for "%s".', \gettype($content), $this->getInfo('url'))); + throw new JsonException(sprintf('JSON content was expected to decode to an array, "%s" returned for "%s".', \gettype($content), $this->getInfo('url'))); } if (null !== $this->content) { diff --git a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php index 2952fd4f62..477c33d924 100644 --- a/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php +++ b/src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php @@ -179,7 +179,7 @@ class HttpClientTraitTest extends TestCase public function testInvalidAuthBearerOption() { $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, object given.'); + $this->expectExceptionMessage('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, "object" given.'); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS); } @@ -249,7 +249,7 @@ class HttpClientTraitTest extends TestCase public function testNormalizePeerFingerprintTypeException() { $this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); - $this->expectExceptionMessage('Option "peer_fingerprint" must be string or array, object given.'); + $this->expectExceptionMessage('Option "peer_fingerprint" must be string or array, "object" given.'); $fingerprint = new \stdClass(); $this->normalizePeerFingerprint($fingerprint); diff --git a/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php b/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php index 61ceb913a9..1b3ab16a84 100644 --- a/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php +++ b/src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php @@ -56,13 +56,13 @@ class MockResponseTest extends TestCase yield [ 'content' => '"not an array"', 'responseHeaders' => [], - 'message' => 'JSON content was expected to decode to an array, string returned for "https://example.com/file.json".', + 'message' => 'JSON content was expected to decode to an array, "string" returned for "https://example.com/file.json".', ]; yield [ 'content' => '8', 'responseHeaders' => [], - 'message' => 'JSON content was expected to decode to an array, integer returned for "https://example.com/file.json".', + 'message' => 'JSON content was expected to decode to an array, "integer" returned for "https://example.com/file.json".', ]; } } diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index 9c7273a734..d45d95e096 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/src/Symfony/Component/HttpFoundation/HeaderBag.php @@ -199,7 +199,7 @@ class HeaderBag implements \IteratorAggregate, \Countable } if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) { - throw new \RuntimeException(sprintf('The %s HTTP header is not parseable (%s).', $key, $value)); + throw new \RuntimeException(sprintf('The "%s" HTTP header is not parseable (%s).', $key, $value)); } return $date; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php index cd3b37ce96..f0d07dd487 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php @@ -54,7 +54,7 @@ class RedisSessionHandler extends AbstractSessionHandler !$redis instanceof RedisProxy && !$redis instanceof RedisClusterProxy ) { - throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, %s given.', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis))); + throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis))); } if ($diff = array_diff(array_keys($options), ['prefix', 'ttl'])) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php index b92bd0ffde..a5ebd29eba 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/SessionHandlerFactory.php @@ -27,7 +27,7 @@ class SessionHandlerFactory public static function createHandler($connection): AbstractSessionHandler { if (!\is_string($connection) && !\is_object($connection)) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be a string or a connection object, %s given.', __METHOD__, \gettype($connection))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, \gettype($connection))); } switch (true) { @@ -46,7 +46,7 @@ class SessionHandlerFactory return new PdoSessionHandler($connection); case !\is_string($connection): - throw new \InvalidArgumentException(sprintf('Unsupported Connection: %s.', \get_class($connection))); + throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', \get_class($connection))); case 0 === strpos($connection, 'file://'): return new StrictSessionHandler(new NativeFileSessionHandler(substr($connection, 7))); @@ -80,6 +80,6 @@ class SessionHandlerFactory return new PdoSessionHandler($connection); } - throw new \InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection)); + throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', $connection)); } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php index fcce432d0d..0201504c9c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php @@ -186,7 +186,7 @@ class MockArraySessionStorage implements SessionStorageInterface public function getBag(string $name) { if (!isset($this->bags[$name])) { - throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); + throw new \InvalidArgumentException(sprintf('The SessionBagInterface "%s" is not registered.', $name)); } if (!$this->started) { diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index bde0bb0221..c0e0b13695 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -311,7 +311,7 @@ class NativeSessionStorage implements SessionStorageInterface public function getBag(string $name) { if (!isset($this->bags[$name])) { - throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); + throw new \InvalidArgumentException(sprintf('The SessionBagInterface "%s" is not registered.', $name)); } if (!$this->started && $this->saveHandler->isActive()) { diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index 2ff356c9ff..e8057737ed 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -69,7 +69,7 @@ abstract class Bundle implements BundleInterface if (null !== $extension) { if (!$extension instanceof ExtensionInterface) { - throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', \get_class($extension))); + throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', \get_class($extension))); } // check naming convention diff --git a/src/Symfony/Component/HttpKernel/CacheClearer/Psr6CacheClearer.php b/src/Symfony/Component/HttpKernel/CacheClearer/Psr6CacheClearer.php index ab37853d31..d0e4cc91b7 100644 --- a/src/Symfony/Component/HttpKernel/CacheClearer/Psr6CacheClearer.php +++ b/src/Symfony/Component/HttpKernel/CacheClearer/Psr6CacheClearer.php @@ -31,7 +31,7 @@ class Psr6CacheClearer implements CacheClearerInterface public function getPool(string $name) { if (!$this->hasPool($name)) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name)); + throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]; @@ -40,7 +40,7 @@ class Psr6CacheClearer implements CacheClearerInterface public function clearPool(string $name) { if (!isset($this->pools[$name])) { - throw new \InvalidArgumentException(sprintf('Cache pool not found: %s.', $name)); + throw new \InvalidArgumentException(sprintf('Cache pool not found: "%s".', $name)); } return $this->pools[$name]->clear(); diff --git a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php index e73b848e60..6fc7e70344 100644 --- a/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php +++ b/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php @@ -99,7 +99,7 @@ class ArgumentMetadata public function getDefaultValue() { if (!$this->hasDefaultValue) { - throw new \LogicException(sprintf('Argument $%s does not have a default value. Use %s::hasDefaultValue() to avoid this exception.', $this->name, __CLASS__)); + throw new \LogicException(sprintf('Argument $%s does not have a default value. Use "%s::hasDefaultValue()" to avoid this exception.', $this->name, __CLASS__)); } return $this->defaultValue; diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php index 46c4d94d67..dbffdca24d 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php @@ -193,7 +193,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface $dumper = new HtmlDumper($data, $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { - throw new \InvalidArgumentException(sprintf('Invalid dump format: %s.', $format)); + throw new \InvalidArgumentException(sprintf('Invalid dump format: "%s".', $format)); } $dumps = []; diff --git a/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php b/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php index f3d3f0d6ef..f51978ac7e 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php +++ b/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php @@ -97,7 +97,7 @@ class FragmentHandler protected function deliver(Response $response) { if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode())); + throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode())); } if (!$response instanceof StreamedResponse) { diff --git a/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php b/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php index ac2c341385..bcfa13446a 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php @@ -96,7 +96,7 @@ abstract class AbstractSurrogate implements SurrogateInterface $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); if (!$response->isSuccessful()) { - throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $subRequest->getUri(), $response->getStatusCode())); + throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $subRequest->getUri(), $response->getStatusCode())); } return $response->getContent(); diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index ab804a62ad..3aa197b767 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -221,7 +221,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl $class = static::class; $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class))).'@anonymous' : $class; - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, $class)); + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the "registerBundles()" method of your "%s.php" file?', $name, $class)); } return $this->bundles[$name]; @@ -624,10 +624,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl foreach (['cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()] as $name => $dir) { if (!is_dir($dir)) { if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n.", $name, $dir)); + throw new \RuntimeException(sprintf('Unable to create the "%s" directory (%s).', $name, $dir)); } } elseif (!is_writable($dir)) { - throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n.", $name, $dir)); + throw new \RuntimeException(sprintf('Unable to write in the "%s" directory (%s).', $name, $dir)); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php index cdf4a97d34..6e0a47e930 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheClearer/Psr6CacheClearerTest.php @@ -40,7 +40,7 @@ class Psr6CacheClearerTest extends TestCase public function testClearPoolThrowsExceptionOnUnreferencedPool() { $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage('Cache pool not found: unknown'); + $this->expectExceptionMessage('Cache pool not found: "unknown"'); (new Psr6CacheClearer())->clearPool('unknown'); } } diff --git a/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php b/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php index 03d9ac3a66..31d7fb9c8a 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php @@ -55,7 +55,7 @@ class GenrbCompiler implements BundleCompilerInterface exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status); if (0 !== $status) { - throw new RuntimeException(sprintf('genrb failed with status %d while compiling %s to %s.', $status, $sourcePath, $targetDir)); + throw new RuntimeException(sprintf('genrb failed with status %d while compiling "%s" to "%s".', $status, $sourcePath, $targetDir)); } } } diff --git a/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php b/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php index 09dd551daf..afc2e09713 100644 --- a/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php +++ b/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php @@ -36,7 +36,7 @@ class RecursiveArrayAccess } } - throw new OutOfBoundsException(sprintf('The index %s does not exist.', $index)); + throw new OutOfBoundsException(sprintf('The index "%s" does not exist.', $index)); } return $array; diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php index 1bcae1bd77..4a4e38e3e1 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php @@ -105,7 +105,7 @@ class TimezoneTransformer extends Transformer $signal = '-' === $matches['signal'] ? '+' : '-'; if (0 < $minutes) { - throw new NotImplementedException(sprintf('It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.', $formattedTimeZone)); + throw new NotImplementedException(sprintf('It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: "%s".', $formattedTimeZone)); } return 'Etc/GMT'.(0 !== $hours ? $signal.$hours : ''); diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index cf2486d246..3cf79f1125 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -360,7 +360,7 @@ abstract class NumberFormatter } if (self::CURRENCY === $this->style) { - throw new NotImplementedException(sprintf('%s() method does not support the formatting of currencies (instance with CURRENCY style). %s.', __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE)); + throw new NotImplementedException(sprintf('%s() method does not support the formatting of currencies (instance with CURRENCY style). "%s".', __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE)); } // Only the default type is supported. diff --git a/src/Symfony/Component/Ldap/Ldap.php b/src/Symfony/Component/Ldap/Ldap.php index a80d295686..69ab268520 100644 --- a/src/Symfony/Component/Ldap/Ldap.php +++ b/src/Symfony/Component/Ldap/Ldap.php @@ -75,7 +75,7 @@ final class Ldap implements LdapInterface public static function create(string $adapter, array $config = []): self { if (!isset(self::$adapterMap[$adapter])) { - throw new DriverNotFoundException(sprintf('Adapter "%s" not found. You should use one of: %s.', $adapter, implode(', ', self::$adapterMap))); + throw new DriverNotFoundException(sprintf('Adapter "%s" not found. You should use one of: "%s".', $adapter, implode('", "', self::$adapterMap))); } $class = self::$adapterMap[$adapter]; diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 4991e9f624..8747308bb2 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -38,11 +38,11 @@ class RedisStore implements PersistingStoreInterface public function __construct($redisClient, float $initialTtl = 300.0) { if (!$redisClient instanceof \Redis && !$redisClient instanceof \RedisArray && !$redisClient instanceof \RedisCluster && !$redisClient instanceof \Predis\ClientInterface && !$redisClient instanceof RedisProxy) { - throw new InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, %s given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient))); + throw new InvalidArgumentException(sprintf('"%s()" expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($redisClient) ? \get_class($redisClient) : \gettype($redisClient))); } if ($initialTtl <= 0) { - throw new InvalidTtlException(sprintf('%s() expects a strictly positive TTL. Got %d.', __METHOD__, $initialTtl)); + throw new InvalidTtlException(sprintf('"%s()" expects a strictly positive TTL. Got %d.', __METHOD__, $initialTtl)); } $this->redis = $redisClient; @@ -141,7 +141,7 @@ class RedisStore implements PersistingStoreInterface return $this->redis->eval(...array_merge([$script, 1, $resource], $args)); } - throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, %s given.', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis))); + throw new InvalidArgumentException(sprintf('%s() expects being initialized with a Redis, RedisArray, RedisCluster or Predis\ClientInterface, "%s" given.', __METHOD__, \is_object($this->redis) ? \get_class($this->redis) : \gettype($this->redis))); } private function getUniqueToken(Key $key): string diff --git a/src/Symfony/Component/Lock/Store/StoreFactory.php b/src/Symfony/Component/Lock/Store/StoreFactory.php index c7bd5725b8..01285eb2da 100644 --- a/src/Symfony/Component/Lock/Store/StoreFactory.php +++ b/src/Symfony/Component/Lock/Store/StoreFactory.php @@ -33,7 +33,7 @@ class StoreFactory public static function createStore($connection) { if (!\is_string($connection) && !\is_object($connection)) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be a string or a connection object, %s given.', __METHOD__, \gettype($connection))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a string or a connection object, "%s" given.', __METHOD__, \gettype($connection))); } switch (true) { @@ -59,7 +59,7 @@ class StoreFactory return new ZookeeperStore($connection); case !\is_string($connection): - throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', \get_class($connection))); + throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', \get_class($connection))); case 'flock' === $connection: return new FlockStore(); @@ -101,6 +101,6 @@ class StoreFactory return new ZookeeperStore(ZookeeperStore::createConnection($connection)); } - throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection)); + throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', $connection)); } } diff --git a/src/Symfony/Component/Lock/Store/ZookeeperStore.php b/src/Symfony/Component/Lock/Store/ZookeeperStore.php index f30eb08ab5..0d86d2bf20 100644 --- a/src/Symfony/Component/Lock/Store/ZookeeperStore.php +++ b/src/Symfony/Component/Lock/Store/ZookeeperStore.php @@ -37,11 +37,11 @@ class ZookeeperStore implements PersistingStoreInterface public static function createConnection(string $dsn): \Zookeeper { if (0 !== strpos($dsn, 'zookeeper:')) { - throw new InvalidArgumentException(sprintf('Unsupported DSN: %s.', $dsn)); + throw new InvalidArgumentException(sprintf('Unsupported DSN: "%s".', $dsn)); } if (false === $params = parse_url($dsn)) { - throw new InvalidArgumentException(sprintf('Invalid Zookeeper DSN: %s.', $dsn)); + throw new InvalidArgumentException(sprintf('Invalid Zookeeper DSN: "%s".', $dsn)); } $host = $params['host'] ?? ''; diff --git a/src/Symfony/Component/Mailer/Tests/TransportTest.php b/src/Symfony/Component/Mailer/Tests/TransportTest.php index d9121a5590..95eb5b6ebf 100644 --- a/src/Symfony/Component/Mailer/Tests/TransportTest.php +++ b/src/Symfony/Component/Mailer/Tests/TransportTest.php @@ -74,7 +74,7 @@ class TransportTest extends TestCase public function fromWrongStringProvider(): iterable { - yield 'garbage at the end' => ['dummy://a some garbage here', 'The DSN has some garbage at the end: some garbage here.']; + yield 'garbage at the end' => ['dummy://a some garbage here', 'The DSN has some garbage at the end: " some garbage here".']; yield 'not a valid DSN' => ['something not a dsn', 'The "something" mailer DSN must contain a scheme.']; diff --git a/src/Symfony/Component/Mailer/Transport.php b/src/Symfony/Component/Mailer/Transport.php index d72f1fa39e..b30ba6fbdc 100644 --- a/src/Symfony/Component/Mailer/Transport.php +++ b/src/Symfony/Component/Mailer/Transport.php @@ -85,7 +85,7 @@ class Transport { list($transport, $offset) = $this->parseDsn($dsn); if ($offset !== \strlen($dsn)) { - throw new InvalidArgumentException(sprintf('The DSN has some garbage at the end: %s.', substr($dsn, $offset))); + throw new InvalidArgumentException(sprintf('The DSN has some garbage at the end: "%s".', substr($dsn, $offset))); } return $transport; diff --git a/src/Symfony/Component/Messenger/Command/DebugCommand.php b/src/Symfony/Component/Messenger/Command/DebugCommand.php index b50d97d1b9..31b19d0bff 100644 --- a/src/Symfony/Component/Messenger/Command/DebugCommand.php +++ b/src/Symfony/Component/Messenger/Command/DebugCommand.php @@ -42,7 +42,7 @@ class DebugCommand extends Command protected function configure() { $this - ->addArgument('bus', InputArgument::OPTIONAL, sprintf('The bus id (one of %s)', implode(', ', array_keys($this->mapping)))) + ->addArgument('bus', InputArgument::OPTIONAL, sprintf('The bus id (one of "%s")', implode('", "', array_keys($this->mapping)))) ->setDescription('Lists messages you can dispatch using the message buses') ->setHelp(<<<'EOF' The %command.name% command displays all messages that can be @@ -70,7 +70,7 @@ EOF $mapping = $this->mapping; if ($bus = $input->getArgument('bus')) { if (!isset($mapping[$bus])) { - throw new RuntimeException(sprintf('Bus "%s" does not exist. Known buses are %s.', $bus, implode(', ', array_keys($this->mapping)))); + throw new RuntimeException(sprintf('Bus "%s" does not exist. Known buses are "%s".', $bus, implode('", "', array_keys($this->mapping)))); } $mapping = [$bus => $mapping[$bus]]; } diff --git a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php index 0ec792e734..5d0c6b178f 100644 --- a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php +++ b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php @@ -75,7 +75,7 @@ class MessengerPass implements CompilerPassInterface foreach ($container->findTaggedServiceIds($this->handlerTag, true) as $serviceId => $tags) { foreach ($tags as $tag) { if (isset($tag['bus']) && !\in_array($tag['bus'], $busIds, true)) { - throw new RuntimeException(sprintf('Invalid handler service "%s": bus "%s" specified on the tag "%s" does not exist (known ones are: %s).', $serviceId, $tag['bus'], $this->handlerTag, implode(', ', $busIds))); + throw new RuntimeException(sprintf('Invalid handler service "%s": bus "%s" specified on the tag "%s" does not exist (known ones are: "%s").', $serviceId, $tag['bus'], $this->handlerTag, implode('", "', $busIds))); } $className = $this->getServiceClass($container, $serviceId); diff --git a/src/Symfony/Component/Messenger/Envelope.php b/src/Symfony/Component/Messenger/Envelope.php index ed52000f6f..94a41d1451 100644 --- a/src/Symfony/Component/Messenger/Envelope.php +++ b/src/Symfony/Component/Messenger/Envelope.php @@ -30,7 +30,7 @@ final class Envelope public function __construct($message, array $stamps = []) { if (!\is_object($message)) { - throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object but got %s.', __METHOD__, \gettype($message))); + throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object but got "%s".', __METHOD__, \gettype($message))); } $this->message = $message; diff --git a/src/Symfony/Component/Messenger/MessageBus.php b/src/Symfony/Component/Messenger/MessageBus.php index e860457bcb..d8146070a8 100644 --- a/src/Symfony/Component/Messenger/MessageBus.php +++ b/src/Symfony/Component/Messenger/MessageBus.php @@ -62,7 +62,7 @@ class MessageBus implements MessageBusInterface public function dispatch($message, array $stamps = []): Envelope { if (!\is_object($message)) { - throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object, but got %s.', __METHOD__, \gettype($message))); + throw new \TypeError(sprintf('Invalid argument provided to "%s()": expected object, but got "%s".', __METHOD__, \gettype($message))); } $envelope = Envelope::wrap($message, $stamps); $middlewareIterator = $this->middlewareAggregate->getIterator(); diff --git a/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php b/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php index 4debfd1260..42aef7ee12 100644 --- a/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php +++ b/src/Symfony/Component/Messenger/Middleware/StackMiddleware.php @@ -37,7 +37,7 @@ class StackMiddleware implements MiddlewareInterface, StackInterface } elseif ($middlewareIterator instanceof MiddlewareInterface) { $this->stack->stack[] = $middlewareIterator; } elseif (!is_iterable($middlewareIterator)) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be iterable of %s, %s given.', __METHOD__, MiddlewareInterface::class, \is_object($middlewareIterator) ? \get_class($middlewareIterator) : \gettype($middlewareIterator))); + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be iterable of "%s", "%s" given.', __METHOD__, MiddlewareInterface::class, \is_object($middlewareIterator) ? \get_class($middlewareIterator) : \gettype($middlewareIterator))); } else { $this->stack->iterator = (function () use ($middlewareIterator) { yield from $middlewareIterator; diff --git a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php index e12ba9de1f..54c52d6622 100644 --- a/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Messenger/Tests/Command/DebugCommandTest.php @@ -156,7 +156,7 @@ TXT public function testExceptionOnUnknownBusArgument() { $this->expectException('Symfony\Component\Console\Exception\RuntimeException'); - $this->expectExceptionMessage('Bus "unknown_bus" does not exist. Known buses are command_bus, query_bus.'); + $this->expectExceptionMessage('Bus "unknown_bus" does not exist. Known buses are "command_bus", "query_bus".'); $command = new DebugCommand(['command_bus' => [], 'query_bus' => []]); $tester = new CommandTester($command); diff --git a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php index 6f102af0c9..e8e0d917fb 100644 --- a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php +++ b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php @@ -157,7 +157,7 @@ class MessengerPassTest extends TestCase public function testProcessTagWithUnknownBus() { $this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); - $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler": bus "unknown_bus" specified on the tag "messenger.message_handler" does not exist (known ones are: command_bus).'); + $this->expectExceptionMessage('Invalid handler service "Symfony\Component\Messenger\Tests\Fixtures\DummyCommandHandler": bus "unknown_bus" specified on the tag "messenger.message_handler" does not exist (known ones are: "command_bus").'); $container = $this->getContainerBuilder($commandBusId = 'command_bus'); $container->register(DummyCommandHandler::class)->addTag('messenger.message_handler', ['bus' => 'unknown_bus']); diff --git a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php index 4e1c2f6982..531643bd56 100644 --- a/src/Symfony/Component/Messenger/Tests/MessageBusTest.php +++ b/src/Symfony/Component/Messenger/Tests/MessageBusTest.php @@ -35,7 +35,7 @@ class MessageBusTest extends TestCase public function testItDispatchInvalidMessageType() { $this->expectException('TypeError'); - $this->expectExceptionMessage('Invalid argument provided to "Symfony\Component\Messenger\MessageBus::dispatch()": expected object, but got string.'); + $this->expectExceptionMessage('Invalid argument provided to "Symfony\Component\Messenger\MessageBus::dispatch()": expected object, but got "string".'); (new MessageBus())->dispatch('wrong'); } diff --git a/src/Symfony/Component/Mime/Crypto/SMime.php b/src/Symfony/Component/Mime/Crypto/SMime.php index 55941be9f4..c6317a6bb1 100644 --- a/src/Symfony/Component/Mime/Crypto/SMime.php +++ b/src/Symfony/Component/Mime/Crypto/SMime.php @@ -24,7 +24,7 @@ abstract class SMime protected function normalizeFilePath(string $path): string { if (!file_exists($path)) { - throw new RuntimeException(sprintf('File does not exist: %s.', $path)); + throw new RuntimeException(sprintf('File does not exist: "%s".', $path)); } return 'file://'.str_replace('\\', '/', realpath($path)); diff --git a/src/Symfony/Component/Mime/Tests/Crypto/SMimeTestCase.php b/src/Symfony/Component/Mime/Tests/Crypto/SMimeTestCase.php index 0bd3c139c4..b400f47e51 100644 --- a/src/Symfony/Component/Mime/Tests/Crypto/SMimeTestCase.php +++ b/src/Symfony/Component/Mime/Tests/Crypto/SMimeTestCase.php @@ -33,7 +33,7 @@ abstract class SMimeTestCase extends TestCase protected function normalizeFilePath(string $path): string { if (!file_exists($path)) { - throw new RuntimeException(sprintf('File does not exist: %s', $path)); + throw new RuntimeException(sprintf('File does not exist: "%s"', $path)); } return str_replace('\\', '/', realpath($path)); diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index a30e2fc2ba..9043f486e0 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1566,7 +1566,7 @@ class Process implements \IteratorAggregate private function requireProcessIsStarted(string $functionName) { if (!$this->isStarted()) { - throw new LogicException(sprintf('Process must be started before calling %s.', $functionName)); + throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName)); } } @@ -1578,7 +1578,7 @@ class Process implements \IteratorAggregate private function requireProcessIsTerminated(string $functionName) { if (!$this->isTerminated()) { - throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName)); + throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName)); } } diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index b2138d6864..0e3b64168d 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -940,7 +940,7 @@ class ProcessTest extends TestCase $process = $this->getProcess('foo'); $this->expectException('Symfony\Component\Process\Exception\LogicException'); - $this->expectExceptionMessage(sprintf('Process must be started before calling %s.', $method)); + $this->expectExceptionMessage(sprintf('Process must be started before calling "%s()".', $method)); $process->{$method}(); } diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index a082dde2db..0243c9b02c 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -631,7 +631,7 @@ class PropertyAccessor implements PropertyAccessorInterface public static function createCache(string $namespace, int $defaultLifetime, string $version, LoggerInterface $logger = null) { if (!class_exists('Symfony\Component\Cache\Adapter\ApcuAdapter')) { - throw new \LogicException(sprintf('The Symfony Cache component must be installed to use %s().', __METHOD__)); + throw new \LogicException(sprintf('The Symfony Cache component must be installed to use "%s()".', __METHOD__)); } if (!ApcuAdapter::isSupported()) { diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index cd29988696..9f713ef664 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -173,7 +173,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface public function getElement(int $index) { if (!isset($this->elements[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the property path.', $index)); + throw new OutOfBoundsException(sprintf('The index "%s" is not within the property path.', $index)); } return $this->elements[$index]; @@ -185,7 +185,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface public function isProperty(int $index) { if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the property path.', $index)); + throw new OutOfBoundsException(sprintf('The index "%s" is not within the property path.', $index)); } return !$this->isIndex[$index]; @@ -197,7 +197,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface public function isIndex(int $index) { if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the property path.', $index)); + throw new OutOfBoundsException(sprintf('The index "%s" is not within the property path.', $index)); } return $this->isIndex[$index]; diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php index 21befd27af..e20045ed53 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php @@ -94,7 +94,7 @@ class PropertyPathBuilder public function remove(int $offset, int $length = 1) { if (!isset($this->elements[$offset])) { - throw new OutOfBoundsException(sprintf('The offset %s is not within the property path.', $offset)); + throw new OutOfBoundsException(sprintf('The offset "%s" is not within the property path.', $offset)); } $this->resize($offset, $length, 0); @@ -149,7 +149,7 @@ class PropertyPathBuilder public function replaceByIndex(int $offset, string $name = null) { if (!isset($this->elements[$offset])) { - throw new OutOfBoundsException(sprintf('The offset %s is not within the property path.', $offset)); + throw new OutOfBoundsException(sprintf('The offset "%s" is not within the property path.', $offset)); } if (null !== $name) { @@ -170,7 +170,7 @@ class PropertyPathBuilder public function replaceByProperty(int $offset, string $name = null) { if (!isset($this->elements[$offset])) { - throw new OutOfBoundsException(sprintf('The offset %s is not within the property path.', $offset)); + throw new OutOfBoundsException(sprintf('The offset "%s" is not within the property path.', $offset)); } if (null !== $name) { diff --git a/src/Symfony/Component/Routing/Loader/ObjectLoader.php b/src/Symfony/Component/Routing/Loader/ObjectLoader.php index 88c9395c7b..963ddf9ada 100644 --- a/src/Symfony/Component/Routing/Loader/ObjectLoader.php +++ b/src/Symfony/Component/Routing/Loader/ObjectLoader.php @@ -52,7 +52,7 @@ abstract class ObjectLoader extends Loader $loaderObject = $this->getObject($parts[0]); if (!\is_object($loaderObject)) { - throw new \TypeError(sprintf('%s:getObject() must return an object: %s returned.', static::class, \gettype($loaderObject))); + throw new \TypeError(sprintf('"%s:getObject()" must return an object: "%s" returned.', static::class, \gettype($loaderObject))); } if (!\is_callable([$loaderObject, $method])) { @@ -64,7 +64,7 @@ abstract class ObjectLoader extends Loader if (!$routeCollection instanceof RouteCollection) { $type = \is_object($routeCollection) ? \get_class($routeCollection) : \gettype($routeCollection); - throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned.', \get_class($loaderObject), $method, $type)); + throw new \LogicException(sprintf('The "%s::%s()" method must return a RouteCollection: "%s" returned.', \get_class($loaderObject), $method, $type)); } // make the object file tracked so that if it changes, the cache rebuilds diff --git a/src/Symfony/Component/Routing/RouteCompiler.php b/src/Symfony/Component/Routing/RouteCompiler.php index f65fe57b50..2e29329e2d 100644 --- a/src/Symfony/Component/Routing/RouteCompiler.php +++ b/src/Symfony/Component/Routing/RouteCompiler.php @@ -150,7 +150,7 @@ class RouteCompiler implements RouteCompilerInterface } if (\strlen($varName) > self::VARIABLE_MAXIMUM_LENGTH) { - throw new \DomainException(sprintf('Variable name "%s" cannot be longer than %s characters in route pattern "%s". Please use a shorter name.', $varName, self::VARIABLE_MAXIMUM_LENGTH, $pattern)); + throw new \DomainException(sprintf('Variable name "%s" cannot be longer than %d characters in route pattern "%s". Please use a shorter name.', $varName, self::VARIABLE_MAXIMUM_LENGTH, $pattern)); } if ($isSeparator && $precedingText !== $precedingChar) { diff --git a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php index 8da5b06818..b26dd3d86e 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php @@ -60,7 +60,7 @@ class AccessDecisionManager implements AccessDecisionManagerInterface public function decide(TokenInterface $token, array $attributes, $object = null) { if (\count($attributes) > 1) { - throw new InvalidArgumentException(sprintf('Passing more than one Security attribute to %s() is not supported.', __METHOD__)); + throw new InvalidArgumentException(sprintf('Passing more than one Security attribute to "%s()" is not supported.', __METHOD__)); } return $this->{$this->strategy}($token, $attributes, $object); diff --git a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php index 351d368f5a..e5b9cfb0b7 100644 --- a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php +++ b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php @@ -75,7 +75,7 @@ class GuardAuthenticatorHandler return $response; } - throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null or a Response object. You returned %s.', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response))); + throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationSuccess()" method must return null or a Response object. You returned "%s".', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response))); } /** @@ -105,7 +105,7 @@ class GuardAuthenticatorHandler return $response; } - throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null or a Response object. You returned %s.', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response))); + throw new \UnexpectedValueException(sprintf('The "%s::onAuthenticationFailure()" method must return null or a Response object. You returned "%s".', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response))); } /** diff --git a/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php b/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php index f38c1d42a4..09e16a9fa4 100644 --- a/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php @@ -105,11 +105,11 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface $user = $guardAuthenticator->getUser($token->getCredentials(), $this->userProvider); if (null === $user) { - throw new UsernameNotFoundException(sprintf('Null returned from %s::getUser().', \get_class($guardAuthenticator))); + throw new UsernameNotFoundException(sprintf('Null returned from "%s::getUser()".', \get_class($guardAuthenticator))); } if (!$user instanceof UserInterface) { - throw new \UnexpectedValueException(sprintf('The %s::getUser() method must return a UserInterface. You returned %s.', \get_class($guardAuthenticator), \is_object($user) ? \get_class($user) : \gettype($user))); + throw new \UnexpectedValueException(sprintf('The "%s::getUser()" method must return a UserInterface. You returned "%s".', \get_class($guardAuthenticator), \is_object($user) ? \get_class($user) : \gettype($user))); } $this->userChecker->checkPreAuth($user); @@ -118,7 +118,7 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface throw new \TypeError(sprintf('%s::checkCredentials() must return a boolean value.', \get_class($guardAuthenticator))); } - throw new BadCredentialsException(sprintf('Authentication failed because %s::checkCredentials() did not return true.', \get_class($guardAuthenticator))); + throw new BadCredentialsException(sprintf('Authentication failed because "%s::checkCredentials()" did not return true.', \get_class($guardAuthenticator))); } if ($this->userProvider instanceof PasswordUpgraderInterface && $guardAuthenticator instanceof PasswordAuthenticatedInterface && null !== $this->passwordEncoder && (null !== $password = $guardAuthenticator->getPassword($token->getCredentials())) && method_exists($this->passwordEncoder, 'needsRehash') && $this->passwordEncoder->needsRehash($user)) { $this->userProvider->upgradePassword($user, $this->passwordEncoder->encodePassword($user, $password)); @@ -128,7 +128,7 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface // turn the UserInterface into a TokenInterface $authenticatedToken = $guardAuthenticator->createAuthenticatedToken($user, $this->providerKey); if (!$authenticatedToken instanceof TokenInterface) { - throw new \UnexpectedValueException(sprintf('The %s::createAuthenticatedToken() method must return a TokenInterface. You returned %s.', \get_class($guardAuthenticator), \is_object($authenticatedToken) ? \get_class($authenticatedToken) : \gettype($authenticatedToken))); + throw new \UnexpectedValueException(sprintf('The "%s::createAuthenticatedToken()" method must return a TokenInterface. You returned "%s".', \get_class($guardAuthenticator), \is_object($authenticatedToken) ? \get_class($authenticatedToken) : \gettype($authenticatedToken))); } return $authenticatedToken; diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index 196edd5dfc..b2deb42f08 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -216,7 +216,7 @@ class ExceptionListener if (!$response instanceof Response) { $given = \is_object($response) ? \get_class($response) : \gettype($response); - throw new \LogicException(sprintf('The %s::start() method must return a Response object (%s returned).', \get_class($this->authenticationEntryPoint), $given)); + throw new \LogicException(sprintf('The "%s::start()" method must return a Response object ("%s" returned).', \get_class($this->authenticationEntryPoint), $given)); } return $response; diff --git a/src/Symfony/Component/Security/Http/Firewall/RemoteUserAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/RemoteUserAuthenticationListener.php index f6b6bc5989..a33ed27f05 100644 --- a/src/Symfony/Component/Security/Http/Firewall/RemoteUserAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/RemoteUserAuthenticationListener.php @@ -41,7 +41,7 @@ class RemoteUserAuthenticationListener extends AbstractPreAuthenticatedListener protected function getPreAuthenticatedData(Request $request) { if (!$request->server->has($this->userKey)) { - throw new BadCredentialsException(sprintf('User key was not found: %s.', $this->userKey)); + throw new BadCredentialsException(sprintf('User key was not found: "%s".', $this->userKey)); } return [$request->server->get($this->userKey), null]; diff --git a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php index 855b43df31..c15c8ff730 100644 --- a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php @@ -52,7 +52,7 @@ class X509AuthenticationListener extends AbstractPreAuthenticatedListener } if (null === $user) { - throw new BadCredentialsException(sprintf('SSL credentials not found: %s, %s.', $this->userKey, $this->credentialKey)); + throw new BadCredentialsException(sprintf('SSL credentials not found: "%s", "%s".', $this->userKey, $this->credentialKey)); } return [$user, $request->server->get($this->credentialKey, '')]; diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php index 232fde09d2..3713ec7b25 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php @@ -83,7 +83,7 @@ class ExceptionListenerTest extends TestCase $listener->onKernelException($event); // the exception has been replaced by our LogicException $this->assertInstanceOf('LogicException', $event->getThrowable()); - $this->assertStringEndsWith('start() method must return a Response object (string returned).', $event->getThrowable()->getMessage()); + $this->assertStringEndsWith('start()" method must return a Response object ("string" returned).', $event->getThrowable()->getMessage()); } /** diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 42a070360f..1662f39644 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -409,7 +409,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa if (\is_object($data)) { if (null === $this->serializer) { - throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used with object data.', __METHOD__)); + throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__)); } $data = $this->serializer->normalize($data, $this->format, $this->context); @@ -475,7 +475,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa $this->buildXml($node, $val); } elseif (\is_object($val)) { if (null === $this->serializer) { - throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used with object data.', __METHOD__)); + throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__)); } return $this->selectNodeType($node, $this->serializer->normalize($val, $this->format, $this->context)); diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/FileLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/FileLoader.php index c34d14b4b4..f4947ef4ce 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/FileLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/FileLoader.php @@ -30,11 +30,11 @@ abstract class FileLoader implements LoaderInterface public function __construct(string $file) { if (!is_file($file)) { - throw new MappingException(sprintf('The mapping file %s does not exist.', $file)); + throw new MappingException(sprintf('The mapping file "%s" does not exist.', $file)); } if (!is_readable($file)) { - throw new MappingException(sprintf('The mapping file %s is not readable.', $file)); + throw new MappingException(sprintf('The mapping file "%s" is not readable.', $file)); } $this->file = $file; diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/LoaderChain.php b/src/Symfony/Component/Serializer/Mapping/Loader/LoaderChain.php index 7f90c84048..f422f11c7d 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/LoaderChain.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/LoaderChain.php @@ -40,7 +40,7 @@ class LoaderChain implements LoaderInterface { foreach ($loaders as $loader) { if (!$loader instanceof LoaderInterface) { - throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface.', \get_class($loader))); + throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', \get_class($loader))); } } diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 7ec9e8a34d..c5d8b727e2 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -354,7 +354,7 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn if ($constructorParameter->isVariadic()) { if ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) { if (!\is_array($data[$paramName])) { - throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name)); + throw new RuntimeException(sprintf('Cannot create an instance of "%s" from serialized data because the variadic parameter "%s" can only accept an array.', $class, $constructorParameter->name)); } $variadicParameters = []; @@ -384,7 +384,7 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn } elseif ($constructorParameter->isDefaultValueAvailable()) { $params[] = $constructorParameter->getDefaultValue(); } else { - throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name)); + throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name)); } } @@ -406,7 +406,7 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn try { if (null !== $parameter->getClass()) { if (!$this->serializer instanceof DenormalizerInterface) { - throw new LogicException(sprintf('Cannot create an instance of %s from serialized data because the serializer inject in "%s" is not a denormalizer.', $parameter->getClass(), self::class)); + throw new LogicException(sprintf('Cannot create an instance of "%s" from serialized data because the serializer inject in "%s" is not a denormalizer.', $parameter->getClass(), self::class)); } $parameterClass = $parameter->getClass()->getName(); $parameterData = $this->serializer->denormalize($parameterData, $parameterClass, $format, $this->createChildContext($context, $parameterName, $format)); diff --git a/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php index ad5090faa5..e1359053da 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php @@ -69,7 +69,7 @@ class ArrayDenormalizer implements ContextAwareDenormalizerInterface, Serializer public function supportsDenormalization($data, string $type, string $format = null, array $context = []): bool { if (null === $this->serializer) { - throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used.', __METHOD__)); + throw new BadMethodCallException(sprintf('The serializer needs to be set to allow "%s()" to be used.', __METHOD__)); } return '[]' === substr($type, -2) diff --git a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php index b166c84a4c..2f7d59a7ef 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php @@ -72,7 +72,7 @@ class DateIntervalNormalizer implements NormalizerInterface, DenormalizerInterfa public function denormalize($data, string $type, string $format = null, array $context = []) { if (!\is_string($data)) { - throw new InvalidArgumentException(sprintf('Data expected to be a string, %s given.', \gettype($data))); + throw new InvalidArgumentException(sprintf('Data expected to be a string, "%s" given.', \gettype($data))); } if (!$this->isISO8601($data)) { diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index 8a10139afc..302b0a53ef 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -119,7 +119,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface final public function serialize($data, string $format, array $context = []): string { if (!$this->supportsEncoding($format, $context)) { - throw new NotEncodableValueException(sprintf('Serialization for the format %s is not supported.', $format)); + throw new NotEncodableValueException(sprintf('Serialization for the format "%s" is not supported.', $format)); } if ($this->encoder->needsNormalization($format, $context)) { @@ -135,7 +135,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface final public function deserialize($data, string $type, string $format, array $context = []) { if (!$this->supportsDecoding($format, $context)) { - throw new NotEncodableValueException(sprintf('Deserialization for the format %s is not supported.', $format)); + throw new NotEncodableValueException(sprintf('Deserialization for the format "%s" is not supported.', $format)); } $data = $this->decode($data, $format, $context); @@ -171,7 +171,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface throw new LogicException('You must register at least one normalizer to be able to normalize objects.'); } - throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', \get_class($data))); + throw new NotNormalizableValueException(sprintf('Could not normalize object of type "%s", no supporting normalizer found.', \get_class($data))); } throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s.', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data)))); @@ -200,7 +200,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface return $normalizer->denormalize($data, $type, $format, $context); } - throw new NotNormalizableValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $type)); + throw new NotNormalizableValueException(sprintf('Could not denormalize object of type "%s", no supporting normalizer found.', $type)); } /** diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ConstructorArgumentsTestTrait.php b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ConstructorArgumentsTestTrait.php index 40cd02f19c..3d4ce26937 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ConstructorArgumentsTestTrait.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ConstructorArgumentsTestTrait.php @@ -55,7 +55,7 @@ trait ConstructorArgumentsTestTrait $normalizer = $this->getDenormalizerForConstructArguments(); $this->expectException(MissingConstructorArgumentsException::class); - $this->expectExceptionMessage('Cannot create an instance of '.ConstructorArgumentsObject::class.' from serialized data because its constructor requires parameter "bar" to be present.'); + $this->expectExceptionMessage('Cannot create an instance of "'.ConstructorArgumentsObject::class.'" from serialized data because its constructor requires parameter "bar" to be present.'); $normalizer->denormalize($data, ConstructorArgumentsObject::class); } } diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index 95afa624d9..6e31dfb7a6 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -307,7 +307,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'; diff --git a/src/Symfony/Component/String/ByteString.php b/src/Symfony/Component/String/ByteString.php index b810be1338..8c02e04e7b 100644 --- a/src/Symfony/Component/String/ByteString.php +++ b/src/Symfony/Component/String/ByteString.php @@ -269,7 +269,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'; diff --git a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php index e482aee769..17c257fde4 100644 --- a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php +++ b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php @@ -91,7 +91,7 @@ abstract class AbstractOperation implements OperationInterface public function getMessages(string $domain) { if (!\in_array($domain, $this->getDomains())) { - throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); + throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); } if (!isset($this->messages[$domain]['all'])) { @@ -107,7 +107,7 @@ abstract class AbstractOperation implements OperationInterface public function getNewMessages(string $domain) { if (!\in_array($domain, $this->getDomains())) { - throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); + throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); } if (!isset($this->messages[$domain]['new'])) { @@ -123,7 +123,7 @@ abstract class AbstractOperation implements OperationInterface public function getObsoleteMessages(string $domain) { if (!\in_array($domain, $this->getDomains())) { - throw new InvalidArgumentException(sprintf('Invalid domain: %s.', $domain)); + throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); } if (!isset($this->messages[$domain]['obsolete'])) { diff --git a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php index 652c9b3ec3..ef1c10b181 100644 --- a/src/Symfony/Component/Validator/Constraints/CallbackValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CallbackValidator.php @@ -46,7 +46,7 @@ class CallbackValidator extends ConstraintValidator $method($object, $this->context, $constraint->payload); } elseif (null !== $object) { if (!method_exists($object, $method)) { - throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class %s.', $method, \get_class($object))); + throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class "%s".', $method, \get_class($object))); } $reflMethod = new \ReflectionMethod($object, $method); diff --git a/src/Symfony/Component/Validator/Constraints/Collection.php b/src/Symfony/Component/Validator/Constraints/Collection.php index dcd6f35361..605d4b9dbb 100644 --- a/src/Symfony/Component/Validator/Constraints/Collection.php +++ b/src/Symfony/Component/Validator/Constraints/Collection.php @@ -57,7 +57,7 @@ class Collection extends Composite parent::initializeNestedConstraints(); if (!\is_array($this->fields)) { - throw new ConstraintDefinitionException(sprintf('The option "fields" is expected to be an array in constraint %s.', __CLASS__)); + throw new ConstraintDefinitionException(sprintf('The option "fields" is expected to be an array in constraint "%s".', __CLASS__)); } foreach ($this->fields as $fieldName => $field) { diff --git a/src/Symfony/Component/Validator/Constraints/Composite.php b/src/Symfony/Component/Validator/Constraints/Composite.php index f57a3d5fa5..b9962f095d 100644 --- a/src/Symfony/Component/Validator/Constraints/Composite.php +++ b/src/Symfony/Component/Validator/Constraints/Composite.php @@ -73,11 +73,11 @@ abstract class Composite extends Constraint $constraint = \get_class($constraint); } - throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s.', $constraint, static::class)); + throw new ConstraintDefinitionException(sprintf('The value "%s" is not an instance of Constraint in constraint "%s".', $constraint, static::class)); } if ($constraint instanceof Valid) { - throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint %s. You can only declare the Valid constraint directly on a field or method.', static::class)); + throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint "%s". You can only declare the Valid constraint directly on a field or method.', static::class)); } } @@ -101,7 +101,7 @@ abstract class Composite extends Constraint $excessGroups = array_diff($constraint->groups, $this->groups); if (\count($excessGroups) > 0) { - throw new ConstraintDefinitionException(sprintf('The group(s) "%s" passed to the constraint %s should also be passed to its containing constraint %s.', implode('", "', $excessGroups), \get_class($constraint), static::class)); + throw new ConstraintDefinitionException(sprintf('The group(s) "%s" passed to the constraint "%s" should also be passed to its containing constraint "%s".', implode('", "', $excessGroups), \get_class($constraint), static::class)); } } else { $constraint->groups = $this->groups; diff --git a/src/Symfony/Component/Validator/Constraints/Count.php b/src/Symfony/Component/Validator/Constraints/Count.php index 5bd2ae0b31..106ea7ed8a 100644 --- a/src/Symfony/Component/Validator/Constraints/Count.php +++ b/src/Symfony/Component/Validator/Constraints/Count.php @@ -55,7 +55,7 @@ class Count extends Constraint parent::__construct($options); if (null === $this->min && null === $this->max && null === $this->divisibleBy) { - throw new MissingOptionsException(sprintf('Either option "min", "max" or "divisibleBy" must be given for constraint %s.', __CLASS__), ['min', 'max', 'divisibleBy']); + throw new MissingOptionsException(sprintf('Either option "min", "max" or "divisibleBy" must be given for constraint "%s".', __CLASS__), ['min', 'max', 'divisibleBy']); } } } diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index 37cfb715d7..865c1d07ce 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -70,7 +70,7 @@ class EmailValidator extends ConstraintValidator } if (!\in_array($constraint->mode, Email::$validationModes, true)) { - throw new \InvalidArgumentException(sprintf('The %s::$mode parameter value is not valid.', \get_class($constraint))); + throw new \InvalidArgumentException(sprintf('The "%s::$mode" parameter value is not valid.', \get_class($constraint))); } if (Email::VALIDATION_MODE_STRICT === $constraint->mode) { diff --git a/src/Symfony/Component/Validator/Constraints/Length.php b/src/Symfony/Component/Validator/Constraints/Length.php index 0b516904c4..7b4c9c589d 100644 --- a/src/Symfony/Component/Validator/Constraints/Length.php +++ b/src/Symfony/Component/Validator/Constraints/Length.php @@ -58,7 +58,7 @@ class Length extends Constraint parent::__construct($options); if (null === $this->min && null === $this->max) { - throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s.', __CLASS__), ['min', 'max']); + throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint "%s".', __CLASS__), ['min', 'max']); } if (null !== $this->normalizer && !\is_callable($this->normalizer)) { diff --git a/src/Symfony/Component/Validator/Constraints/Range.php b/src/Symfony/Component/Validator/Constraints/Range.php index ccb0347b75..b713090de7 100644 --- a/src/Symfony/Component/Validator/Constraints/Range.php +++ b/src/Symfony/Component/Validator/Constraints/Range.php @@ -65,7 +65,7 @@ class Range extends Constraint parent::__construct($options); if (null === $this->min && null === $this->minPropertyPath && null === $this->max && null === $this->maxPropertyPath) { - throw new MissingOptionsException(sprintf('Either option "min", "minPropertyPath", "max" or "maxPropertyPath" must be given for constraint %s.', __CLASS__), ['min', 'minPropertyPath', 'max', 'maxPropertyPath']); + throw new MissingOptionsException(sprintf('Either option "min", "minPropertyPath", "max" or "maxPropertyPath" must be given for constraint "%s".', __CLASS__), ['min', 'minPropertyPath', 'max', 'maxPropertyPath']); } } } diff --git a/src/Symfony/Component/Validator/Constraints/Traverse.php b/src/Symfony/Component/Validator/Constraints/Traverse.php index 40313e4a8c..f5f66f53ff 100644 --- a/src/Symfony/Component/Validator/Constraints/Traverse.php +++ b/src/Symfony/Component/Validator/Constraints/Traverse.php @@ -26,7 +26,7 @@ class Traverse extends Constraint public function __construct($options = null) { if (\is_array($options) && \array_key_exists('groups', $options)) { - throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint %s.', __CLASS__)); + throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint "%s".', __CLASS__)); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php index 6277f54336..4e986ba814 100644 --- a/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php +++ b/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php @@ -72,7 +72,7 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface public function getMetadataFor($value) { if (!\is_object($value) && !\is_string($value)) { - throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: %s.', \gettype($value))); + throw new NoSuchMetadataException(sprintf('Cannot create metadata for non-objects. Got: "%s".', \gettype($value))); } $class = ltrim(\is_object($value) ? \get_class($value) : $value, '\\'); diff --git a/src/Symfony/Component/Validator/Mapping/GetterMetadata.php b/src/Symfony/Component/Validator/Mapping/GetterMetadata.php index b39e619565..c840d975df 100644 --- a/src/Symfony/Component/Validator/Mapping/GetterMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GetterMetadata.php @@ -53,10 +53,10 @@ class GetterMetadata extends MemberMetadata } elseif (method_exists($class, $hasMethod)) { $method = $hasMethod; } else { - throw new ValidatorException(sprintf('Neither of these methods exist in class %s: %s, %s, %s.', $class, $getMethod, $isMethod, $hasMethod)); + throw new ValidatorException(sprintf('Neither of these methods exist in class "%s": "%s", "%s", "%s".', $class, $getMethod, $isMethod, $hasMethod)); } } elseif (!method_exists($class, $method)) { - throw new ValidatorException(sprintf('The %s() method does not exist in class %s.', $method, $class)); + throw new ValidatorException(sprintf('The "%s()" method does not exist in class "%s".', $method, $class)); } parent::__construct($class, $method, $property); diff --git a/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php b/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php index 05ef322fde..5eb17ee375 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/LoaderChain.php @@ -36,7 +36,7 @@ class LoaderChain implements LoaderInterface { foreach ($loaders as $loader) { if (!$loader instanceof LoaderInterface) { - throw new MappingException(sprintf('Class %s is expected to implement LoaderInterface.', \get_class($loader))); + throw new MappingException(sprintf('Class "%s" is expected to implement LoaderInterface.', \get_class($loader))); } } diff --git a/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php index 98f09fe5b8..256700e1ef 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/StaticMethodLoader.php @@ -49,7 +49,7 @@ class StaticMethodLoader implements LoaderInterface } if (!$reflMethod->isStatic()) { - throw new MappingException(sprintf('The method %s::%s should be static.', $reflClass->name, $this->methodName)); + throw new MappingException(sprintf('The method "%s::%s()" should be static.', $reflClass->name, $this->methodName)); } if ($reflMethod->getDeclaringClass()->name != $reflClass->name) { diff --git a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php index 8f72ed21c4..a8d2f2c856 100644 --- a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -72,7 +72,7 @@ abstract class MemberMetadata extends GenericMetadata implements PropertyMetadat public function addConstraint(Constraint $constraint) { if (!\in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) { - throw new ConstraintDefinitionException(sprintf('The constraint %s cannot be put on properties or getters.', \get_class($constraint))); + throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on properties or getters.', \get_class($constraint))); } parent::addConstraint($constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index a84f8c00bc..11f4aab1b7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -218,7 +218,7 @@ class EmailValidatorTest extends ConstraintValidatorTestCase public function testUnknownModesOnValidateTriggerException() { $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage('The Symfony\Component\Validator\Constraints\Email::$mode parameter value is not valid.'); + $this->expectExceptionMessage('The "Symfony\Component\Validator\Constraints\Email::$mode" parameter value is not valid.'); $constraint = new Email(); $constraint->mode = 'Unknown Mode'; diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php b/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php index 0f8f765b1b..f3c639ee07 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php @@ -29,7 +29,7 @@ class FakeMetadataFactory implements MetadataFactoryInterface } if (!\is_string($class)) { - throw new NoSuchMetadataException(sprintf('No metadata for type %s', \gettype($class))); + throw new NoSuchMetadataException(sprintf('No metadata for type "%s".', \gettype($class))); } if (!isset($this->metadatas[$class])) { diff --git a/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php index 63d127c67a..127bd5a164 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php @@ -64,7 +64,7 @@ class GetterMetadataTest extends TestCase public function testUndefinedMethodNameThrowsException() { $this->expectException('Symfony\Component\Validator\Exception\ValidatorException'); - $this->expectExceptionMessage('The hasLastName() method does not exist in class Symfony\Component\Validator\Tests\Fixtures\Entity.'); + $this->expectExceptionMessage('The "hasLastName()" method does not exist in class "Symfony\Component\Validator\Tests\Fixtures\Entity".'); new GetterMetadata(self::CLASSNAME, 'lastName', 'hasLastName'); } } diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index 7d6e7392d6..bafcb31eaf 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -392,7 +392,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate break; default: - throw new \RuntimeException(sprintf('Unexpected Stub type: %s.', $item->type)); + throw new \RuntimeException(sprintf('Unexpected Stub type: "%s".', $item->type)); } } elseif ('array' === $type) { $dumper->enterHash($cursor, Cursor::HASH_INDEXED, 0, false); diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index d3180e5549..38f7fbf1af 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -76,7 +76,7 @@ class Exporter if ($reflector->hasMethod('__serialize')) { if (!$reflector->getMethod('__serialize')->isPublic()) { - throw new \Error(sprintf('Call to %s method %s::__serialize().', $reflector->getMethod('__serialize')->isProtected() ? 'protected' : 'private', $class)); + throw new \Error(sprintf('Call to %s method "%s::__serialize()".', $reflector->getMethod('__serialize')->isProtected() ? 'protected' : 'private', $class)); } if (!\is_array($properties = $value->__serialize())) { diff --git a/src/Symfony/Component/Workflow/EventListener/GuardListener.php b/src/Symfony/Component/Workflow/EventListener/GuardListener.php index 4badb75afb..9329d40436 100644 --- a/src/Symfony/Component/Workflow/EventListener/GuardListener.php +++ b/src/Symfony/Component/Workflow/EventListener/GuardListener.php @@ -77,7 +77,7 @@ class GuardListener $token = $this->tokenStorage->getToken(); if (null === $token) { - throw new InvalidTokenConfigurationException(sprintf('There are no tokens available for workflow %s.', $event->getWorkflowName())); + throw new InvalidTokenConfigurationException(sprintf('There are no tokens available for workflow "%s".', $event->getWorkflowName())); } $variables = [ diff --git a/src/Symfony/Component/Workflow/Validator/StateMachineValidator.php b/src/Symfony/Component/Workflow/Validator/StateMachineValidator.php index 023ca5df5e..355c7608ae 100644 --- a/src/Symfony/Component/Workflow/Validator/StateMachineValidator.php +++ b/src/Symfony/Component/Workflow/Validator/StateMachineValidator.php @@ -45,7 +45,7 @@ class StateMachineValidator implements DefinitionValidatorInterface $initialPlaces = $definition->getInitialPlaces(); if (2 <= \count($initialPlaces)) { - throw new InvalidDefinitionException(sprintf('The state machine "%s" can not store many places. But the definition has %s initial places. Only one is supported.', $name, \count($initialPlaces))); + throw new InvalidDefinitionException(sprintf('The state machine "%s" can not store many places. But the definition has %d initial places. Only one is supported.', $name, \count($initialPlaces))); } } } diff --git a/src/Symfony/Component/Workflow/Validator/WorkflowValidator.php b/src/Symfony/Component/Workflow/Validator/WorkflowValidator.php index 32cc80ef1e..f0e7402943 100644 --- a/src/Symfony/Component/Workflow/Validator/WorkflowValidator.php +++ b/src/Symfony/Component/Workflow/Validator/WorkflowValidator.php @@ -52,7 +52,7 @@ class WorkflowValidator implements DefinitionValidatorInterface $initialPlaces = $definition->getInitialPlaces(); if (2 <= \count($initialPlaces)) { - throw new InvalidDefinitionException(sprintf('The marking store of workflow "%s" can not store many places. But the definition has %s initial places. Only one is supported.', $name, \count($initialPlaces))); + throw new InvalidDefinitionException(sprintf('The marking store of workflow "%s" can not store many places. But the definition has %d initial places. Only one is supported.', $name, \count($initialPlaces))); } } } diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 02fa9d8daf..6e60512162 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -297,7 +297,7 @@ class Inline $i += \strlen($output); $output = trim($output); } else { - throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename); + throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename); } // a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >) @@ -321,7 +321,7 @@ class Inline private static function parseQuotedScalar(string $scalar, int &$i): string { if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) { - throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); + throw new ParseException(sprintf('Malformed inline YAML string: "%s".', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } $output = substr($match[0], 1, -1); @@ -397,7 +397,7 @@ class Inline ++$i; } - throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename); + throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename); } /** @@ -538,7 +538,7 @@ class Inline } } - throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename); + throw new ParseException(sprintf('Malformed inline YAML string: "%s".', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename); } /** diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index f5f0f12f0f..e6c49bf069 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -617,7 +617,7 @@ class InlineTest extends TestCase public function testNotSupportedMissingValue() { $this->expectException('Symfony\Component\Yaml\Exception\ParseException'); - $this->expectExceptionMessage('Malformed inline YAML string: {this, is not, supported} at line 1.'); + $this->expectExceptionMessage('Malformed inline YAML string: "{this, is not, supported}" at line 1.'); Inline::parse('{this, is not, supported}'); }