You are here

private function ResolveInvalidReferencesPass::processArguments in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php \Symfony\Component\DependencyInjection\Compiler\ResolveInvalidReferencesPass::processArguments()

Processes arguments to determine invalid references.

Parameters

array $arguments An array of Reference objects:

bool $inMethodCall:

Return value

array

Throws

RuntimeException When the config is invalid

1 call to ResolveInvalidReferencesPass::processArguments()
ResolveInvalidReferencesPass::process in vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php
Process the ContainerBuilder to resolve invalid references.

File

vendor/symfony/dependency-injection/Compiler/ResolveInvalidReferencesPass.php, line 79

Class

ResolveInvalidReferencesPass
Emulates the invalid behavior if the reference is not found within the container.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

private function processArguments(array $arguments, $inMethodCall = false) {
  foreach ($arguments as $k => $argument) {
    if (is_array($argument)) {
      $arguments[$k] = $this
        ->processArguments($argument, $inMethodCall);
    }
    elseif ($argument instanceof Reference) {
      $id = (string) $argument;
      $invalidBehavior = $argument
        ->getInvalidBehavior();
      $exists = $this->container
        ->has($id);

      // resolve invalid behavior
      if (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) {
        $arguments[$k] = null;
      }
      elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) {
        if ($inMethodCall) {
          throw new RuntimeException('Method shouldn\'t be called.');
        }
        $arguments[$k] = null;
      }
    }
  }
  return $arguments;
}