Skip to content

Commit 8421939

Browse files
Consistently throw exceptions on a single line
1 parent 1607759 commit 8421939

File tree

4 files changed

+4
-27
lines changed

4 files changed

+4
-27
lines changed

Compiler/CheckDefinitionValidityPass.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ public function process(ContainerBuilder $container)
6464
throw new RuntimeException(sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id));
6565
}
6666

67-
throw new RuntimeException(sprintf(
68-
'The definition for "%s" has no class. If you intend to inject '
69-
.'this service dynamically at runtime, please mark it as synthetic=true. '
70-
.'If this is an abstract definition solely used by child definitions, '
71-
.'please add abstract=true, otherwise specify a class to get rid of this error.',
72-
$id
73-
));
67+
throw new RuntimeException(sprintf('The definition for "%s" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.', $id));
7468
}
7569

7670
// tag attribute values must be scalars

Compiler/CheckReferenceValidityPass.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,7 @@ private function validateReferences(array $arguments)
9494
$targetDefinition = $this->getDefinition((string) $argument);
9595

9696
if (null !== $targetDefinition && $targetDefinition->isAbstract()) {
97-
throw new RuntimeException(sprintf(
98-
'The definition "%s" has a reference to an abstract definition "%s". '
99-
.'Abstract definitions cannot be the target of references.',
100-
$this->currentId,
101-
$argument
102-
));
97+
throw new RuntimeException(sprintf('The definition "%s" has a reference to an abstract definition "%s". Abstract definitions cannot be the target of references.', $this->currentId, $argument));
10398
}
10499

105100
$this->validateScope($argument, $targetDefinition);

Loader/XmlFileLoader.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,7 @@ private function validateExtensions(\DOMDocument $dom, $file)
543543
// can it be handled by an extension?
544544
if (!$this->container->hasExtension($node->namespaceURI)) {
545545
$extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getNamespace(); }, $this->container->getExtensions()));
546-
throw new InvalidArgumentException(sprintf(
547-
'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
548-
$node->tagName,
549-
$file,
550-
$node->namespaceURI,
551-
$extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none'
552-
));
546+
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'));
553547
}
554548
}
555549
}

Loader/YamlFileLoader.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,7 @@ private function validate($content, $file)
396396

397397
if (!$this->container->hasExtension($namespace)) {
398398
$extensionNamespaces = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions()));
399-
throw new InvalidArgumentException(sprintf(
400-
'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s',
401-
$namespace,
402-
$file,
403-
$namespace,
404-
$extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none'
405-
));
399+
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'));
406400
}
407401
}
408402

0 commit comments

Comments
 (0)