You are here

private function CheckReferenceValidityPass::validateScope in Zircon Profile 8

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

Validates the scope of a single Reference.

Parameters

Reference $reference:

Definition $definition:

Throws

ScopeWideningInjectionException when the definition references a service of a narrower scope

ScopeCrossingInjectionException when the definition references a service of another scope hierarchy

1 call to CheckReferenceValidityPass::validateScope()
CheckReferenceValidityPass::validateReferences in vendor/symfony/dependency-injection/Compiler/CheckReferenceValidityPass.php
Validates an array of References.

File

vendor/symfony/dependency-injection/Compiler/CheckReferenceValidityPass.php, line 121

Class

CheckReferenceValidityPass
Checks the validity of references.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

private function validateScope(Reference $reference, Definition $definition = null) {
  if (ContainerInterface::SCOPE_PROTOTYPE === $this->currentScope) {
    return;
  }
  if (!$reference
    ->isStrict()) {
    return;
  }
  if (null === $definition) {
    return;
  }
  if ($this->currentScope === ($scope = $definition
    ->getScope())) {
    return;
  }
  $id = (string) $reference;
  if (in_array($scope, $this->currentScopeChildren, true)) {
    throw new ScopeWideningInjectionException($this->currentId, $this->currentScope, $id, $scope);
  }
  if (!in_array($scope, $this->currentScopeAncestors, true)) {
    throw new ScopeCrossingInjectionException($this->currentId, $this->currentScope, $id, $scope);
  }
}