1 | <?php |
||
12 | class Container implements \ArrayAccess |
||
13 | { |
||
14 | protected $locked = []; |
||
15 | private $aliasOf = []; |
||
16 | private $factories; |
||
17 | private $hasAliases = []; |
||
18 | private $raw = []; |
||
19 | private $values = []; |
||
20 | |||
21 | public function __construct() |
||
25 | |||
26 | /** |
||
27 | * Checks if a parameter or an object is defined. |
||
28 | * |
||
29 | * @param string $id the parameter/object identifier to check |
||
30 | * @return boolean |
||
31 | */ |
||
32 | public function offsetExists($id): bool |
||
36 | |||
37 | /** |
||
38 | * Gets a parameter or an object. |
||
39 | * |
||
40 | * @param string $id the parameter/object identifier |
||
41 | * @return mixed The requested value |
||
42 | * @throws \InvalidArgumentException if provided identifier is not defined |
||
43 | */ |
||
44 | public function offsetGet($id) |
||
63 | |||
64 | /** |
||
65 | * Sets a parameter or an object. |
||
66 | * |
||
67 | * Note that you cannot override locked value, you have to call ::offsetUnset first. |
||
68 | * |
||
69 | * @param string $id the identifier for parameter or object |
||
70 | * @param mixed $v the value of the parameter or an object |
||
71 | * @throws \RuntimeException prevents override of locked value |
||
72 | * @throws \InvalidArgumentException prevents value's identifier to be equal to an existing alias |
||
73 | */ |
||
74 | public function offsetSet($id, $v): void |
||
86 | |||
87 | /** |
||
88 | * Unsets a parameter or an object. It can also unset an alias. |
||
89 | * |
||
90 | * Note that if you unset a value it will also unset all its aliases. |
||
91 | * |
||
92 | * @param string $id the identifier of the object/parameter to unset |
||
93 | */ |
||
94 | public function offsetUnset($id): void |
||
112 | |||
113 | /** |
||
114 | * Adds alias to service's identifier. |
||
115 | * |
||
116 | * @param string $alias the alias to identifier |
||
117 | * @param string $id the identifier to alias |
||
118 | * @return self |
||
119 | * @throws InvalidArgumentException if provided identifier is undefined or if alias is |
||
120 | * equals to identifier |
||
121 | */ |
||
122 | public function alias(string $alias, string $id): void |
||
136 | |||
137 | /** |
||
138 | * Retrieves parameter and/or object by identifier. |
||
139 | * this method also support wildcard character (*) in identifier. |
||
140 | * |
||
141 | * @param string $id this identifier can contain one or many wildcard character (*) |
||
142 | * @return array an array of values that mached with provided identifier pattern |
||
143 | */ |
||
144 | public function find(string $id): array |
||
156 | |||
157 | /** |
||
158 | * Returns all defined identifiers and aliases. |
||
159 | * |
||
160 | * @return array |
||
161 | */ |
||
162 | public function keys(): array |
||
166 | |||
167 | /** |
||
168 | * Add provided service as factory. |
||
169 | * |
||
170 | * @param string $id the factory identifier |
||
171 | * @param mixed $factory the factory object |
||
172 | * @return self |
||
173 | * @throws InvalidArgumentException if provided factory is not a Closure or not an invokable object |
||
174 | */ |
||
175 | public function factory(string $id, $factory): void |
||
184 | |||
185 | /** |
||
186 | * Locks an object or a parameter so you can not override it until unset() is called. |
||
187 | * |
||
188 | * @param string|array $ids the identifier(s) to lock |
||
189 | * @return self |
||
190 | */ |
||
191 | public function lock($ids): void |
||
197 | |||
198 | /** |
||
199 | * @param ContainerProviderInterface $provider |
||
200 | * @return self |
||
201 | */ |
||
202 | public function hydrate(ContainerProviderInterface $provider): Container |
||
208 | |||
209 | /** |
||
210 | * Returns associated identifier if provided argument is an alias. |
||
211 | * |
||
212 | * @param string $id the identifier to convert if needed |
||
213 | * @return string |
||
214 | * @throws \InvalidArgumentException if provided identifier is not defined |
||
215 | */ |
||
216 | private function resolveIdentifier(string $id): string |
||
224 | } |
||
225 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: