1 | <?php |
||
14 | class Container implements ContainerInterface, FactoryInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var bool[] map where component name => TRUE, if the component has been initialized |
||
18 | */ |
||
19 | protected $active = []; |
||
20 | |||
21 | /** |
||
22 | * @var mixed[] map where component name => value |
||
23 | */ |
||
24 | protected $values = []; |
||
25 | |||
26 | /** |
||
27 | * @var callable[] map where component name => factory function |
||
28 | */ |
||
29 | protected $factory = []; |
||
30 | |||
31 | /** |
||
32 | * @var array map where component name => mixed list/map of parameter names |
||
33 | */ |
||
34 | protected $factory_map = []; |
||
35 | |||
36 | /** |
||
37 | * @var (callable[])[] map where component name => list of configuration functions |
||
38 | */ |
||
39 | protected $config = []; |
||
40 | |||
41 | /** |
||
42 | * @var array map where component name => mixed list/map of parameter names |
||
43 | */ |
||
44 | protected $config_map = []; |
||
45 | |||
46 | /** |
||
47 | * @param mixed[] $values |
||
48 | * @param callable[] $factory |
||
49 | * @param array $factory_map |
||
50 | * @param (callable[])[] $config |
||
51 | * @param array $config_map |
||
52 | */ |
||
53 | 1 | public function __construct(array $values, array $factory, array $factory_map, array $config, array $config_map) |
|
68 | |||
69 | /** |
||
70 | * Resolve the registered component with the given name. |
||
71 | * |
||
72 | * @param string $name component name |
||
73 | * |
||
74 | * @return mixed |
||
75 | * |
||
76 | * @throws ContainerException |
||
77 | * @throws NotFoundException |
||
78 | */ |
||
79 | 1 | public function get($name) |
|
101 | |||
102 | /** |
||
103 | * Check for the existence of a component with a given name. |
||
104 | * |
||
105 | * @param string $name component name |
||
106 | * |
||
107 | * @return bool true, if a component with the given name has been defined |
||
108 | */ |
||
109 | 1 | public function has($name) |
|
113 | |||
114 | /** |
||
115 | * Check if a component has been unboxed and is currently active. |
||
116 | * |
||
117 | * @param string $name component name |
||
118 | * |
||
119 | * @return bool |
||
120 | */ |
||
121 | 1 | public function isActive($name) |
|
125 | |||
126 | /** |
||
127 | * Call any given callable, using dependency injection to satisfy it's arguments, and/or |
||
128 | * manually specifying some of those arguments - then return the value from the call. |
||
129 | * |
||
130 | * This will work for any callable: |
||
131 | * |
||
132 | * $container->call('foo'); // function foo() |
||
133 | * $container->call($foo, 'baz'); // instance method $foo->baz() |
||
134 | * $container->call([Foo::class, 'bar']); // static method Foo::bar() |
||
135 | * $container->call($foo); // closure (or class implementing __invoke) |
||
136 | * |
||
137 | * In any of those examples, you can also supply custom arguments, either named or |
||
138 | * positional, or mixed, as per the `$map` argument in `register()`, `configure()`, etc. |
||
139 | * |
||
140 | * See also {@see create()} which lets you invoke any constructor. |
||
141 | * |
||
142 | * @param callable|object $callback any arbitrary closure or callable, or object implementing __invoke() |
||
143 | * @param mixed|mixed[] $map mixed list/map of parameter values (and/or boxed values) |
||
144 | * |
||
145 | * @return mixed return value from the given callable |
||
146 | */ |
||
147 | 1 | public function call($callback, $map = []) |
|
153 | |||
154 | /** |
||
155 | * Create an instance of a given class. |
||
156 | * |
||
157 | * The container will internally resolve and inject any constructor arguments |
||
158 | * not explicitly provided in the (optional) second parameter. |
||
159 | * |
||
160 | * @param string $class_name fully-qualified class-name |
||
161 | * @param mixed|mixed[] $map mixed list/map of parameter values (and/or boxed values) |
||
162 | * |
||
163 | * @return mixed |
||
164 | */ |
||
165 | 1 | public function create($class_name, $map = []) |
|
185 | |||
186 | /** |
||
187 | * Internally resolves parameters to functions or constructors. |
||
188 | * |
||
189 | * This is the heart of the beast. |
||
190 | * |
||
191 | * @param ReflectionParameter[] $params parameter reflections |
||
192 | * @param array $map mixed list/map of parameter values (and/or boxed values) |
||
193 | * @param bool $safe if TRUE, it's considered safe to resolve against parameter names |
||
194 | * |
||
195 | * @return array parameters |
||
196 | * |
||
197 | * @throws ContainerException |
||
198 | * @throws NotFoundException |
||
199 | */ |
||
200 | 1 | protected function resolve(array $params, $map, $safe = true) |
|
245 | |||
246 | /** |
||
247 | * Dynamically inject a component into this Container. |
||
248 | * |
||
249 | * Enables classes that extend `Container` to dynamically inject components (to implement "auto-wiring") |
||
250 | * |
||
251 | * @param string $name |
||
252 | * @param mixed $value |
||
253 | */ |
||
254 | 1 | protected function inject($name, $value) |
|
259 | |||
260 | /** |
||
261 | * Internally initialize an active component. |
||
262 | * |
||
263 | * @param string $name component name |
||
264 | * |
||
265 | * @return void |
||
266 | */ |
||
267 | 1 | private function initialize($name) |
|
285 | } |
||
286 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..