Skip to content

Commit

Permalink
minor #36081 Add missing dots at the end of exception messages (fabpot)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

Add missing dots at the end of exception messages

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

Commits
-------

6dad402 Add missing dots at the end of exception messages
  • Loading branch information
fabpot committed Mar 15, 2020
2 parents cc8d23a + 6dad402 commit 3543bf6
Show file tree
Hide file tree
Showing 43 changed files with 73 additions and 73 deletions.
Expand Up @@ -32,10 +32,10 @@ public function __construct(RequestStack $requestStack, array $exclusions, $acti
{
foreach ($exclusions as $exclusion) {
if (!\array_key_exists('code', $exclusion)) {
throw new \LogicException(sprintf('An exclusion must have a "code" key'));
throw new \LogicException(sprintf('An exclusion must have a "code" key.'));
}
if (!\array_key_exists('urls', $exclusion)) {
throw new \LogicException(sprintf('An exclusion must have a "urls" key'));
throw new \LogicException(sprintf('An exclusion must have a "urls" key.'));
}
}

Expand Down
Expand Up @@ -48,10 +48,10 @@ private function __construct(array $thresholds = [], $regex = '', $verboseOutput

foreach ($thresholds as $group => $threshold) {
if (!\in_array($group, $groups, true)) {
throw new \InvalidArgumentException(sprintf('Unrecognized threshold "%s", expected one of "%s"', $group, implode('", "', $groups)));
throw new \InvalidArgumentException(sprintf('Unrecognized threshold "%s", expected one of "%s".', $group, implode('", "', $groups)));
}
if (!is_numeric($threshold)) {
throw new \InvalidArgumentException(sprintf('Threshold for group "%s" has invalid value "%s"', $group, $threshold));
throw new \InvalidArgumentException(sprintf('Threshold for group "%s" has invalid value "%s".', $group, $threshold));
}
$this->thresholds[$group] = (int) $threshold;
}
Expand Down Expand Up @@ -146,7 +146,7 @@ public static function fromUrlEncodedString($serializedConfiguration)
parse_str($serializedConfiguration, $normalizedConfiguration);
foreach (array_keys($normalizedConfiguration) as $key) {
if (!\in_array($key, ['max', 'disabled', 'verbose'], true)) {
throw new \InvalidArgumentException(sprintf('Unknown configuration option "%s"', $key));
throw new \InvalidArgumentException(sprintf('Unknown configuration option "%s".', $key));
}
}

Expand Down
Expand Up @@ -109,7 +109,7 @@ public function originatesFromAnObject()
public function originatingClass()
{
if (null === $this->originClass) {
throw new \LogicException('Check with originatesFromAnObject() before calling this method');
throw new \LogicException('Check with originatesFromAnObject() before calling this method.');
}

return $this->originClass;
Expand All @@ -121,7 +121,7 @@ public function originatingClass()
public function originatingMethod()
{
if (null === $this->originMethod) {
throw new \LogicException('Check with originatesFromAnObject() before calling this method');
throw new \LogicException('Check with originatesFromAnObject() before calling this method.');
}

return $this->originMethod;
Expand Down Expand Up @@ -237,7 +237,7 @@ private function getPackage($path)
$relativePath = substr($path, \strlen($vendorRoot) + 1);
$vendor = strstr($relativePath, \DIRECTORY_SEPARATOR, true);
if (false === $vendor) {
throw new \RuntimeException(sprintf('Could not find directory separator "%s" in path "%s"', \DIRECTORY_SEPARATOR, $relativePath));
throw new \RuntimeException(sprintf('Could not find directory separator "%s" in path "%s".', \DIRECTORY_SEPARATOR, $relativePath));
}

return rtrim($vendor.'/'.strstr(substr(
Expand All @@ -247,7 +247,7 @@ private function getPackage($path)
}
}

throw new \RuntimeException(sprintf('No vendors found for path "%s"', $path));
throw new \RuntimeException(sprintf('No vendors found for path "%s".', $path));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Command/DebugCommand.php
Expand Up @@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$filter = $input->getOption('filter');

if (null !== $name && [] === $this->getFilesystemLoaders()) {
throw new InvalidArgumentException(sprintf('Argument "name" not supported, it requires the Twig loader "%s"', FilesystemLoader::class));
throw new InvalidArgumentException(sprintf('Argument "name" not supported, it requires the Twig loader "%s".', FilesystemLoader::class));
}

switch ($input->getOption('format')) {
Expand Down
Expand Up @@ -65,7 +65,7 @@ public function setContainer(ContainerInterface $container): ?ContainerInterface
protected function getParameter(string $name)
{
if (!$this->container->has('parameter_bag')) {
throw new ServiceNotFoundException('parameter_bag', null, null, [], sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', static::class));
throw new ServiceNotFoundException('parameter_bag.', null, null, [], sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', static::class));
}

return $this->container->get('parameter_bag')->get($name);
Expand Down
Expand Up @@ -49,7 +49,7 @@ public function resolveControllerName(...$args)
public function __call(string $method, array $args)
{
if ('onKernelRequest' !== $method && 'onKernelRequest' !== strtolower($method)) {
throw new \Error(sprintf('Error: Call to undefined method %s::%s()', static::class, $method));
throw new \Error(sprintf('Error: Call to undefined method %s::%s().', static::class, $method));
}

$event = $args[0];
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/Secrets/SodiumVault.php
Expand Up @@ -177,7 +177,7 @@ public function loadEnvVars(): array
private function loadKeys(): void
{
if (!\function_exists('sodium_crypto_box_seal')) {
throw new \LogicException('The "sodium" PHP extension is required to deal with secrets. Alternatively, try running "composer require paragonie/sodium_compat" if you cannot enable the extension."');
throw new \LogicException('The "sodium" PHP extension is required to deal with secrets. Alternatively, try running "composer require paragonie/sodium_compat" if you cannot enable the extension.".');
}

if (null !== $this->encryptionKey || '' !== $this->decryptionKey = (string) $this->decryptionKey) {
Expand Down Expand Up @@ -214,7 +214,7 @@ private function export(string $file, string $data): void
private function createSecretsDir(): void
{
if ($this->secretsDir && !is_dir($this->secretsDir) && !@mkdir($this->secretsDir, 0777, true) && !is_dir($this->secretsDir)) {
throw new \RuntimeException(sprintf('Unable to create the secrets directory (%s)', $this->secretsDir));
throw new \RuntimeException(sprintf('Unable to create the secrets directory (%s).', $this->secretsDir));
}

$this->secretsDir = null;
Expand Down
Expand Up @@ -41,7 +41,7 @@ protected function __construct(string $namespace = '', int $defaultLifetime = 0)
{
$this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':';
if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) {
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace));
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s").', $this->maxIdLength - 24, \strlen($namespace), $namespace));
}
$this->createCacheItem = \Closure::bind(
static function ($key, $value, $isHit) use ($defaultLifetime) {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Cache/CacheItem.php
Expand Up @@ -130,7 +130,7 @@ public function tag($tags): ItemInterface
throw new InvalidArgumentException('Cache tag length must be greater than zero.');
}
if (false !== strpbrk($tag, self::RESERVED_CHARACTERS)) {
throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters %s', $tag, self::RESERVED_CHARACTERS));
throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters %s.', $tag, self::RESERVED_CHARACTERS));
}
$this->newMetadata[self::METADATA_TAGS][$tag] = $tag;
}
Expand Down Expand Up @@ -174,7 +174,7 @@ public static function validateKey($key): string
throw new InvalidArgumentException('Cache key length must be greater than zero.');
}
if (false !== strpbrk($key, self::RESERVED_CHARACTERS)) {
throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters %s', $key, self::RESERVED_CHARACTERS));
throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters %s.', $key, self::RESERVED_CHARACTERS));
}

return $key;
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Cache/Psr16Cache.php
Expand Up @@ -144,7 +144,7 @@ public function getMultiple($keys, $default = null)
if ($keys instanceof \Traversable) {
$keys = iterator_to_array($keys, false);
} elseif (!\is_array($keys)) {
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given.', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
}

try {
Expand Down Expand Up @@ -193,7 +193,7 @@ public function setMultiple($values, $ttl = null)
{
$valuesIsArray = \is_array($values);
if (!$valuesIsArray && !$values instanceof \Traversable) {
throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values)));
throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given.', \is_object($values) ? \get_class($values) : \gettype($values)));
}
$items = [];

Expand Down Expand Up @@ -247,7 +247,7 @@ public function deleteMultiple($keys)
if ($keys instanceof \Traversable) {
$keys = iterator_to_array($keys, false);
} elseif (!\is_array($keys)) {
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given.', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/MemcachedTrait.php
Expand Up @@ -117,7 +117,7 @@ public static function createConnection($servers, array $options = [])

if (isset($query['host'])) {
if (!\is_array($hosts = $query['host'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s.', $dsn));
}
foreach ($hosts as $host => $weight) {
if (false === $port = strrpos($host, ':')) {
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/Cache/Traits/RedisTrait.php
Expand Up @@ -97,7 +97,7 @@ public static function createConnection($dsn, array $options = [])
}

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) {
Expand All @@ -119,7 +119,7 @@ public static function createConnection($dsn, array $options = [])

if (isset($query['host'])) {
if (!\is_array($hosts = $query['host'])) {
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s', $dsn));
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s.', $dsn));
}
foreach ($hosts as $host => $parameters) {
if (\is_string($parameters)) {
Expand Down Expand Up @@ -151,11 +151,11 @@ public static function createConnection($dsn, array $options = [])
}

if (!$hosts) {
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s', $dsn));
throw new InvalidArgumentException(sprintf('Invalid Redis DSN: %s.', $dsn));
}

if (isset($params['redis_sentinel']) && !class_exists(\Predis\Client::class)) {
throw new CacheException(sprintf('Redis Sentinel support requires the "predis/predis" package: %s', $dsn));
throw new CacheException(sprintf('Redis Sentinel support requires the "predis/predis" package: %s.', $dsn));
}

$params += $query + $options + self::$defaultConnectionOptions;
Expand Down Expand Up @@ -215,7 +215,7 @@ public static function createConnection($dsn, array $options = [])
try {
$redis = new $class($hosts, $params);
} catch (\RedisClusterException $e) {
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e->getMessage(), $dsn));
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s.', $e->getMessage(), $dsn));
}

if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
Expand All @@ -230,7 +230,7 @@ public static function createConnection($dsn, array $options = [])
try {
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']);
} catch (\RedisClusterException $e) {
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s', $e->getMessage(), $dsn));
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): %s.', $e->getMessage(), $dsn));
}

if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
Expand All @@ -250,7 +250,7 @@ public static function createConnection($dsn, array $options = [])
if ($params['redis_cluster']) {
$params['cluster'] = 'redis';
if (isset($params['redis_sentinel'])) {
throw new InvalidArgumentException(sprintf('Cannot use both "redis_cluster" and "redis_sentinel" at the same time: %s', $dsn));
throw new InvalidArgumentException(sprintf('Cannot use both "redis_cluster" and "redis_sentinel" at the same time: %s.', $dsn));
}
} elseif (isset($params['redis_sentinel'])) {
$params['replication'] = 'sentinel';
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Definition/BaseNode.php
Expand Up @@ -48,7 +48,7 @@ abstract class BaseNode implements NodeInterface
public function __construct(?string $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)
{
if (false !== strpos($name = (string) $name, $pathSeparator)) {
throw new \InvalidArgumentException('The name must not contain "'.$pathSeparator.'".');
throw new \InvalidArgumentException('The name must not contain ".'.$pathSeparator.'".');
}

$this->name = $name;
Expand Down
Expand Up @@ -472,7 +472,7 @@ protected function validateConcreteNode(ArrayNode $node)
}

if (false === $this->allowEmptyValue) {
throw new InvalidDefinitionException(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s"', $path));
throw new InvalidDefinitionException(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s".', $path));
}

if (true === $this->atLeastOne) {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Application.php
Expand Up @@ -599,7 +599,7 @@ public function findNamespace($namespace)

$exact = \in_array($namespace, $namespaces, true);
if (\count($namespaces) > 1 && !$exact) {
throw new NamespaceNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
throw new NamespaceNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
}

return $exact ? $namespace : reset($namespaces);
Expand Down Expand Up @@ -707,7 +707,7 @@ public function find($name)
if (\count($commands) > 1) {
$suggestions = $this->getAbbreviationSuggestions(array_filter($abbrevs));

throw new CommandNotFoundException(sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $name, $suggestions), array_values($commands));
throw new CommandNotFoundException(sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), array_values($commands));
}
}

Expand Down
Expand Up @@ -241,7 +241,7 @@ public function getEnv($prefix, $name, \Closure $getEnv)
$parsedEnv = parse_url($env);

if (false === $parsedEnv) {
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'])) {
throw new RuntimeException(sprintf('Invalid URL env var "%s": schema and host expected, %s given.', $name, $env));
Expand Down
Expand Up @@ -690,7 +690,7 @@ protected function loadFile($file)
try {
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
} catch (ParseException $e) {
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s', $file, $e->getMessage()), 0, $e);
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s.', $file, $e->getMessage()), 0, $e);
}

return $this->validate($configuration, $file);
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/ErrorHandler/ErrorHandler.php
Expand Up @@ -246,14 +246,14 @@ public function setLoggers(array $loggers): array
if (!\is_array($log)) {
$log = [$log];
} elseif (!\array_key_exists(0, $log)) {
throw new \InvalidArgumentException('No logger provided');
throw new \InvalidArgumentException('No logger provided.');
}
if (null === $log[0]) {
$this->loggedErrors &= ~$type;
} elseif ($log[0] instanceof LoggerInterface) {
$this->loggedErrors |= $type;
} else {
throw new \InvalidArgumentException('Invalid logger provided');
throw new \InvalidArgumentException('Invalid logger provided.');
}
$this->loggers[$type] = $log + $prev[$type];

Expand Down
Expand Up @@ -35,7 +35,7 @@ public function __construct(string $trueValue, array $falseValues = [null])
$this->trueValue = $trueValue;
$this->falseValues = $falseValues;
if (\in_array($this->trueValue, $this->falseValues, true)) {
throw new InvalidArgumentException('The specified "true" value is contained in the false-values');
throw new InvalidArgumentException('The specified "true" value is contained in the false-values.');
}
}

Expand Down

0 comments on commit 3543bf6

Please sign in to comment.