1 | <?php |
||
20 | class Container implements ContainerInterface |
||
21 | { |
||
22 | /** @var array[string] Collection of loaded services */ |
||
23 | protected $services = array(); |
||
24 | |||
25 | /** @var array[string] Collection of alias => class name for alias resolving*/ |
||
26 | protected $aliases = array(); |
||
27 | |||
28 | /** @var array[string] Collection of class name dependencies trees */ |
||
29 | protected $dependencies = array(); |
||
30 | |||
31 | /** |
||
32 | * Get reflection paramater class name type hint if present without |
||
33 | * autoloading and throwing exceptions. |
||
34 | * |
||
35 | * @param \ReflectionParameter $param Parameter for parsing |
||
36 | * |
||
37 | * @return string|null Class name typehint or null |
||
38 | */ |
||
39 | 1 | protected function getClassName(\ReflectionParameter $param) { |
|
43 | |||
44 | /** |
||
45 | * Recursively build class constructor dependencies tree. |
||
46 | * |
||
47 | * @param string $className Current class name for analyzing |
||
48 | * @param array $dependencies Reference to tree for filling up |
||
49 | * |
||
50 | * @return array[string] Multidimensional array as dependency tree |
||
|
|||
51 | */ |
||
52 | 1 | protected function buildDependenciesTree($className, array &$dependencies = array()) |
|
87 | |||
88 | /** |
||
89 | * Finds an entry of the container by its identifier and returns it. |
||
90 | * |
||
91 | * @param string $id Identifier of the entry to look for. |
||
92 | * |
||
93 | * @throws NotFoundException No entry was found for this identifier. |
||
94 | * @throws ContainerException Error while retrieving the entry. |
||
95 | * |
||
96 | * @return mixed Entry. |
||
97 | */ |
||
98 | public function get($id) |
||
113 | |||
114 | /** |
||
115 | * Returns true if the container can return an entry for the given identifier. |
||
116 | * Returns false otherwise. |
||
117 | * |
||
118 | * @param string $id Identifier of the entry to look for. |
||
119 | * |
||
120 | * @return boolean |
||
121 | */ |
||
122 | public function has($id) |
||
126 | |||
127 | /** |
||
128 | * Set dependency alias with callback function. |
||
129 | * |
||
130 | * @param callable $callable Callable to return dependency |
||
131 | * @param string $alias Dependency name |
||
132 | * |
||
133 | * @return self Chaining |
||
134 | */ |
||
135 | public function callback($callable, $alias = null) |
||
139 | |||
140 | /** |
||
141 | * Set service dependency. Upon first creation of this class instance |
||
142 | * it would be used everywhere where this dependency is needed. |
||
143 | * |
||
144 | * @param string $className Fully qualified class name |
||
145 | * @param string $alias Dependency name |
||
146 | * @param array $parameters Collection of parameters needed for dependency creation |
||
147 | * |
||
148 | * @return self Chaining |
||
149 | */ |
||
150 | public function service($className, $alias = null, array $parameters = array()) |
||
154 | |||
155 | /** |
||
156 | * Set service dependency by passing object instance. |
||
157 | * |
||
158 | * @param mixed $instance Instance that needs to be return by this dependency |
||
159 | * @param string $alias Dependency name |
||
160 | * @param array $parameters Collection of parameters needed for dependency creation |
||
161 | * |
||
162 | * @return self Chaining |
||
163 | */ |
||
164 | public function instance(&$instance, $alias = null, array $parameters = array()) |
||
169 | |||
170 | /** |
||
171 | * Set dependency. |
||
172 | * |
||
173 | * @param string $className Fully qualified class name |
||
174 | * @param string $alias Dependency name |
||
175 | * @param array $parameters Collection of parameters needed for dependency creation |
||
176 | * |
||
177 | * @return ContainerInterface Chaining |
||
178 | */ |
||
179 | 1 | public function set($className, $alias = null, array $parameters = array()) |
|
192 | } |
||
193 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.