- }
-
- /**
- * Validates an array of References.
- *
- * @param array $arguments An array of Reference objects
- *
- * @throws RuntimeException when there is a reference to an abstract definition.
- */
- private function validateReferences(array $arguments)
- {
- foreach ($arguments as $argument) {
- if (is_array($argument)) {
- $this->validateReferences($argument);
- } elseif ($argument instanceof Reference) {
- $targetDefinition = $this->getDefinition((string) $argument);
-
- if (null !== $targetDefinition && $targetDefinition->isAbstract()) {
- 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
- ));
- }
+ if ($value instanceof Reference && $this->container->hasDefinition((string) $value)) {
+ $targetDefinition = $this->container->getDefinition((string) $value);
+
+ if ($targetDefinition->isAbstract()) {
+ 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,
+ $value
+ ));