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 | * @var int[] map where component name => activation depth |
||
23 | * |
||
24 | * @see get() |
||
25 | */ |
||
26 | private $activations = []; |
||
27 | |||
28 | /** |
||
29 | * @param Configuration $config |
||
30 | */ |
||
31 | 1 | public function __construct(Configuration $config) |
|
44 | |||
45 | /** |
||
46 | * Resolve the registered component with the given name. |
||
47 | * |
||
48 | * @param string $name component name |
||
49 | * |
||
50 | * @return mixed |
||
51 | * |
||
52 | * @throws NotFoundException |
||
53 | */ |
||
54 | 1 | public function get($name) |
|
98 | |||
99 | /** |
||
100 | * Check for the existence of a component with a given name. |
||
101 | * |
||
102 | * @param string $name component name |
||
103 | * |
||
104 | * @return bool true, if a component with the given name has been defined |
||
105 | */ |
||
106 | 1 | public function has($name) |
|
110 | |||
111 | /** |
||
112 | * Check if a component has been unboxed and is currently active. |
||
113 | * |
||
114 | * @param string $name component name |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | 1 | public function isActive($name) |
|
122 | |||
123 | /** |
||
124 | * Call any given callable, using dependency injection to satisfy it's arguments, and/or |
||
125 | * manually specifying some of those arguments - then return the value from the call. |
||
126 | * |
||
127 | * This will work for any callable: |
||
128 | * |
||
129 | * $container->call('foo'); // function foo() |
||
130 | * $container->call($foo, 'baz'); // instance method $foo->baz() |
||
131 | * $container->call([Foo::class, 'bar']); // static method Foo::bar() |
||
132 | * $container->call($foo); // closure (or class implementing __invoke) |
||
133 | * |
||
134 | * In any of those examples, you can also supply custom arguments, either named or |
||
135 | * positional, or mixed, as per the `$map` argument in `register()`, `configure()`, etc. |
||
136 | * |
||
137 | * See also {@see create()} which lets you invoke any constructor. |
||
138 | * |
||
139 | * @param callable|object $callback any arbitrary closure or callable, or object implementing __invoke() |
||
140 | * @param mixed|mixed[] $map mixed list/map of parameter values (and/or boxed values) |
||
141 | * |
||
142 | * @return mixed return value from the given callable |
||
143 | */ |
||
144 | 1 | public function call($callback, $map = []) |
|
150 | |||
151 | /** |
||
152 | * Create an instance of a given class. |
||
153 | * |
||
154 | * The container will internally resolve and inject any constructor arguments |
||
155 | * not explicitly provided in the (optional) second parameter. |
||
156 | * |
||
157 | * @param string $class_name fully-qualified class-name |
||
158 | * @param mixed|mixed[] $map mixed list/map of parameter values (and/or boxed values) |
||
159 | * |
||
160 | * @return mixed |
||
161 | * |
||
162 | * @throws InvalidArgumentException |
||
163 | */ |
||
164 | 1 | public function create($class_name, $map = []) |
|
184 | |||
185 | /** |
||
186 | * Internally resolves parameters to functions or constructors. |
||
187 | * |
||
188 | * This is the heart of the beast. |
||
189 | * |
||
190 | * @param ReflectionParameter[] $params parameter reflections |
||
191 | * @param array $map mixed list/map of parameter values (and/or boxed values) |
||
192 | * @param bool $safe if TRUE, it's considered safe to resolve against parameter names |
||
193 | * |
||
194 | * @return array parameters |
||
195 | * |
||
196 | * @throws ContainerException |
||
197 | */ |
||
198 | 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 |
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..