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

  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 string $type;
  19.     private ?string $name;
  20.     private array $attributes;
  21.     /**
  22.      * @param string      $id              The service identifier
  23.      * @param string      $type            The PHP type of the identified service
  24.      * @param int         $invalidBehavior The behavior when the service does not exist
  25.      * @param string|null $name            The name of the argument targeting the service
  26.      * @param array       $attributes      The attributes to be used
  27.      */
  28.     public function __construct(string $idstring $typeint $invalidBehavior ContainerInterface::EXCEPTION_ON_INVALID_REFERENCEstring $name null, array $attributes = [])
  29.     {
  30.         $this->name $type === $id $name null;
  31.         parent::__construct($id$invalidBehavior);
  32.         $this->type $type;
  33.         $this->attributes $attributes;
  34.     }
  35.     public function getType()
  36.     {
  37.         return $this->type;
  38.     }
  39.     public function getName(): ?string
  40.     {
  41.         return $this->name;
  42.     }
  43.     public function getAttributes(): array
  44.     {
  45.         return $this->attributes;
  46.     }
  47. }