Merge branch '4.4' into 5.0

* 4.4:
  Fix quotes in exception messages
  Fix quotes in exception messages
  Fix quotes in exception messages
This commit is contained in:
Fabien Potencier 2020-03-16 13:10:54 +01:00
commit e903750b9c
152 changed files with 276 additions and 276 deletions

View File

@ -429,7 +429,7 @@ abstract class AbstractDoctrineExtension extends Extension
} }
if (null !== $autoMappedManager) { 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; $autoMappedManager = $name;

View File

@ -69,7 +69,7 @@ class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
$connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections); $connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
foreach ($connections as $con) { foreach ($connections as $con) {
if (!isset($this->connections[$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)]); $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); $connections = isset($tag['connection']) ? [$tag['connection']] : array_keys($this->connections);
foreach ($connections as $con) { foreach ($connections as $con) {
if (!isset($this->connections[$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); $listenerRefs[$con][$id] = new Reference($id);

View File

@ -53,7 +53,7 @@ class EntityType extends DoctrineType
public function getLoader(ObjectManager $manager, $queryBuilder, string $class) public function getLoader(ObjectManager $manager, $queryBuilder, string $class)
{ {
if (!$queryBuilder instanceof QueryBuilder) { 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); return new ORMQueryBuilderLoader($queryBuilder);
@ -79,7 +79,7 @@ class EntityType extends DoctrineType
public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array public function getQueryBuilderPartsForCachingHash($queryBuilder): ?array
{ {
if (!$queryBuilder instanceof QueryBuilder) { 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 [ return [

View File

@ -50,7 +50,7 @@ class DoctrineFooType extends Type
return null; return null;
} }
if (!$value instanceof Foo) { 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; return $foo->bar;

View File

@ -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) 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)) { 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); parent::__construct($level, $bubble);

View File

@ -88,7 +88,7 @@ class LazyLoadingValueHolderGenerator extends BaseGenerator
$newBody = preg_replace('/^(\$this->initializer[a-zA-Z0-9]++) && .*;\n\nreturn (\$this->valueHolder)/', '$1 || $2', $body); $newBody = preg_replace('/^(\$this->initializer[a-zA-Z0-9]++) && .*;\n\nreturn (\$this->valueHolder)/', '$1 || $2', $body);
if ($body === $newBody) { 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); $destructor->setBody($newBody);

View File

@ -35,7 +35,7 @@ class TwigErrorRenderer implements ErrorRendererInterface
public function __construct(Environment $twig, HtmlErrorRenderer $fallbackErrorRenderer = null, $debug = false) public function __construct(Environment $twig, HtmlErrorRenderer $fallbackErrorRenderer = null, $debug = false)
{ {
if (!\is_bool($debug) && !\is_callable($debug)) { 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; $this->twig = $twig;

View File

@ -51,7 +51,7 @@ class NotificationEmail extends TemplatedEmail
} }
if ($missingPackages) { 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); parent::__construct($headers, $body);

View File

@ -171,7 +171,7 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI
return (string) $this->resolve($resolved); 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); }, $value);
return str_replace('%%', '%', $escapedValue); return str_replace('%%', '%', $escapedValue);

View File

@ -34,7 +34,7 @@ class SodiumVault extends AbstractVault implements EnvVarLoaderInterface
public function __construct(string $secretsDir, $decryptionKey = null) public function __construct(string $secretsDir, $decryptionKey = null)
{ {
if (null !== $decryptionKey && !\is_string($decryptionKey) && !(\is_object($decryptionKey) && method_exists($decryptionKey, '__toString'))) { 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).'.'; $this->pathPrefix = rtrim(strtr($secretsDir, '/', \DIRECTORY_SEPARATOR), \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR.basename($secretsDir).'.';

View File

@ -55,11 +55,11 @@ abstract class KernelTestCase extends TestCase
protected static function getKernelClass() protected static function getKernelClass()
{ {
if (!isset($_SERVER['KERNEL_CLASS']) && !isset($_ENV['KERNEL_CLASS'])) { 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'])) { 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; return $class;

View File

@ -390,7 +390,7 @@ class RouterTest extends TestCase
public function testExceptionOnNonStringParameter() public function testExceptionOnNonStringParameter()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $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 = new RouteCollection();
$routes->add('foo', new Route('/%object%')); $routes->add('foo', new Route('/%object%'));
@ -405,7 +405,7 @@ class RouterTest extends TestCase
public function testExceptionOnNonStringParameterWithSfContainer() public function testExceptionOnNonStringParameterWithSfContainer()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $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 = new RouteCollection();
$routes->add('foo', new Route('/%object%')); $routes->add('foo', new Route('/%object%'));

View File

@ -52,7 +52,7 @@ class AddSecurityVotersPass implements CompilerPassInterface
$class = $container->getParameterBag()->resolveValue($definition->getClass()); $class = $container->getParameterBag()->resolveValue($definition->getClass());
if (!is_a($class, VoterInterface::class, true)) { 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) { if ($debug) {

View File

@ -130,7 +130,7 @@ class AddSecurityVotersPassTest extends TestCase
public function testVoterMissingInterface() public function testVoterMissingInterface()
{ {
$exception = LogicException::class; $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->expectException($exception);
$this->expectExceptionMessage($message); $this->expectExceptionMessage($message);

View File

@ -308,7 +308,7 @@ class TwigExtensionTest extends TestCase
$loader = new YamlFileLoader($container, $locator); $loader = new YamlFileLoader($container, $locator);
break; break;
default: default:
throw new \InvalidArgumentException(sprintf('Unsupported format: %s', $format)); throw new \InvalidArgumentException(sprintf('Unsupported format: "%s"', $format));
} }
$loader->load($file.'.'.$format); $loader->load($file.'.'.$format);

View File

@ -131,7 +131,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
return MemcachedAdapter::createConnection($dsn, $options); return MemcachedAdapter::createConnection($dsn, $options);
} }
throw new InvalidArgumentException(sprintf('Unsupported DSN: %s.', $dsn)); throw new InvalidArgumentException(sprintf('Unsupported DSN: "%s".', $dsn));
} }
/** /**

View File

@ -130,7 +130,7 @@ final class CacheItem implements ItemInterface
throw new InvalidArgumentException('Cache tag length must be greater than zero.'); throw new InvalidArgumentException('Cache tag length must be greater than zero.');
} }
if (false !== strpbrk($tag, self::RESERVED_CHARACTERS)) { 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; $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.'); throw new InvalidArgumentException('Cache key length must be greater than zero.');
} }
if (false !== strpbrk($key, self::RESERVED_CHARACTERS)) { 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; return $key;

View File

@ -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) { 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) { if ($redisClient instanceof \Predis\ClientInterface && $redisClient->getOptions()->exceptions) {
@ -93,11 +93,11 @@ trait RedisTrait
} elseif (0 === strpos($dsn, 'rediss:')) { } elseif (0 === strpos($dsn, 'rediss:')) {
$scheme = 'rediss'; $scheme = 'rediss';
} else { } 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)) { 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) { $params = preg_replace_callback('#^'.$scheme.':(//)?(?:(?:[^:@]*+:)?([^@]*+)@)?#', function ($m) use (&$auth) {
@ -109,7 +109,7 @@ trait RedisTrait
}, $dsn); }, $dsn);
if (false === $params = parse_url($params)) { 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 = []; $query = $hosts = [];
@ -119,7 +119,7 @@ trait RedisTrait
if (isset($query['host'])) { if (isset($query['host'])) {
if (!\is_array($hosts = $query['host'])) { if (!\is_array($hosts = $query['host'])) {
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s.', $dsn)); throw new InvalidArgumentException(sprintf('Invalid Redis DSN: "%s".', $dsn));
} }
foreach ($hosts as $host => $parameters) { foreach ($hosts as $host => $parameters) {
if (\is_string($parameters)) { if (\is_string($parameters)) {
@ -151,11 +151,11 @@ trait RedisTrait
} }
if (!$hosts) { 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)) { 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; $params += $query + $options + self::$defaultConnectionOptions;
@ -174,7 +174,7 @@ trait RedisTrait
try { try {
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']); @$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
} catch (\RedisException $e) { } 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; }); set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
@ -182,7 +182,7 @@ trait RedisTrait
restore_error_handler(); restore_error_handler();
if (!$isConnected) { if (!$isConnected) {
$error = preg_match('/^Redis::p?connect\(\): (.*)/', $error, $error) ? sprintf(' (%s)', $error[1]) : ''; $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)) if ((null !== $auth && !$redis->auth($auth))
@ -190,7 +190,7 @@ trait RedisTrait
|| ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout'])) || ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout']))
) { ) {
$e = preg_replace('/^ERR /', '', $redis->getLastError()); $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')) { if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
@ -215,7 +215,7 @@ trait RedisTrait
try { try {
$redis = new $class($hosts, $params); $redis = new $class($hosts, $params);
} catch (\RedisClusterException $e) { } 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')) { if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
@ -230,7 +230,7 @@ trait RedisTrait
try { try {
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']); $redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']);
} catch (\RedisClusterException $e) { } 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')) { if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
@ -250,7 +250,7 @@ trait RedisTrait
if ($params['redis_cluster']) { if ($params['redis_cluster']) {
$params['cluster'] = 'redis'; $params['cluster'] = 'redis';
if (isset($params['redis_sentinel'])) { 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'])) { } elseif (isset($params['redis_sentinel'])) {
$params['replication'] = 'sentinel'; $params['replication'] = 'sentinel';

View File

@ -207,7 +207,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
protected function finalizeValue($value) protected function finalizeValue($value)
{ {
if (false === $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) { foreach ($this->children as $name => $child) {

View File

@ -175,7 +175,7 @@ class PrototypedArrayNode extends ArrayNode
protected function finalizeValue($value) protected function finalizeValue($value)
{ {
if (false === $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) { foreach ($value as $k => $v) {

View File

@ -68,7 +68,7 @@ class FileLocator implements FileLocatorInterface
} }
if (!$filepaths) { 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; return $filepaths;

View File

@ -77,7 +77,7 @@ class ApplicationDescription
public function getCommand(string $name): Command public function getCommand(string $name): Command
{ {
if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { 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]; return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];

View File

@ -113,7 +113,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
public function getStyle(string $name) public function getStyle(string $name)
{ {
if (!$this->hasStyle($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)]; return $this->styles[strtolower($name)];

View File

@ -606,7 +606,7 @@ class Table
$unmergedRows = []; $unmergedRows = [];
foreach ($rows[$line] as $column => $cell) { foreach ($rows[$line] as $column => $cell) {
if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) { 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) { if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
$nbLines = $cell->getRowspan() - 1; $nbLines = $cell->getRowspan() - 1;

View File

@ -150,7 +150,7 @@ class ChoiceQuestion extends Question
} }
if (\count($results) > 1) { 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); $result = array_search($value, $choices);

View File

@ -630,7 +630,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
public function testAmbiguousChoiceFromChoicelist() public function testAmbiguousChoiceFromChoicelist()
{ {
$this->expectException('InvalidArgumentException'); $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 = [ $possibleChoices = [
'env_1' => 'My first environment', 'env_1' => 'My first environment',
'env_2' => 'My environment', 'env_2' => 'My environment',

View File

@ -770,7 +770,7 @@ TABLE;
public function testThrowsWhenTheCellInAnArray() public function testThrowsWhenTheCellInAnArray()
{ {
$this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException'); $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 = new Table($output = $this->getOutputStream());
$table $table
->setHeaders(['ISBN', 'Title', 'Author', 'Price']) ->setHeaders(['ISBN', 'Title', 'Author', 'Price'])

View File

@ -55,7 +55,7 @@ class StringHandler implements HandlerInterface
$match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote)); $match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote));
if (!$match) { 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 // check unclosed strings

View File

@ -53,7 +53,7 @@ class FunctionExtension extends AbstractExtension
try { try {
list($a, $b) = Parser::parseSeries($function->getArguments()); list($a, $b) = Parser::parseSeries($function->getArguments());
} catch (SyntaxErrorException $e) { } 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(); $xpath->addStarPrefix();

View File

@ -45,7 +45,7 @@ trait ReferenceSetArgumentTrait
{ {
foreach ($values as $k => $v) { foreach ($values as $k => $v) {
if (null !== $v && !$v instanceof Reference) { 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)));
} }
} }

View File

@ -209,7 +209,7 @@ abstract class AbstractRecursivePass implements CompilerPassInterface
$arg = $this->processValue(new Reference($id)); $arg = $this->processValue(new Reference($id));
$this->inExpression = false; $this->inExpression = false;
if (!$arg instanceof Reference) { 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); $arg = sprintf('"%s"', $arg);
} }

View File

@ -125,7 +125,7 @@ class PriorityTaggedServiceUtil
$defaultIndex = $rm->invoke(null); $defaultIndex = $rm->invoke(null);
if (!\is_string($defaultIndex)) { 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; return $defaultIndex;
@ -154,7 +154,7 @@ class PriorityTaggedServiceUtil
$defaultPriority = $rm->invoke(null); $defaultPriority = $rm->invoke(null);
if (!\is_int($defaultPriority)) { 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; return $defaultPriority;

View File

@ -134,7 +134,7 @@ class ResolveBindingsPass extends AbstractRecursivePass
} }
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) { 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)));
} }
} }

View File

@ -76,7 +76,7 @@ class ResolveNamedArgumentsPass extends AbstractRecursivePass
} }
if (null !== $argument && !$argument instanceof Reference && !$argument instanceof Definition) { 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; $typeFound = false;

View File

@ -1387,7 +1387,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
$completed = true; $completed = true;
} else { } else {
if (!\is_string($resolved) && !is_numeric($resolved)) { 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); $value = str_ireplace($placeholder, $resolved, $value);
} }

View File

@ -1376,7 +1376,7 @@ EOF;
foreach ($this->container->getParameterBag()->all() as $key => $value) { foreach ($this->container->getParameterBag()->all() as $key => $value) {
if ($key !== $resolvedKey = $this->container->resolveEnvPlaceholders($key)) { 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 = $this->exportParameters([$value]);
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2); $export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);

View File

@ -184,7 +184,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
} }
if (!is_scalar($env)) { 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) { if ('string' === $prefix) {
@ -231,7 +231,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
} }
if (null !== $env && !\is_array($env)) { 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; return $env;
@ -244,7 +244,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
throw new RuntimeException(sprintf('Invalid URL in env var "%s".', $name)); throw new RuntimeException(sprintf('Invalid URL in env var "%s".', $name));
} }
if (!isset($parsedEnv['scheme'], $parsedEnv['host'])) { 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 += [ $parsedEnv += [
'port' => null, 'port' => null,

View File

@ -31,7 +31,7 @@ abstract class AbstractConfigurator
return $this->{'set'.$method}(...$args); 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));
} }
/** /**

View File

@ -48,7 +48,7 @@ class ContainerConfigurator extends AbstractConfigurator
{ {
if (!$this->container->hasExtension($namespace)) { if (!$this->container->hasExtension($namespace)) {
$extensions = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); $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)); $this->container->loadFromExtension($namespace, static::processValue($config));

View File

@ -90,10 +90,10 @@ abstract class FileLoader extends BaseFileLoader
public function registerClasses(Definition $prototype, $namespace, $resource, $exclude = null) public function registerClasses(Definition $prototype, $namespace, $resource, $exclude = null)
{ {
if ('\\' !== substr($namespace, -1)) { 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)) { 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); $classes = $this->findClasses($namespace, $resource, (array) $exclude);

View File

@ -171,7 +171,7 @@ class XmlFileLoader extends FileLoader
foreach ($defaults['tags'] as $tag) { foreach ($defaults['tags'] as $tag) {
if ('' === $tag->getAttribute('name')) { if ('' === $tag->getAttribute('name')) {
throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in %s must be a non-empty string.', $file)); throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in "%s" must be a non-empty string.', $file));
} }
} }
@ -344,7 +344,7 @@ class XmlFileLoader extends FileLoader
} }
if ('' === $tag->getAttribute('name')) { 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); $definition->addTag($tag->getAttribute('name'), $parameters);
@ -395,7 +395,7 @@ class XmlFileLoader extends FileLoader
try { try {
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']); $dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
} catch (\InvalidArgumentException $e) { } 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); $this->validateExtensions($dom, $file);
@ -437,7 +437,7 @@ class XmlFileLoader extends FileLoader
// anonymous services "in the wild" // anonymous services "in the wild"
if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) { if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) {
foreach ($nodes as $node) { 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()));
} }
} }
@ -678,7 +678,7 @@ EOF
// can it be handled by an extension? // can it be handled by an extension?
if (!$this->container->hasExtension($node->namespaceURI)) { if (!$this->container->hasExtension($node->namespaceURI)) {
$extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getNamespace(); }, $this->container->getExtensions())); $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'));
} }
} }
} }

View File

@ -134,7 +134,7 @@ class YamlFileLoader extends FileLoader
// parameters // parameters
if (isset($content['parameters'])) { if (isset($content['parameters'])) {
if (!\is_array($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) { foreach ($content['parameters'] as $key => $value) {
@ -180,7 +180,7 @@ class YamlFileLoader extends FileLoader
} }
if (!\is_array($content['imports'])) { 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); $defaultDirectory = \dirname($file);
@ -189,7 +189,7 @@ class YamlFileLoader extends FileLoader
$import = ['resource' => $import]; $import = ['resource' => $import];
} }
if (!isset($import['resource'])) { 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); $this->setCurrentDir($defaultDirectory);
@ -204,7 +204,7 @@ class YamlFileLoader extends FileLoader
} }
if (!\is_array($content['services'])) { 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'])) { if (\array_key_exists('_instanceof', $content['services'])) {
@ -218,10 +218,10 @@ class YamlFileLoader extends FileLoader
$this->isLoadingInstanceof = true; $this->isLoadingInstanceof = true;
foreach ($instanceof as $id => $service) { foreach ($instanceof as $id => $service) {
if (!$service || !\is_array($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, '@')) { 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, []); $this->parseDefinition($id, $service, $file, []);
} }
@ -257,7 +257,7 @@ class YamlFileLoader extends FileLoader
if (isset($defaults['tags'])) { if (isset($defaults['tags'])) {
if (!\is_array($tags = $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) { foreach ($tags as $tag) {
@ -266,18 +266,18 @@ class YamlFileLoader extends FileLoader
} }
if (!isset($tag['name'])) { 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']; $name = $tag['name'];
unset($tag['name']); unset($tag['name']);
if (!\is_string($name) || '' === $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) { foreach ($tag as $attribute => $value) {
if (!is_scalar($value) && null !== $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));
} }
} }
} }
@ -285,7 +285,7 @@ class YamlFileLoader extends FileLoader
if (isset($defaults['bind'])) { if (isset($defaults['bind'])) {
if (!\is_array($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) { foreach ($this->resolveServices($defaults['bind'], $file) as $argument => $value) {
@ -338,7 +338,7 @@ class YamlFileLoader extends FileLoader
} }
if (!\is_array($service)) { 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); $this->checkDefinition($id, $service, $file);
@ -459,16 +459,16 @@ class YamlFileLoader extends FileLoader
if (isset($service['calls'])) { if (isset($service['calls'])) {
if (!\is_array($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) { foreach ($service['calls'] as $k => $call) {
if (!\is_array($call) && (!\is_string($k) || !$call instanceof TaggedValue)) { 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)) { 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'])) { if (isset($call['method'])) {
@ -482,7 +482,7 @@ class YamlFileLoader extends FileLoader
if ($args instanceof TaggedValue) { if ($args instanceof TaggedValue) {
if ('returns_clone' !== $args->getTag()) { 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; $returnsClone = true;
@ -491,7 +491,7 @@ class YamlFileLoader extends FileLoader
$returnsClone = false; $returnsClone = false;
} }
} elseif (empty($call[0])) { } 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 { } else {
$method = $call[0]; $method = $call[0];
$args = $call[1] ?? []; $args = $call[1] ?? [];
@ -500,7 +500,7 @@ class YamlFileLoader extends FileLoader
} }
if (!\is_array($args)) { 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); $args = $this->resolveServices($args, $file);
@ -510,7 +510,7 @@ class YamlFileLoader extends FileLoader
$tags = isset($service['tags']) ? $service['tags'] : []; $tags = isset($service['tags']) ? $service['tags'] : [];
if (!\is_array($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'])) { if (isset($defaults['tags'])) {
@ -523,18 +523,18 @@ class YamlFileLoader extends FileLoader
} }
if (!isset($tag['name'])) { 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']; $name = $tag['name'];
unset($tag['name']); unset($tag['name']);
if (!\is_string($name) || '' === $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) { foreach ($tag as $attribute => $value) {
if (!is_scalar($value) && null !== $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));
} }
} }
@ -575,7 +575,7 @@ class YamlFileLoader extends FileLoader
if (isset($service['bind'])) { if (isset($service['bind'])) {
if (!\is_array($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)); $bindings = array_merge($bindings, $this->resolveServices($service['bind'], $file));
@ -599,12 +599,12 @@ class YamlFileLoader extends FileLoader
} }
if (\array_key_exists('namespace', $service) && !\array_key_exists('resource', $service)) { 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 (\array_key_exists('resource', $service)) {
if (!\is_string($service['resource'])) { 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; $exclude = isset($service['exclude']) ? $service['exclude'] : null;
$namespace = isset($service['namespace']) ? $service['namespace'] : $id; $namespace = isset($service['namespace']) ? $service['namespace'] : $id;
@ -646,10 +646,10 @@ class YamlFileLoader extends FileLoader
return $callable; 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));
} }
/** /**
@ -682,7 +682,7 @@ class YamlFileLoader extends FileLoader
try { try {
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS); $configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
} catch (ParseException $e) { } 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); return $this->validate($configuration, $file);
@ -710,7 +710,7 @@ class YamlFileLoader extends FileLoader
if (!$this->container->hasExtension($namespace)) { if (!$this->container->hasExtension($namespace)) {
$extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); $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'));
} }
} }

View File

@ -45,7 +45,7 @@ class EnvPlaceholderParameterBag extends ParameterBag
} }
} }
if (!preg_match('/^(?:\w*+:)*+\w++$/', $env)) { if (!preg_match('/^(?:\w*+:)*+\w++$/', $env)) {
throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name)); throw new InvalidArgumentException(sprintf('Invalid "%s" name: only "word" characters are allowed.', $name));
} }
if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) { if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) {
throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name)); throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name));
@ -147,7 +147,7 @@ class EnvPlaceholderParameterBag extends ParameterBag
foreach ($this->envPlaceholders as $env => $placeholders) { foreach ($this->envPlaceholders as $env => $placeholders) {
if ($this->has($name = "env($env)") && null !== ($default = $this->parameters[$name]) && !\is_string($default)) { 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)));
} }
} }
} }

View File

@ -227,7 +227,7 @@ class ParameterBag implements ParameterBagInterface
$resolved = $this->get($key); $resolved = $this->get($key);
if (!\is_string($resolved) && !is_numeric($resolved)) { 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; $resolved = (string) $resolved;

View File

@ -738,7 +738,7 @@ class ContainerBuilderTest extends TestCase
public function testCompileWithArrayInStringResolveEnv() public function testCompileWithArrayInStringResolveEnv()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException'); $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"}'); putenv('ARRAY={"foo":"bar"}');
$container = new ContainerBuilder(); $container = new ContainerBuilder();

View File

@ -589,7 +589,7 @@ class YamlFileLoaderTest extends TestCase
public function testInvalidTagsWithDefaults() public function testInvalidTagsWithDefaults()
{ {
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException'); $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 = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('services31_invalid_tags.yml'); $loader->load('services31_invalid_tags.yml');
} }

View File

@ -162,7 +162,7 @@ class ParameterBagTest extends TestCase
$bag->resolveValue('%foo%'); $bag->resolveValue('%foo%');
$this->fail('->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter'); $this->fail('->resolveValue() throws a RuntimeException when a parameter embeds another non-string parameter');
} catch (RuntimeException $e) { } 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%']); $bag = new ParameterBag(['foo' => '%bar%', 'bar' => '%foobar%', 'foobar' => '%foo%']);

View File

@ -49,7 +49,7 @@ abstract class AbstractUriElement
$elementUriIsRelative = null === parse_url(trim($this->getRawUri()), PHP_URL_SCHEME); $elementUriIsRelative = null === parse_url(trim($this->getRawUri()), PHP_URL_SCHEME);
$baseUriIsAbsolute = \in_array(strtolower(substr($this->currentUri, 0, 4)), ['http', 'file']); $baseUriIsAbsolute = \in_array(strtolower(substr($this->currentUri, 0, 4)), ['http', 'file']);
if ($elementUriIsRelative && !$baseUriIsAbsolute) { 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));
} }
} }

View File

@ -133,11 +133,11 @@ class ChoiceFormField extends FormField
foreach ($value as $v) { foreach ($value as $v) {
if (!$this->containsOption($v, $this->options)) { 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)) { } 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) { 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'))) { 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; $this->value = null;

View File

@ -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]; $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)) { 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]; $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'))) { 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); $this->setValue(null);

View File

@ -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) public function __construct($debug = false, string $charset = null, $fileLinkFormat = null, string $projectDir = null, $outputBuffer = '', LoggerInterface $logger = null)
{ {
if (!\is_bool($debug) && !\is_callable($debug)) { 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)) { 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; $this->debug = $debug;

View File

@ -35,11 +35,11 @@ class SerializerErrorRenderer implements ErrorRendererInterface
public function __construct(SerializerInterface $serializer, $format, ErrorRendererInterface $fallbackErrorRenderer = null, $debug = false) public function __construct(SerializerInterface $serializer, $format, ErrorRendererInterface $fallbackErrorRenderer = null, $debug = false)
{ {
if (!\is_string($format) && !\is_callable($format)) { 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)) { 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; $this->serializer = $serializer;

View File

@ -369,10 +369,10 @@ class Filesystem
{ {
if (self::$lastError) { if (self::$lastError) {
if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) { 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);
} }
/** /**

View File

@ -43,13 +43,13 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface
try { try {
new \DateTimeZone($this->inputTimezone); new \DateTimeZone($this->inputTimezone);
} catch (\Exception $e) { } 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 { try {
new \DateTimeZone($this->outputTimezone); new \DateTimeZone($this->outputTimezone);
} catch (\Exception $e) { } 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);
} }
} }
} }

View File

@ -311,28 +311,28 @@ class DateTimeType extends AbstractType
$resolver->setNormalizer('date_format', function (Options $options, $dateFormat) { $resolver->setNormalizer('date_format', function (Options $options, $dateFormat) {
if (null !== $dateFormat && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { 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; return $dateFormat;
}); });
$resolver->setNormalizer('date_widget', function (Options $options, $dateWidget) { $resolver->setNormalizer('date_widget', function (Options $options, $dateWidget) {
if (null !== $dateWidget && 'single_text' === $options['widget']) { 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; return $dateWidget;
}); });
$resolver->setNormalizer('time_widget', function (Options $options, $timeWidget) { $resolver->setNormalizer('time_widget', function (Options $options, $timeWidget) {
if (null !== $timeWidget && 'single_text' === $options['widget']) { 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; return $timeWidget;
}); });
$resolver->setNormalizer('html5', function (Options $options, $html5) { $resolver->setNormalizer('html5', function (Options $options, $html5) {
if ($html5 && self::HTML5_FORMAT !== $options['format']) { 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; return $html5;

View File

@ -325,7 +325,7 @@ class DateType extends AbstractType
$resolver->setNormalizer('html5', function (Options $options, $html5) { $resolver->setNormalizer('html5', function (Options $options, $html5) {
if ($html5 && 'single_text' === $options['widget'] && self::HTML5_FORMAT !== $options['format']) { 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; return $html5;

View File

@ -161,7 +161,7 @@ class WeekType extends AbstractType
$resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer); $resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer);
$resolver->setNormalizer('html5', function (Options $options, $html5) { $resolver->setNormalizer('html5', function (Options $options, $html5) {
if ($html5 && 'single_text' !== $options['widget']) { 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; return $html5;

View File

@ -70,7 +70,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
public function __construct(FormDataExtractorInterface $dataExtractor) public function __construct(FormDataExtractorInterface $dataExtractor)
{ {
if (!class_exists(ClassStub::class)) { 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; $this->dataExtractor = $dataExtractor;

View File

@ -163,7 +163,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface
public function getElement(int $index) public function getElement(int $index)
{ {
if (!isset($this->elements[$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]; return $this->elements[$index];
@ -175,7 +175,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface
public function isProperty(int $index) public function isProperty(int $index)
{ {
if (!isset($this->isIndex[$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]; return !$this->isIndex[$index];
@ -187,7 +187,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface
public function isIndex(int $index) public function isIndex(int $index)
{ {
if (!isset($this->isIndex[$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]; return $this->isIndex[$index];
@ -210,7 +210,7 @@ class ViolationPath implements \IteratorAggregate, PropertyPathInterface
public function mapsForm(int $index) public function mapsForm(int $index)
{ {
if (!isset($this->mapsForm[$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]; return $this->mapsForm[$index];

View File

@ -1055,7 +1055,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
$value = $transformer->transform($value); $value = $transformer->transform($value);
} }
} catch (TransformationFailedException $exception) { } 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; return $value;
@ -1077,7 +1077,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
$value = $transformers[$i]->reverseTransform($value); $value = $transformers[$i]->reverseTransform($value);
} }
} catch (TransformationFailedException $exception) { } 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; return $value;
@ -1106,7 +1106,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
$value = $transformer->transform($value); $value = $transformer->transform($value);
} }
} catch (TransformationFailedException $exception) { } 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; return $value;
@ -1130,7 +1130,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
$value = $transformers[$i]->reverseTransform($value); $value = $transformers[$i]->reverseTransform($value);
} }
} catch (TransformationFailedException $exception) { } 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; return $value;

View File

@ -31,7 +31,7 @@ trait ValidatorExtensionTrait
} }
if (!$this instanceof TypeTestCase) { 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(); $this->validator = $this->getMockBuilder(ValidatorInterface::class)->getMock();

View File

@ -114,7 +114,7 @@ class CachingHttpClient implements HttpClientInterface
if ($responses instanceof ResponseInterface) { if ($responses instanceof ResponseInterface) {
$responses = [$responses]; $responses = [$responses];
} elseif (!is_iterable($responses)) { } elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of 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 = []; $mockResponses = [];

View File

@ -156,14 +156,14 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
if (\is_array($options['auth_ntlm'])) { if (\is_array($options['auth_ntlm'])) {
$count = \count($options['auth_ntlm']); $count = \count($options['auth_ntlm']);
if ($count <= 0 || $count > 2) { 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']); $options['auth_ntlm'] = implode(':', $options['auth_ntlm']);
} }
if (!\is_string($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']; $curlopts[CURLOPT_USERPWD] = $options['auth_ntlm'];
@ -319,7 +319,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
if ($responses instanceof CurlResponse) { if ($responses instanceof CurlResponse) {
$responses = [$responses]; $responses = [$responses];
} elseif (!is_iterable($responses)) { } elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of 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; $active = 0;
@ -439,7 +439,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
{ {
if (!$eof && \strlen($buffer) < $length) { if (!$eof && \strlen($buffer) < $length) {
if (!\is_string($data = $body($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; $buffer .= $data;

View File

@ -48,7 +48,7 @@ trait HttpClientTrait
$options['buffer'] = static function (array $headers) use ($buffer) { $options['buffer'] = static function (array $headers) use ($buffer) {
if (!\is_bool($buffer = $buffer($headers))) { if (!\is_bool($buffer = $buffer($headers))) {
if (!\is_array($bufferInfo = @stream_get_meta_data($buffer))) { 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+')) { if (false === strpbrk($bufferInfo['mode'], 'acew+')) {
@ -60,7 +60,7 @@ trait HttpClientTrait
}; };
} elseif (!\is_bool($buffer)) { } elseif (!\is_bool($buffer)) {
if (!\is_array($bufferInfo = @stream_get_meta_data($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+')) { if (false === strpbrk($bufferInfo['mode'], 'acew+')) {
@ -94,24 +94,24 @@ trait HttpClientTrait
// Validate on_progress // Validate on_progress
if (!\is_callable($onProgress = $options['on_progress'] ?? 'var_dump')) { 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)) { if (\is_array($options['auth_basic'] ?? null)) {
$count = \count($options['auth_basic']); $count = \count($options['auth_basic']);
if ($count <= 0 || $count > 2) { 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']); $options['auth_basic'] = implode(':', $options['auth_basic']);
} }
if (!\is_string($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']))) { 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'])) { if (isset($options['auth_basic'], $options['auth_bearer'])) {
@ -206,10 +206,10 @@ trait HttpClientTrait
} }
if ('auth_ntlm' === $name) { 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; return $options;
@ -231,13 +231,13 @@ trait HttpClientTrait
if (\is_int($name)) { if (\is_int($name)) {
if (!\is_string($values)) { 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); [$name, $values] = explode(':', $values, 2);
$values = [ltrim($values)]; $values = [ltrim($values)];
} elseif (!is_iterable($values)) { } elseif (!is_iterable($values)) {
if (\is_object($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; $values = (array) $values;
@ -299,7 +299,7 @@ trait HttpClientTrait
} }
if (!\is_string($body) && !\is_array(@stream_get_meta_data($body))) { if (!\is_string($body) && !\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; return $body;
@ -325,7 +325,7 @@ trait HttpClientTrait
$fingerprint[$algo] = 'pin-sha256' === $algo ? (array) $hash : str_replace(':', '', $hash); $fingerprint[$algo] = 'pin-sha256' === $algo ? (array) $hash : str_replace(':', '', $hash);
} }
} else { } 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; return $fingerprint;

View File

@ -184,7 +184,7 @@ final class HttplugClient implements HttplugInterface, HttpAsyncClient, RequestF
} elseif (\is_resource($body)) { } elseif (\is_resource($body)) {
$stream = $this->streamFactory->createStreamFromResource($body); $stream = $this->streamFactory->createStreamFromResource($body);
} else { } 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()) { if ($stream->isSeekable()) {

View File

@ -79,7 +79,7 @@ class MockHttpClient implements HttpClientInterface
if ($responses instanceof ResponseInterface) { if ($responses instanceof ResponseInterface) {
$responses = [$responses]; $responses = [$responses];
} elseif (!is_iterable($responses)) { } elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of 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)); return new ResponseStream(MockResponse::stream($responses, $timeout));

View File

@ -238,7 +238,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
if ($responses instanceof NativeResponse) { if ($responses instanceof NativeResponse) {
$responses = [$responses]; $responses = [$responses];
} elseif (!is_iterable($responses)) { } elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of 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)); return new ResponseStream(NativeResponse::stream($responses, $timeout));
@ -258,7 +258,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
while ('' !== $data = $body(self::$CHUNK_SIZE)) { while ('' !== $data = $body(self::$CHUNK_SIZE)) {
if (!\is_string($data)) { if (!\is_string($data)) {
throw new TransportException(sprintf('Return value of the "body" option callback must be string, %s returned.', \gettype($data))); throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', \gettype($data)));
} }
$result .= $data; $result .= $data;

View File

@ -228,7 +228,7 @@ class MockResponse implements ResponseInterface
} elseif ($body instanceof \Closure) { } elseif ($body instanceof \Closure) {
while ('' !== $data = $body(16372)) { while ('' !== $data = $body(16372)) {
if (!\is_string($data)) { if (!\is_string($data)) {
throw new TransportException(sprintf('Return value of the "body" option callback must be string, %s returned.', \gettype($data))); throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', \gettype($data)));
} }
// "notify" upload progress // "notify" upload progress
@ -295,7 +295,7 @@ class MockResponse implements ResponseInterface
$onProgress($offset, $dlSize, $response->info); $onProgress($offset, $dlSize, $response->info);
if ($dlSize && $offset !== $dlSize) { 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));
} }
} }
} }

View File

@ -161,7 +161,7 @@ trait ResponseTrait
} }
if (!\is_array($content)) { 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) { if (null !== $this->content) {

View File

@ -179,7 +179,7 @@ class HttpClientTraitTest extends TestCase
public function testInvalidAuthBearerOption() public function testInvalidAuthBearerOption()
{ {
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); $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); self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS);
} }
@ -249,7 +249,7 @@ class HttpClientTraitTest extends TestCase
public function testNormalizePeerFingerprintTypeException() public function testNormalizePeerFingerprintTypeException()
{ {
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException'); $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(); $fingerprint = new \stdClass();
$this->normalizePeerFingerprint($fingerprint); $this->normalizePeerFingerprint($fingerprint);

View File

@ -56,13 +56,13 @@ class MockResponseTest extends TestCase
yield [ yield [
'content' => '"not an array"', 'content' => '"not an array"',
'responseHeaders' => [], '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 [ yield [
'content' => '8', 'content' => '8',
'responseHeaders' => [], '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".',
]; ];
} }
} }

View File

@ -199,7 +199,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
} }
if (false === $date = \DateTime::createFromFormat(DATE_RFC2822, $value)) { 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; return $date;

View File

@ -54,7 +54,7 @@ class RedisSessionHandler extends AbstractSessionHandler
!$redis instanceof RedisProxy && !$redis instanceof RedisProxy &&
!$redis instanceof RedisClusterProxy !$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'])) { if ($diff = array_diff(array_keys($options), ['prefix', 'ttl'])) {

View File

@ -27,7 +27,7 @@ class SessionHandlerFactory
public static function createHandler($connection): AbstractSessionHandler public static function createHandler($connection): AbstractSessionHandler
{ {
if (!\is_string($connection) && !\is_object($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) { switch (true) {
@ -46,7 +46,7 @@ class SessionHandlerFactory
return new PdoSessionHandler($connection); return new PdoSessionHandler($connection);
case !\is_string($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://'): case 0 === strpos($connection, 'file://'):
return new StrictSessionHandler(new NativeFileSessionHandler(substr($connection, 7))); return new StrictSessionHandler(new NativeFileSessionHandler(substr($connection, 7)));
@ -80,6 +80,6 @@ class SessionHandlerFactory
return new PdoSessionHandler($connection); return new PdoSessionHandler($connection);
} }
throw new \InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection)); throw new \InvalidArgumentException(sprintf('Unsupported Connection: "%s".', $connection));
} }
} }

View File

@ -186,7 +186,7 @@ class MockArraySessionStorage implements SessionStorageInterface
public function getBag(string $name) public function getBag(string $name)
{ {
if (!isset($this->bags[$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) { if (!$this->started) {

View File

@ -311,7 +311,7 @@ class NativeSessionStorage implements SessionStorageInterface
public function getBag(string $name) public function getBag(string $name)
{ {
if (!isset($this->bags[$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()) { if (!$this->started && $this->saveHandler->isActive()) {

View File

@ -69,7 +69,7 @@ abstract class Bundle implements BundleInterface
if (null !== $extension) { if (null !== $extension) {
if (!$extension instanceof ExtensionInterface) { 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 // check naming convention

View File

@ -31,7 +31,7 @@ class Psr6CacheClearer implements CacheClearerInterface
public function getPool(string $name) public function getPool(string $name)
{ {
if (!$this->hasPool($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]; return $this->pools[$name];
@ -40,7 +40,7 @@ class Psr6CacheClearer implements CacheClearerInterface
public function clearPool(string $name) public function clearPool(string $name)
{ {
if (!isset($this->pools[$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(); return $this->pools[$name]->clear();

View File

@ -99,7 +99,7 @@ class ArgumentMetadata
public function getDefaultValue() public function getDefaultValue()
{ {
if (!$this->hasDefaultValue) { 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; return $this->defaultValue;

View File

@ -193,7 +193,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
$dumper = new HtmlDumper($data, $this->charset); $dumper = new HtmlDumper($data, $this->charset);
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
} else { } else {
throw new \InvalidArgumentException(sprintf('Invalid dump format: %s.', $format)); throw new \InvalidArgumentException(sprintf('Invalid dump format: "%s".', $format));
} }
$dumps = []; $dumps = [];

View File

@ -97,7 +97,7 @@ class FragmentHandler
protected function deliver(Response $response) protected function deliver(Response $response)
{ {
if (!$response->isSuccessful()) { 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) { if (!$response instanceof StreamedResponse) {

View File

@ -96,7 +96,7 @@ abstract class AbstractSurrogate implements SurrogateInterface
$response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
if (!$response->isSuccessful()) { 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(); return $response->getContent();

View File

@ -221,7 +221,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$class = static::class; $class = static::class;
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class; $class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($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]; 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) { foreach (['cache' => $this->warmupDir ?: $this->getCacheDir(), 'logs' => $this->getLogDir()] as $name => $dir) {
if (!is_dir($dir)) { if (!is_dir($dir)) {
if (false === @mkdir($dir, 0777, true) && !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)) { } 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));
} }
} }

View File

@ -40,7 +40,7 @@ class Psr6CacheClearerTest extends TestCase
public function testClearPoolThrowsExceptionOnUnreferencedPool() public function testClearPoolThrowsExceptionOnUnreferencedPool()
{ {
$this->expectException('InvalidArgumentException'); $this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Cache pool not found: unknown'); $this->expectExceptionMessage('Cache pool not found: "unknown"');
(new Psr6CacheClearer())->clearPool('unknown'); (new Psr6CacheClearer())->clearPool('unknown');
} }
} }

View File

@ -55,7 +55,7 @@ class GenrbCompiler implements BundleCompilerInterface
exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status); exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status);
if (0 !== $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));
} }
} }
} }

View File

@ -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; return $array;

View File

@ -105,7 +105,7 @@ class TimezoneTransformer extends Transformer
$signal = '-' === $matches['signal'] ? '+' : '-'; $signal = '-' === $matches['signal'] ? '+' : '-';
if (0 < $minutes) { 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 : ''); return 'Etc/GMT'.(0 !== $hours ? $signal.$hours : '');

View File

@ -360,7 +360,7 @@ abstract class NumberFormatter
} }
if (self::CURRENCY === $this->style) { 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. // Only the default type is supported.

View File

@ -75,7 +75,7 @@ final class Ldap implements LdapInterface
public static function create(string $adapter, array $config = []): self public static function create(string $adapter, array $config = []): self
{ {
if (!isset(self::$adapterMap[$adapter])) { 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]; $class = self::$adapterMap[$adapter];

View File

@ -38,11 +38,11 @@ class RedisStore implements PersistingStoreInterface
public function __construct($redisClient, float $initialTtl = 300.0) 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) { 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) { 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; $this->redis = $redisClient;
@ -141,7 +141,7 @@ class RedisStore implements PersistingStoreInterface
return $this->redis->eval(...array_merge([$script, 1, $resource], $args)); 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 private function getUniqueToken(Key $key): string

View File

@ -33,7 +33,7 @@ class StoreFactory
public static function createStore($connection) public static function createStore($connection)
{ {
if (!\is_string($connection) && !\is_object($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) { switch (true) {
@ -56,7 +56,7 @@ class StoreFactory
return new ZookeeperStore($connection); return new ZookeeperStore($connection);
case !\is_string($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: case 'flock' === $connection:
return new FlockStore(); return new FlockStore();
@ -95,6 +95,6 @@ class StoreFactory
return new ZookeeperStore(ZookeeperStore::createConnection($connection)); return new ZookeeperStore(ZookeeperStore::createConnection($connection));
} }
throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection)); throw new InvalidArgumentException(sprintf('Unsupported Connection: "%s".', $connection));
} }
} }

View File

@ -37,11 +37,11 @@ class ZookeeperStore implements PersistingStoreInterface
public static function createConnection(string $dsn): \Zookeeper public static function createConnection(string $dsn): \Zookeeper
{ {
if (0 !== strpos($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)) { 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'] ?? ''; $host = $params['host'] ?? '';

View File

@ -74,7 +74,7 @@ class TransportTest extends TestCase
public function fromWrongStringProvider(): iterable 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.']; yield 'not a valid DSN' => ['something not a dsn', 'The "something" mailer DSN must contain a scheme.'];

View File

@ -85,7 +85,7 @@ class Transport
{ {
list($transport, $offset) = $this->parseDsn($dsn); list($transport, $offset) = $this->parseDsn($dsn);
if ($offset !== \strlen($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; return $transport;

View File

@ -42,7 +42,7 @@ class DebugCommand extends Command
protected function configure() protected function configure()
{ {
$this $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') ->setDescription('Lists messages you can dispatch using the message buses')
->setHelp(<<<'EOF' ->setHelp(<<<'EOF'
The <info>%command.name%</info> command displays all messages that can be The <info>%command.name%</info> command displays all messages that can be
@ -70,7 +70,7 @@ EOF
$mapping = $this->mapping; $mapping = $this->mapping;
if ($bus = $input->getArgument('bus')) { if ($bus = $input->getArgument('bus')) {
if (!isset($mapping[$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]]; $mapping = [$bus => $mapping[$bus]];
} }

View File

@ -75,7 +75,7 @@ class MessengerPass implements CompilerPassInterface
foreach ($container->findTaggedServiceIds($this->handlerTag, true) as $serviceId => $tags) { foreach ($container->findTaggedServiceIds($this->handlerTag, true) as $serviceId => $tags) {
foreach ($tags as $tag) { foreach ($tags as $tag) {
if (isset($tag['bus']) && !\in_array($tag['bus'], $busIds, true)) { 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 = $container->getDefinition($serviceId)->getClass(); $className = $container->getDefinition($serviceId)->getClass();

View File

@ -30,7 +30,7 @@ final class Envelope
public function __construct($message, array $stamps = []) public function __construct($message, array $stamps = [])
{ {
if (!\is_object($message)) { 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; $this->message = $message;

View File

@ -62,7 +62,7 @@ class MessageBus implements MessageBusInterface
public function dispatch($message, array $stamps = []): Envelope public function dispatch($message, array $stamps = []): Envelope
{ {
if (!\is_object($message)) { 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); $envelope = Envelope::wrap($message, $stamps);
$middlewareIterator = $this->middlewareAggregate->getIterator(); $middlewareIterator = $this->middlewareAggregate->getIterator();

View File

@ -37,7 +37,7 @@ class StackMiddleware implements MiddlewareInterface, StackInterface
} elseif ($middlewareIterator instanceof MiddlewareInterface) { } elseif ($middlewareIterator instanceof MiddlewareInterface) {
$this->stack->stack[] = $middlewareIterator; $this->stack->stack[] = $middlewareIterator;
} elseif (!is_iterable($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 { } else {
$this->stack->iterator = (function () use ($middlewareIterator) { $this->stack->iterator = (function () use ($middlewareIterator) {
yield from $middlewareIterator; yield from $middlewareIterator;

View File

@ -142,7 +142,7 @@ TXT
public function testExceptionOnUnknownBusArgument() public function testExceptionOnUnknownBusArgument()
{ {
$this->expectException('Symfony\Component\Console\Exception\RuntimeException'); $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' => []]); $command = new DebugCommand(['command_bus' => [], 'query_bus' => []]);
$tester = new CommandTester($command); $tester = new CommandTester($command);

Some files were not shown because too many files have changed in this diff Show More