1 | <?php |
||
13 | class Compiler |
||
14 | { |
||
15 | /** |
||
16 | * @var DefinitionInterface[] |
||
17 | */ |
||
18 | private $definitions = []; |
||
19 | |||
20 | /** |
||
21 | * @var DumpableInterface[] |
||
22 | */ |
||
23 | private $dumpableDefinitions = []; |
||
24 | |||
25 | /** |
||
26 | * The object in charge of converting container-interop definitions to our internal standard. |
||
27 | * |
||
28 | * @var DefinitionConverterInterface |
||
29 | */ |
||
30 | private $converter; |
||
31 | |||
32 | /** |
||
33 | * @param DefinitionConverterInterface $converter The object in charge of converting container-interop definitions to our internal standard. |
||
34 | */ |
||
35 | public function __construct(DefinitionConverterInterface $converter = null) |
||
42 | |||
43 | /** |
||
44 | * Adds a definition to the list of definitions managed by this compiler. |
||
45 | * |
||
46 | * @param string $identifier |
||
47 | * @param DefinitionInterface $definition |
||
48 | */ |
||
49 | public function addDefinition($identifier, DefinitionInterface $definition) |
||
54 | |||
55 | /** |
||
56 | * Registers a new definition provider. |
||
57 | * |
||
58 | * @param DefinitionProviderInterface $definitionProvider |
||
59 | */ |
||
60 | public function register(DefinitionProviderInterface $definitionProvider) |
||
66 | |||
67 | /** |
||
68 | * Adds a dumpable definition to the list of definitions managed by this compiler. |
||
69 | * Note: a "dumpable" definition is a definition represented in Yaco internal format. |
||
70 | * |
||
71 | * @param DumpableInterface $dumpableDefinition |
||
72 | */ |
||
73 | public function addDumpableDefinition(DumpableInterface $dumpableDefinition) |
||
78 | |||
79 | /** |
||
80 | * @param string $identifier |
||
81 | * |
||
82 | * @return bool |
||
83 | */ |
||
84 | public function has($identifier) |
||
88 | |||
89 | /** |
||
90 | * Returns the dumpable definition matching the $identifier. |
||
91 | * |
||
92 | * @param string $identifier |
||
93 | * |
||
94 | * @return Definition\AliasDefinition|DumpableInterface|Definition\FactoryCallDefinition|Definition\ObjectDefinition|Definition\ParameterDefinition |
||
95 | * |
||
96 | * @throws CompilerException |
||
97 | */ |
||
98 | public function getDumpableDefinition($identifier) |
||
108 | |||
109 | /** |
||
110 | * @param string $className |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | public function compile($className) |
||
159 | |||
160 | private function splitFQCN($className) |
||
176 | |||
177 | private function getParametersCode(InlineEntryInterface $inlineEntry) |
||
185 | |||
186 | private function getClosureCode(InlineEntryInterface $inlineEntry) |
||
193 | } |
||
194 |