1 | <?php declare(strict_types = 1); |
||
26 | class DefinitionCompiler |
||
27 | { |
||
28 | /** @var DefinitionGenerator */ |
||
29 | protected $generator; |
||
30 | |||
31 | /** @var DefinitionAnalyzer */ |
||
32 | protected $analyzer; |
||
33 | |||
34 | /** @var array All registered dependencies*/ |
||
35 | protected $dependencies = []; |
||
36 | |||
37 | /** |
||
38 | * DefinitionCompiler constructor. |
||
39 | * |
||
40 | * @param DefinitionGenerator $generator |
||
41 | * @param DefinitionAnalyzer $analyzer |
||
42 | */ |
||
43 | 4 | public function __construct(DefinitionGenerator $generator, DefinitionAnalyzer $analyzer) |
|
48 | |||
49 | /** |
||
50 | * Compile and get container |
||
51 | * |
||
52 | * @param DefinitionBuilder $definitionBuilder |
||
53 | * @param $containerName |
||
54 | * @param $namespace |
||
55 | * @param $containerDir |
||
56 | * @return ContainerInterface |
||
57 | * @throws ImplementerForTypeNotFoundException |
||
58 | * @throws ParameterNotFoundException |
||
59 | * @throws ClassDefinitionAlreadyExistsException |
||
60 | * @throws ReferenceNotImplementsException |
||
61 | * @throws \InvalidArgumentException |
||
62 | */ |
||
63 | 2 | public function compile(DefinitionBuilder $definitionBuilder, $containerName, $namespace, $containerDir) |
|
110 | |||
111 | /** |
||
112 | * Get class dependencies form definition builder |
||
113 | * |
||
114 | * @param DefinitionBuilder $definitionBuilder |
||
115 | * @return array |
||
116 | * @throws ImplementerForTypeNotFoundException |
||
117 | */ |
||
118 | 4 | protected function getClassDependencies(DefinitionBuilder $definitionBuilder): array |
|
140 | |||
141 | /** |
||
142 | * Generate definitions from dependencies for builder |
||
143 | * |
||
144 | * @param DefinitionBuilder $definitionBuilder |
||
145 | * @param array $dependencyList |
||
146 | * @throws ClassDefinitionAlreadyExistsException |
||
147 | * @throws ImplementerForTypeNotFoundException |
||
148 | * @throws \InvalidArgumentException |
||
149 | */ |
||
150 | 3 | protected function generateDefinitions( |
|
161 | |||
162 | /** |
||
163 | * Check if class name is interface or abstract class |
||
164 | * |
||
165 | * @param string $className |
||
166 | * @return bool |
||
167 | */ |
||
168 | 4 | protected function checkIfType(string $className): bool |
|
173 | |||
174 | /** |
||
175 | * Get class which implements the interface |
||
176 | * |
||
177 | * @param string $interfaceName |
||
178 | * @return string |
||
179 | * @throws ImplementerForTypeNotFoundException |
||
180 | * TODO Add interface resolvers functionality |
||
181 | */ |
||
182 | protected function resolveTypeImplementer(string $interfaceName): string |
||
196 | |||
197 | /** |
||
198 | * Add dependencies which then will be use for automatic creation the definitions |
||
199 | * |
||
200 | * @param array $dependencyList |
||
201 | * @param ReferenceInterface $reference |
||
202 | * @param AbstractPropertyDefinition $definition |
||
203 | * @return array |
||
204 | * @throws ImplementerForTypeNotFoundException |
||
205 | */ |
||
206 | 4 | protected function addDependency( |
|
224 | } |
||
225 |