Debian Codegraph @

vendor/symfony/type-info/Type/TemplateType.php

raw
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
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\TypeInfo\Type;
13
14 use Symfony\Component\TypeInfo\Type;
15
16 /**
17 * Represents a template placeholder, such as "T" in "Collection<T>".
18 *
19 * @author Mathias Arlaud <[email protected]>
20 * @author Baptiste Leduc <[email protected]>
21 *
22 * @template T of Type
23 *
24 * @implements WrappingTypeInterface<T>
25 */
26 final class TemplateType extends Type implements WrappingTypeInterface
27 {
28 /**
29 * @param T $bound
30 */
31 public function __construct(
32 private readonly string $name,
33 private readonly Type $bound,
34 ) {
35 }
36
37 public function getName(): string
38 {
39 return $this->name;
40 }
41
42 /**
43 * @return T
44 */
45 public function getBound(): Type
46 {
47 return $this->bound;
48 }
49
50 public function getWrappedType(): Type
51 {
52 return $this->bound;
53 }
54
55 public function wrappedTypeIsSatisfiedBy(callable $specification): bool
56 {
57 return $this->getWrappedType()->isSatisfiedBy($specification);
58 }
59
60 public function __toString(): string
61 {
62 return $this->name;
63 }
64 }