vendor/symfony/dependency-injection/TypedReference.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\DependencyInjection;
  11. /**
  12.  * Represents a PHP type-hinted service reference.
  13.  *
  14.  * @author Nicolas Grekas <p@tchwork.com>
  15.  */
  16. class TypedReference extends Reference
  17. {
  18.     private $type;
  19.     private $name;
  20.     /**
  21.      * @param string      $id              The service identifier
  22.      * @param string      $type            The PHP type of the identified service
  23.      * @param int         $invalidBehavior The behavior when the service does not exist
  24.      * @param string|null $name            The name of the argument targeting the service
  25.      */
  26.     public function __construct(string $idstring $typeint $invalidBehavior ContainerInterface::EXCEPTION_ON_INVALID_REFERENCEstring $name null)
  27.     {
  28.         $this->name $type === $id $name null;
  29.         parent::__construct($id$invalidBehavior);
  30.         $this->type $type;
  31.     }
  32.     public function getType()
  33.     {
  34.         return $this->type;
  35.     }
  36.     public function getName(): ?string
  37.     {
  38.         return $this->name;
  39.     }
  40. }