1 | <?php |
||
15 | class TypeHint implements HintInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $name; |
||
21 | |||
22 | /** |
||
23 | * @var bool |
||
24 | */ |
||
25 | private $iterable; |
||
26 | |||
27 | /** |
||
28 | * @var Matchable[] |
||
29 | */ |
||
30 | private $matchers = []; |
||
31 | |||
32 | /** |
||
33 | * TypeHint constructor. |
||
34 | * @param string $name |
||
35 | * @param bool $iterable |
||
36 | */ |
||
37 | public function __construct(string $name, bool $iterable = false) |
||
42 | |||
43 | /** |
||
44 | * @return string |
||
45 | */ |
||
46 | public function getName(): string |
||
50 | |||
51 | /** |
||
52 | * @return bool |
||
53 | */ |
||
54 | public function isIterable(): bool |
||
58 | |||
59 | /** |
||
60 | * @param Matchable $matcher |
||
61 | * @return OrTypeHint |
||
62 | */ |
||
63 | public function addMatcher(Matchable $matcher): Matchable |
||
69 | |||
70 | /** |
||
71 | * @param mixed $value |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function match($value): bool |
||
78 | |||
79 | /** |
||
80 | * @param iterable|mixed $values |
||
81 | * @return bool |
||
82 | */ |
||
83 | private function matchIterable($values): bool |
||
97 | |||
98 | /** |
||
99 | * @param mixed $value |
||
100 | * @return bool |
||
101 | */ |
||
102 | private function matchScalar($value): bool |
||
123 | |||
124 | /** |
||
125 | * @return bool |
||
126 | */ |
||
127 | private function isBuiltin(): bool |
||
131 | |||
132 | /** |
||
133 | * @param mixed $value |
||
134 | * @return bool |
||
135 | */ |
||
136 | private function matchBuiltin($value): bool |
||
142 | } |
||
143 |
If you suppress an error, we recommend checking for the error condition explicitly: