private function 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 drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php
Validates an array of References.

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php, line 123

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);
  }
}