Skip to content

Commit 587ba07

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Fix quotes in exception messages Fix quotes in exception messages Fix quotes in exception messages
2 parents 31ac82b + 25e13ee commit 587ba07

18 files changed

+55
-55
lines changed

Argument/ReferenceSetArgumentTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function setValues(array $values)
4545
{
4646
foreach ($values as $k => $v) {
4747
if (null !== $v && !$v instanceof Reference) {
48-
throw new InvalidArgumentException(sprintf('A %s must hold only Reference instances, "%s" given.', __CLASS__, \is_object($v) ? \get_class($v) : \gettype($v)));
48+
throw new InvalidArgumentException(sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, \is_object($v) ? \get_class($v) : \gettype($v)));
4949
}
5050
}
5151

Compiler/AbstractRecursivePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private function getExpressionLanguage(): ExpressionLanguage
209209
$arg = $this->processValue(new Reference($id));
210210
$this->inExpression = false;
211211
if (!$arg instanceof Reference) {
212-
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));
212+
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));
213213
}
214214
$arg = sprintf('"%s"', $arg);
215215
}

Compiler/PriorityTaggedServiceTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static function getDefaultIndex(ContainerBuilder $container, string $serv
125125
$defaultIndex = $rm->invoke(null);
126126

127127
if (!\is_string($defaultIndex)) {
128-
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));
128+
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));
129129
}
130130

131131
return $defaultIndex;
@@ -154,7 +154,7 @@ public static function getDefaultPriority(ContainerBuilder $container, string $s
154154
$defaultPriority = $rm->invoke(null);
155155

156156
if (!\is_int($defaultPriority)) {
157-
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));
157+
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));
158158
}
159159

160160
return $defaultPriority;

Compiler/ResolveBindingsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function processValue($value, bool $isRoot = false)
134134
}
135135

136136
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition && !$bindingValue instanceof TaggedIteratorArgument && !$bindingValue instanceof ServiceLocatorArgument) {
137-
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)));
137+
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)));
138138
}
139139
}
140140

Compiler/ResolveNamedArgumentsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function processValue($value, bool $isRoot = false)
7676
}
7777

7878
if (null !== $argument && !$argument instanceof Reference && !$argument instanceof Definition) {
79-
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)));
79+
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)));
8080
}
8181

8282
$typeFound = false;

ContainerBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ public function resolveEnvPlaceholders($value, $format = null, array &$usedEnvs
13871387
$completed = true;
13881388
} else {
13891389
if (!\is_string($resolved) && !is_numeric($resolved)) {
1390-
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)));
1390+
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)));
13911391
}
13921392
$value = str_ireplace($placeholder, $resolved, $value);
13931393
}

Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ private function addDefaultParametersMethod(): string
13761376

13771377
foreach ($this->container->getParameterBag()->all() as $key => $value) {
13781378
if ($key !== $resolvedKey = $this->container->resolveEnvPlaceholders($key)) {
1379-
throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: %s.', $resolvedKey));
1379+
throw new InvalidArgumentException(sprintf('Parameter name cannot use env parameters: "%s".', $resolvedKey));
13801380
}
13811381
$export = $this->exportParameters([$value]);
13821382
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);

EnvVarProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv)
184184
}
185185

186186
if (!is_scalar($env)) {
187-
throw new RuntimeException(sprintf('Non-scalar env var "%s" cannot be cast to %s.', $name, $prefix));
187+
throw new RuntimeException(sprintf('Non-scalar env var "%s" cannot be cast to "%s".', $name, $prefix));
188188
}
189189

190190
if ('string' === $prefix) {
@@ -231,7 +231,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv)
231231
}
232232

233233
if (null !== $env && !\is_array($env)) {
234-
throw new RuntimeException(sprintf('Invalid JSON env var "%s": array or null expected, %s given.', $name, \gettype($env)));
234+
throw new RuntimeException(sprintf('Invalid JSON env var "%s": array or null expected, "%s" given.', $name, \gettype($env)));
235235
}
236236

237237
return $env;
@@ -244,7 +244,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv)
244244
throw new RuntimeException(sprintf('Invalid URL in env var "%s".', $name));
245245
}
246246
if (!isset($parsedEnv['scheme'], $parsedEnv['host'])) {
247-
throw new RuntimeException(sprintf('Invalid URL env var "%s": schema and host expected, %s given.', $name, $env));
247+
throw new RuntimeException(sprintf('Invalid URL env var "%s": schema and host expected, "%s" given.', $name, $env));
248248
}
249249
$parsedEnv += [
250250
'port' => null,

Loader/Configurator/AbstractConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __call(string $method, array $args)
3131
return $this->{'set'.$method}(...$args);
3232
}
3333

34-
throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s().', static::class, $method));
34+
throw new \BadMethodCallException(sprintf('Call to undefined method "%s::%s()".', static::class, $method));
3535
}
3636

3737
/**

Loader/Configurator/ContainerConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final public function extension(string $namespace, array $config)
4848
{
4949
if (!$this->container->hasExtension($namespace)) {
5050
$extensions = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions()));
51-
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'));
51+
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'));
5252
}
5353

5454
$this->container->loadFromExtension($namespace, static::processValue($config));

Loader/FileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ public function import($resource, $type = null, $ignoreErrors = false, $sourceRe
9090
public function registerClasses(Definition $prototype, $namespace, $resource, $exclude = null)
9191
{
9292
if ('\\' !== substr($namespace, -1)) {
93-
throw new InvalidArgumentException(sprintf('Namespace prefix must end with a "\\": %s.', $namespace));
93+
throw new InvalidArgumentException(sprintf('Namespace prefix must end with a "\\": "%s".', $namespace));
9494
}
9595
if (!preg_match('/^(?:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+\\\\)++$/', $namespace)) {
96-
throw new InvalidArgumentException(sprintf('Namespace is not a valid PSR-4 prefix: %s.', $namespace));
96+
throw new InvalidArgumentException(sprintf('Namespace is not a valid PSR-4 prefix: "%s".', $namespace));
9797
}
9898

9999
$classes = $this->findClasses($namespace, $resource, (array) $exclude);

Loader/XmlFileLoader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private function getServiceDefaults(\DOMDocument $xml, string $file): array
171171

172172
foreach ($defaults['tags'] as $tag) {
173173
if ('' === $tag->getAttribute('name')) {
174-
throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in %s must be a non-empty string.', $file));
174+
throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in "%s" must be a non-empty string.', $file));
175175
}
176176
}
177177

@@ -344,7 +344,7 @@ private function parseDefinition(\DOMElement $service, string $file, array $defa
344344
}
345345

346346
if ('' === $tag->getAttribute('name')) {
347-
throw new InvalidArgumentException(sprintf('The tag name for service "%s" in %s must be a non-empty string.', (string) $service->getAttribute('id'), $file));
347+
throw new InvalidArgumentException(sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', (string) $service->getAttribute('id'), $file));
348348
}
349349

350350
$definition->addTag($tag->getAttribute('name'), $parameters);
@@ -395,7 +395,7 @@ private function parseFileToDOM(string $file): \DOMDocument
395395
try {
396396
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
397397
} catch (\InvalidArgumentException $e) {
398-
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": %s.', $file, $e->getMessage()), $e->getCode(), $e);
398+
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": "%s".', $file, $e->getMessage()), $e->getCode(), $e);
399399
}
400400

401401
$this->validateExtensions($dom, $file);
@@ -437,7 +437,7 @@ private function processAnonymousServices(\DOMDocument $xml, string $file)
437437
// anonymous services "in the wild"
438438
if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) {
439439
foreach ($nodes as $node) {
440-
throw new InvalidArgumentException(sprintf('Top-level services must have "id" attribute, none found in %s at line %d.', $file, $node->getLineNo()));
440+
throw new InvalidArgumentException(sprintf('Top-level services must have "id" attribute, none found in "%s" at line %d.', $file, $node->getLineNo()));
441441
}
442442
}
443443

@@ -678,7 +678,7 @@ private function validateExtensions(\DOMDocument $dom, string $file)
678678
// can it be handled by an extension?
679679
if (!$this->container->hasExtension($node->namespaceURI)) {
680680
$extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getNamespace(); }, $this->container->getExtensions()));
681-
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'));
681+
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'));
682682
}
683683
}
684684
}

0 commit comments

Comments
 (0)