[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/symfony/dependency-injection/Loader/Configurator/Traits/ -> BindTrait.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\Loader\Configurator\Traits;
  13  
  14  use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  15  use Symfony\Component\DependencyInjection\Reference;
  16  
  17  trait BindTrait
  18  {
  19      /**
  20       * Sets bindings.
  21       *
  22       * Bindings map $named or FQCN arguments to values that should be
  23       * injected in the matching parameters (of the constructor, of methods
  24       * called and of controller actions).
  25       *
  26       * @param string $nameOrFqcn A parameter name with its "$" prefix, or a FQCN
  27       * @param mixed  $valueOrRef The value or reference to bind
  28       *
  29       * @return $this
  30       */
  31      final public function bind($nameOrFqcn, $valueOrRef)
  32      {
  33          $valueOrRef = static::processValue($valueOrRef, true);
  34          if (isset($nameOrFqcn[0]) && '$' !== $nameOrFqcn[0] && !$valueOrRef instanceof Reference) {
  35              throw new InvalidArgumentException(sprintf('Invalid binding for service "%s": named arguments must start with a "$", and FQCN must map to references. Neither applies to binding "%s".', $this->id, $nameOrFqcn));
  36          }
  37          $bindings = $this->definition->getBindings();
  38          $bindings[$nameOrFqcn] = $valueOrRef;
  39          $this->definition->setBindings($bindings);
  40  
  41          return $this;
  42      }
  43  }


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