1 | <?php |
||
14 | class Container extends Configuration 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 | * @param Configuration $config |
||
23 | */ |
||
24 | 1 | public function __construct(Configuration $config) |
|
37 | |||
38 | /** |
||
39 | * Resolve the registered component with the given name. |
||
40 | * |
||
41 | * @param string $name component name |
||
42 | * |
||
43 | * @return mixed |
||
44 | * |
||
45 | * @throws NotFoundException |
||
46 | */ |
||
47 | 1 | public function get($name) |
|
69 | |||
70 | /** |
||
71 | * Check if a component has been unboxed and is currently active. |
||
72 | * |
||
73 | * @param string $name component name |
||
74 | * |
||
75 | * @return bool |
||
76 | */ |
||
77 | 1 | public function isActive($name) |
|
81 | |||
82 | /** |
||
83 | * Call any given callable, using dependency injection to satisfy it's arguments, and/or |
||
84 | * manually specifying some of those arguments - then return the value from the call. |
||
85 | * |
||
86 | * This will work for any callable: |
||
87 | * |
||
88 | * $container->call('foo'); // function foo() |
||
89 | * $container->call($foo, 'baz'); // instance method $foo->baz() |
||
90 | * $container->call([Foo::class, 'bar']); // static method Foo::bar() |
||
91 | * $container->call($foo); // closure (or class implementing __invoke) |
||
92 | * |
||
93 | * In any of those examples, you can also supply custom arguments, either named or |
||
94 | * positional, or mixed, as per the `$map` argument in `register()`, `configure()`, etc. |
||
95 | * |
||
96 | * See also {@see create()} which lets you invoke any constructor. |
||
97 | * |
||
98 | * @param callable|object $callback any arbitrary closure or callable, or object implementing __invoke() |
||
99 | * @param mixed|mixed[] $map mixed list/map of parameter values (and/or boxed values) |
||
100 | * |
||
101 | * @return mixed return value from the given callable |
||
102 | */ |
||
103 | 1 | public function call($callback, $map = []) |
|
109 | |||
110 | /** |
||
111 | * Create an instance of a given class. |
||
112 | * |
||
113 | * The container will internally resolve and inject any constructor arguments |
||
114 | * not explicitly provided in the (optional) second parameter. |
||
115 | * |
||
116 | * @param string $class_name fully-qualified class-name |
||
117 | * @param mixed|mixed[] $map mixed list/map of parameter values (and/or boxed values) |
||
118 | * |
||
119 | * @return mixed |
||
120 | * |
||
121 | * @throws InvalidArgumentException |
||
122 | */ |
||
123 | 1 | public function create($class_name, $map = []) |
|
143 | |||
144 | /** |
||
145 | * Internally resolves parameters to functions or constructors. |
||
146 | * |
||
147 | * This is the heart of the beast. |
||
148 | * |
||
149 | * @param ReflectionParameter[] $params parameter reflections |
||
150 | * @param array $map mixed list/map of parameter values (and/or boxed values) |
||
151 | * @param bool $safe if TRUE, it's considered safe to resolve against parameter names |
||
152 | * |
||
153 | * @return array parameters |
||
154 | * |
||
155 | * @throws ContainerException |
||
156 | */ |
||
157 | 1 | protected function resolve(array $params, $map, $safe = true) |
|
204 | |||
205 | /** |
||
206 | * Dynamically inject a component into this Container. |
||
207 | * |
||
208 | * Enables classes that extend `Container` to dynamically inject components (to implement "auto-wiring") |
||
209 | * |
||
210 | * @param string $name |
||
211 | * @param mixed $value |
||
212 | */ |
||
213 | 1 | protected function inject($name, $value) |
|
218 | |||
219 | /** |
||
220 | * Internally initialize an active component. |
||
221 | * |
||
222 | * @param string $name component name |
||
223 | * |
||
224 | * @return void |
||
225 | */ |
||
226 | 1 | private function initialize($name) |
|
244 | } |
||
245 |
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..