1 | <?php |
||
14 | class Container implements ContainerInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | private $services; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $parameters; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $serviceStore; |
||
30 | |||
31 | /** |
||
32 | * Constructor for the container. |
||
33 | * |
||
34 | * Entries into the $services array must be an associative array with a |
||
35 | * 'class' key and an optional 'arguments' key. Where present the arguments |
||
36 | * will be passed to the class constructor. If an argument is an instance of |
||
37 | * ContainerService the argument will be replaced with the corresponding |
||
38 | * service from the container before the class is instantiated. If an |
||
39 | * argument is an instance of ContainerParameter the argument will be |
||
40 | * replaced with the corresponding parameter from the container before the |
||
41 | * class is instantiated. |
||
42 | * |
||
43 | * @param array $services The service definitions. |
||
44 | * @param array $parameters The parameter definitions. |
||
45 | */ |
||
46 | 9 | public function __construct(array $services = [], array $parameters = []) |
|
52 | |||
53 | /** |
||
54 | * {@inheritDoc} |
||
55 | */ |
||
56 | 7 | public function get($name) |
|
70 | |||
71 | /** |
||
72 | * {@inheritDoc} |
||
73 | */ |
||
74 | 7 | public function has($name) |
|
78 | |||
79 | /** |
||
80 | * {@inheritDoc} |
||
81 | */ |
||
82 | 3 | public function getParameter($name) |
|
97 | |||
98 | /** |
||
99 | * {@inheritDoc} |
||
100 | */ |
||
101 | 1 | public function hasParameter($name) |
|
111 | |||
112 | /** |
||
113 | * Attempt to create a service. |
||
114 | * |
||
115 | * @param string $name The service name. |
||
116 | * |
||
117 | * @return mixed The created service. |
||
118 | * |
||
119 | * @throws ContainerException On failure. |
||
120 | */ |
||
121 | 6 | private function createService($name) |
|
146 | |||
147 | /** |
||
148 | * Resolve argument definitions into an array of arguments. |
||
149 | * |
||
150 | * @param string $name The service name. |
||
151 | * @param array $argumentDefinitions The service arguments definition. |
||
152 | * |
||
153 | * @return array The service constructor arguments. |
||
154 | * |
||
155 | * @throws ContainerException On failure. |
||
156 | */ |
||
157 | 4 | private function resolveArguments($name, array $argumentDefinitions) |
|
177 | |||
178 | /** |
||
179 | * Initialize a service using the call definitions. |
||
180 | * |
||
181 | * @param object $service The service. |
||
182 | * @param string $name The service name. |
||
183 | * @param array $callDefinitions The service calls definition. |
||
184 | * |
||
185 | * @throws ContainerException On failure. |
||
186 | */ |
||
187 | 3 | private function initializeService($service, $name, array $callDefinitions) |
|
201 | } |
||
202 |
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: