1 | <?php |
||
20 | class ValueTypeResolver |
||
21 | { |
||
22 | /** |
||
23 | * @var callable[] |
||
24 | */ |
||
25 | private const DEFAULT_BREAKPOINTS = [ |
||
26 | 'String' => '\\is_string', |
||
27 | 'Boolean' => '\\is_bool', |
||
28 | 'Float' => '\\is_float', |
||
29 | 'Int' => '\\is_int', |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * @var Dictionary |
||
34 | */ |
||
35 | private $dictionary; |
||
36 | |||
37 | /** |
||
38 | * @var callable[] |
||
39 | */ |
||
40 | private $breakpoints = self::DEFAULT_BREAKPOINTS; |
||
41 | |||
42 | /** |
||
43 | * ValueTypeResolver constructor. |
||
44 | * @param Dictionary $dictionary |
||
45 | */ |
||
46 | public function __construct(Dictionary $dictionary) |
||
50 | |||
51 | /** |
||
52 | * @param string $type |
||
53 | * @param callable $filter |
||
54 | * @return ValueTypeResolver |
||
55 | */ |
||
56 | public function breakpoint(string $type, callable $filter): self |
||
62 | |||
63 | /** |
||
64 | * @param string $type |
||
65 | * @return TypeDefinition |
||
66 | * @throws \Railt\Reflection\Exception\TypeNotFoundException |
||
67 | */ |
||
68 | private function load(string $type): TypeDefinition |
||
72 | |||
73 | /** |
||
74 | * @param TypeDefinition $type |
||
75 | * @param mixed $value |
||
76 | * @param string $renderedValue |
||
77 | * @return mixed |
||
78 | * @throws TypeConflictException |
||
79 | * @throws \Railt\Reflection\Exception\TypeNotFoundException |
||
80 | */ |
||
81 | public function castTo(TypeDefinition $type, $value, string $renderedValue = null) |
||
98 | |||
99 | /** |
||
100 | * @param mixed $value |
||
101 | * @return iterable|TypeDefinition[] |
||
102 | * @throws \Railt\Reflection\Exception\TypeNotFoundException |
||
103 | */ |
||
104 | public function resolveType($value): iterable |
||
118 | |||
119 | /** |
||
120 | * @return \Closure |
||
121 | */ |
||
122 | private function getFilter(): \Closure |
||
128 | |||
129 | /** |
||
130 | * @param TypeDefinition $resolved |
||
131 | * @return bool |
||
132 | */ |
||
133 | private function shouldBreak(TypeDefinition $resolved): bool |
||
137 | |||
138 | /** |
||
139 | * @param TypeDefinition $type |
||
140 | * @param \Closure $filter |
||
141 | * @return \Generator|TypeDefinition[] |
||
142 | */ |
||
143 | private function inheritedBy(TypeDefinition $type, \Closure $filter): \Traversable |
||
155 | } |
||
156 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.