1 | <?php |
||
14 | abstract class TypeSystem implements ITypeSystem |
||
15 | { |
||
16 | /** |
||
17 | * @var INativeType[] |
||
18 | */ |
||
19 | protected $nativeTypes = []; |
||
20 | |||
21 | /** |
||
22 | * @var IObjectType[] |
||
23 | */ |
||
24 | protected $objectTypes = []; |
||
25 | |||
26 | /** |
||
27 | * @var ICompositeType[] |
||
28 | */ |
||
29 | protected $compositeTypes = []; |
||
30 | |||
31 | /** |
||
32 | * @var IType[] |
||
33 | */ |
||
34 | protected $customTypes = []; |
||
35 | |||
36 | /** |
||
37 | * @var IFunction[] |
||
38 | */ |
||
39 | protected $functions = []; |
||
40 | |||
41 | /** |
||
42 | * @var IBinaryOperation[] |
||
43 | */ |
||
44 | protected $binaryOperations = []; |
||
45 | |||
46 | public function __construct() |
||
56 | |||
57 | /** |
||
58 | * Performs all necessary normalization to the class name. |
||
59 | * |
||
60 | * @param string $name |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | protected function normalizeClassName($name) |
||
68 | |||
69 | /** |
||
70 | * Performs all necessary normalization the function name. |
||
71 | * |
||
72 | * @param string $name |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | protected function normalizeFunctionName($name) |
||
80 | |||
81 | protected function buildTypeOperations($type, array $operatorTypeMap = []) |
||
90 | |||
91 | /** |
||
92 | * @return INativeType[] |
||
93 | */ |
||
94 | abstract protected function nativeTypes(); |
||
95 | |||
96 | /** |
||
97 | * @return INativeType[] |
||
98 | */ |
||
99 | protected function buildNativeTypes() |
||
103 | |||
104 | /** |
||
105 | * @return array[] |
||
106 | */ |
||
107 | abstract protected function binaryOperations(); |
||
108 | |||
109 | /** |
||
110 | * @return IBinaryOperation[] |
||
111 | */ |
||
112 | protected function buildBinaryOperations() |
||
121 | |||
122 | public function getType($typeIdentifier) |
||
134 | |||
135 | public function getNativeType($nativeType) |
||
143 | |||
144 | /** |
||
145 | * @param string $typeId |
||
146 | * @param string $classType |
||
147 | * |
||
148 | * @return IObjectType |
||
149 | */ |
||
150 | abstract protected function buildObjectType($typeId, $classType); |
||
151 | |||
152 | public function getObjectType($classType) |
||
162 | |||
163 | /** |
||
164 | * @param string $typeId |
||
165 | * @param IType[] $types |
||
166 | * |
||
167 | * @return ICompositeType |
||
168 | */ |
||
169 | abstract protected function buildCompositeType($typeId, array $types); |
||
170 | |||
171 | public function getCompositeType(array $types) |
||
199 | |||
200 | /** |
||
201 | * Flattens all the composed types. |
||
202 | * |
||
203 | * @param IType[] $types |
||
204 | * |
||
205 | * @return IType[] |
||
206 | */ |
||
207 | protected function flattenComposedTypes(array $types) |
||
220 | |||
221 | /** |
||
222 | * @param string $name |
||
223 | * |
||
224 | * @return IFunction |
||
225 | */ |
||
226 | abstract protected function buildFunction($name); |
||
227 | |||
228 | public function getFunction($name) |
||
237 | |||
238 | public function getBinaryOperation(IType $leftOperandType, $operator, IType $rightOperandType) |
||
261 | } |
||
262 |