Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ResolveBindingsPass.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 6.07 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of the Symfony package.
 005   *
 006   * (c) Fabien Potencier <fabien@symfony.com>
 007   *
 008   * For the full copyright and license information, please view the LICENSE
 009   * file that was distributed with this source code.
 010   */
 011   
 012  namespace Symfony\Component\DependencyInjection\Compiler;
 013   
 014  use Symfony\Component\DependencyInjection\Argument\BoundArgument;
 015  use Symfony\Component\DependencyInjection\ContainerBuilder;
 016  use Symfony\Component\DependencyInjection\Definition;
 017  use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
 018  use Symfony\Component\DependencyInjection\Exception\RuntimeException;
 019  use Symfony\Component\DependencyInjection\LazyProxy\ProxyHelper;
 020  use Symfony\Component\DependencyInjection\Reference;
 021  use Symfony\Component\DependencyInjection\TypedReference;
 022   
 023  /**
 024   * @author Guilhem Niot <guilhem.niot@gmail.com>
 025   */
 026  class ResolveBindingsPass extends AbstractRecursivePass
 027  {
 028      private $usedBindings = [];
 029      private $unusedBindings = [];
 030      private $errorMessages = [];
 031   
 032      /**
 033       * {@inheritdoc}
 034       */
 035      public function process(ContainerBuilder $container)
 036      {
 037          $this->usedBindings = $container->getRemovedBindingIds();
 038   
 039          try {
 040              parent::process($container);
 041   
 042              foreach ($this->unusedBindings as list($key, $serviceId)) {
 043                  $message = sprintf('Unused binding "%s" in service "%s".', $key, $serviceId);
 044                  if ($this->errorMessages) {
 045                      $message .= sprintf("\nCould be related to%s:", 1 < \count($this->errorMessages) ? ' one of' : '');
 046                  }
 047                  foreach ($this->errorMessages as $m) {
 048                      $message .= "\n - ".$m;
 049                  }
 050                  throw new InvalidArgumentException($message);
 051              }
 052          } finally {
 053              $this->usedBindings = [];
 054              $this->unusedBindings = [];
 055              $this->errorMessages = [];
 056          }
 057      }
 058   
 059      /**
 060       * {@inheritdoc}
 061       */
 062      protected function processValue($value, $isRoot = false)
 063      {
 064          if ($value instanceof TypedReference && $value->getType() === $this->container->normalizeId($value)) {
 065              // Already checked
 066              $bindings = $this->container->getDefinition($this->currentId)->getBindings();
 067   
 068              if (isset($bindings[$value->getType()])) {
 069                  return $this->getBindingValue($bindings[$value->getType()]);
 070              }
 071   
 072              return parent::processValue($value, $isRoot);
 073          }
 074   
 075          if (!$value instanceof Definition || !$bindings = $value->getBindings()) {
 076              return parent::processValue($value, $isRoot);
 077          }
 078   
 079          foreach ($bindings as $key => $binding) {
 080              list($bindingValue, $bindingId, $used) = $binding->getValues();
 081              if ($used) {
 082                  $this->usedBindings[$bindingId] = true;
 083                  unset($this->unusedBindings[$bindingId]);
 084              } elseif (!isset($this->usedBindings[$bindingId])) {
 085                  $this->unusedBindings[$bindingId] = [$key, $this->currentId];
 086              }
 087   
 088              if (isset($key[0]) && '$' === $key[0]) {
 089                  continue;
 090              }
 091   
 092              if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition) {
 093                  throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, an instance of "%s" or an instance of "%s", "%s" given.', $key, $this->currentId, Reference::class, Definition::class, \gettype($bindingValue)));
 094              }
 095          }
 096   
 097          if ($value->isAbstract()) {
 098              return parent::processValue($value, $isRoot);
 099          }
 100   
 101          $calls = $value->getMethodCalls();
 102   
 103          try {
 104              if ($constructor = $this->getConstructor($value, false)) {
 105                  $calls[] = [$constructor, $value->getArguments()];
 106              }
 107          } catch (RuntimeException $e) {
 108              $this->errorMessages[] = $e->getMessage();
 109              $this->container->getDefinition($this->currentId)->addError($e->getMessage());
 110   
 111              return parent::processValue($value, $isRoot);
 112          }
 113   
 114          foreach ($calls as $i => $call) {
 115              list($method, $arguments) = $call;
 116   
 117              if ($method instanceof \ReflectionFunctionAbstract) {
 118                  $reflectionMethod = $method;
 119              } else {
 120                  try {
 121                      $reflectionMethod = $this->getReflectionMethod($value, $method);
 122                  } catch (RuntimeException $e) {
 123                      if ($value->getFactory()) {
 124                          continue;
 125                      }
 126                      throw $e;
 127                  }
 128              }
 129   
 130              foreach ($reflectionMethod->getParameters() as $key => $parameter) {
 131                  if (\array_key_exists($key, $arguments) && '' !== $arguments[$key]) {
 132                      continue;
 133                  }
 134   
 135                  if (\array_key_exists('$'.$parameter->name, $bindings)) {
 136                      $arguments[$key] = $this->getBindingValue($bindings['$'.$parameter->name]);
 137   
 138                      continue;
 139                  }
 140   
 141                  $typeHint = ProxyHelper::getTypeHint($reflectionMethod, $parameter, true);
 142   
 143                  if (!isset($bindings[$typeHint])) {
 144                      continue;
 145                  }
 146   
 147                  $arguments[$key] = $this->getBindingValue($bindings[$typeHint]);
 148              }
 149   
 150              if ($arguments !== $call[1]) {
 151                  ksort($arguments);
 152                  $calls[$i][1] = $arguments;
 153              }
 154          }
 155   
 156          if ($constructor) {
 157              list(, $arguments) = array_pop($calls);
 158   
 159              if ($arguments !== $value->getArguments()) {
 160                  $value->setArguments($arguments);
 161              }
 162          }
 163   
 164          if ($calls !== $value->getMethodCalls()) {
 165              $value->setMethodCalls($calls);
 166          }
 167   
 168          return parent::processValue($value, $isRoot);
 169      }
 170   
 171      private function getBindingValue(BoundArgument $binding)
 172      {
 173          list($bindingValue, $bindingId) = $binding->getValues();
 174   
 175          $this->usedBindings[$bindingId] = true;
 176          unset($this->unusedBindings[$bindingId]);
 177   
 178          return $bindingValue;
 179      }
 180  }
 181