[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Compiler/ -> CheckReferenceValidityPass.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\DependencyInjection\Compiler;
  13  
  14  use Symfony\Component\DependencyInjection\Definition;
  15  use Symfony\Component\DependencyInjection\Exception\RuntimeException;
  16  use Symfony\Component\DependencyInjection\Reference;
  17  
  18  /**
  19   * Checks the validity of references.
  20   *
  21   * The following checks are performed by this pass:
  22   * - target definitions are not abstract
  23   *
  24   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  25   */
  26  class CheckReferenceValidityPass extends AbstractRecursivePass
  27  {
  28      protected function processValue($value, $isRoot = false)
  29      {
  30          if ($isRoot && $value instanceof Definition && ($value->isSynthetic() || $value->isAbstract())) {
  31              return $value;
  32          }
  33          if ($value instanceof Reference && $this->container->hasDefinition((string) $value)) {
  34              $targetDefinition = $this->container->getDefinition((string) $value);
  35  
  36              if ($targetDefinition->isAbstract()) {
  37                  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));
  38              }
  39          }
  40  
  41          return parent::processValue($value, $isRoot);
  42      }
  43  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1