1 | <?php |
||
11 | class Container extends AbstractContainer |
||
12 | { |
||
13 | /** Variable name for storing services */ |
||
14 | const STATIC_COLLECTION_VARIABLE = '$services'; |
||
15 | |||
16 | /** @var array[string] Collection of loaded services */ |
||
17 | protected $services = array(); |
||
18 | |||
19 | /** |
||
20 | * Get reflection parameter class name type hint if present without |
||
21 | * auto loading and throwing exceptions. |
||
22 | * TODO: Add resolving configured classes |
||
23 | * |
||
24 | * @param \ReflectionParameter $param Parameter for parsing |
||
25 | * |
||
26 | * @return string|null Class name typehint or null |
||
27 | */ |
||
28 | 2 | protected function getClassName(\ReflectionParameter $param) |
|
35 | |||
36 | /** |
||
37 | * Recursively build class constructor dependencies tree. |
||
38 | * TODO: Analyze recurrent dependencies and throw an exception |
||
39 | * |
||
40 | * @param string $className Current class name for analyzing |
||
41 | * @param array $dependencies Reference to tree for filling up |
||
42 | * |
||
43 | * @return array [string] Multidimensional array as dependency tree |
||
44 | * @throws ClassNotFoundException |
||
45 | */ |
||
46 | 2 | protected function buildDependenciesTree($className, array &$dependencies) |
|
82 | |||
83 | /** |
||
84 | * Set service dependency. Upon first creation of this class instance |
||
85 | * it would be used everywhere where this dependency is needed. |
||
86 | * |
||
87 | * @param string $className Fully qualified class name |
||
88 | * @param string $alias Dependency name |
||
89 | * @param array $parameters Collection of parameters needed for dependency creation |
||
90 | * |
||
91 | * @return Container Chaining |
||
92 | */ |
||
93 | 2 | public function service($className, $alias = null, array $parameters = array()) |
|
99 | |||
100 | /** |
||
101 | * Set dependency. |
||
102 | * |
||
103 | * @param string $className Fully qualified class name |
||
104 | * @param string $alias Dependency name |
||
105 | * @param array $parameters Collection of parameters needed for dependency creation |
||
106 | * |
||
107 | * @return Container Chaining |
||
108 | */ |
||
109 | 2 | public function set($className, $alias = null, array $parameters = array()) |
|
123 | |||
124 | /** |
||
125 | * Generate initial class instance declaration |
||
126 | * @param string $className Entity class name |
||
127 | */ |
||
128 | 2 | protected function generateInitialDeclaration($className) |
|
142 | |||
143 | /** |
||
144 | * Generate container dependency condition code. |
||
145 | * |
||
146 | * @param string $className |
||
147 | * @param mixed $dependencies |
||
148 | * @param int $level |
||
149 | * |
||
150 | * @throws ConstructorParameterNotSetException |
||
151 | * |
||
152 | */ |
||
153 | 2 | protected function generateCondition($className, $dependencies, $level = 0) |
|
192 | } |
||
193 |