@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Balloon |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param Iterable $config |
62 | 62 | */ |
63 | - public function __construct(Iterable $config = [], ?ContainerInterface $parent=null) |
|
63 | + public function __construct(Iterable $config = [], ?ContainerInterface $parent = null) |
|
64 | 64 | { |
65 | 65 | $this->config = $config; |
66 | 66 | $this->parent = $parent; |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | return $this->addStaticService($name); |
85 | 85 | } |
86 | 86 | |
87 | - if(isset($this->config[$name])) { |
|
87 | + if (isset($this->config[$name])) { |
|
88 | 88 | return $this->autoWireClass($name); |
89 | 89 | } |
90 | 90 | |
91 | 91 | try { |
92 | 92 | return $this->lookupService($name); |
93 | - } catch(Exception\ServiceNotFound $e) { |
|
93 | + } catch (Exception\ServiceNotFound $e) { |
|
94 | 94 | return $this->autoWireClass($name); |
95 | 95 | } |
96 | 96 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function addStaticService(string $name) |
105 | 105 | { |
106 | - if( $this->registry[$name] instanceof Closure) { |
|
106 | + if ($this->registry[$name] instanceof Closure) { |
|
107 | 107 | $this->service[$name] = $this->registry[$name]->call($this); |
108 | 108 | } else { |
109 | 109 | $this->service[$name] = $this->registry[$name]; |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | return $this->addStaticService($name); |
130 | 130 | } |
131 | 131 | |
132 | - if(isset($this->config[$name])) { |
|
132 | + if (isset($this->config[$name])) { |
|
133 | 133 | return $this->autoWireClass($name); |
134 | 134 | } |
135 | 135 | |
136 | - if($this->parent !== null) { |
|
136 | + if ($this->parent !== null) { |
|
137 | 137 | return $this->parent->lookupService($name); |
138 | 138 | } |
139 | 139 | |
@@ -208,20 +208,20 @@ discard block |
||
208 | 208 | } |
209 | 209 | |
210 | 210 | if (isset($config['use'])) { |
211 | - if(!is_string($config['use'])) { |
|
211 | + if (!is_string($config['use'])) { |
|
212 | 212 | throw new Exception\Configuration('use must be a string for service '.$name); |
213 | 213 | } |
214 | 214 | |
215 | 215 | $class = $config['use']; |
216 | 216 | } |
217 | 217 | |
218 | - if(preg_match('#^\{(.*)\}$#', $class, $match)) { |
|
218 | + if (preg_match('#^\{(.*)\}$#', $class, $match)) { |
|
219 | 219 | $service = $this->get($match[1]); |
220 | 220 | |
221 | - if(isset($this->config[$name]['selects'])) { |
|
221 | + if (isset($this->config[$name]['selects'])) { |
|
222 | 222 | $reflection = new ReflectionClass(get_class($service)); |
223 | 223 | |
224 | - foreach($this->config[$name]['selects'] as $select) { |
|
224 | + foreach ($this->config[$name]['selects'] as $select) { |
|
225 | 225 | $args = $this->autoWireMethod($name, $reflection->getMethod($select['method']), $select); |
226 | 226 | $service = call_user_func_array([&$service, $select['method']], $args); |
227 | 227 | } |
@@ -260,16 +260,16 @@ discard block |
||
260 | 260 | $instance = $class->newInstanceArgs($arguments); |
261 | 261 | $this->service[$name] = $instance; |
262 | 262 | |
263 | - if(isset($this->config[$name]['calls'])) { |
|
264 | - foreach($this->config[$name]['calls'] as $call) { |
|
265 | - if(!isset($call['method'])) { |
|
263 | + if (isset($this->config[$name]['calls'])) { |
|
264 | + foreach ($this->config[$name]['calls'] as $call) { |
|
265 | + if (!isset($call['method'])) { |
|
266 | 266 | throw new Exception\Configuration('method is required for setter injection in service '.$name); |
267 | 267 | } |
268 | 268 | |
269 | 269 | $arguments = []; |
270 | 270 | try { |
271 | 271 | $method = $class->getMethod($call['method']); |
272 | - } catch(\ReflectionException $e) { |
|
272 | + } catch (\ReflectionException $e) { |
|
273 | 273 | throw new Exception\Configuration('method '.$call['method'].' is not callable in class '.$class->getName().' for service '.$name); |
274 | 274 | } |
275 | 275 | |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | $type = $param->getClass(); |
299 | 299 | $param_name = $param->getName(); |
300 | 300 | |
301 | - if(isset($config['arguments'][$param_name])) { |
|
301 | + if (isset($config['arguments'][$param_name])) { |
|
302 | 302 | $args[$param_name] = $this->parseParam($config['arguments'][$param_name], $name); |
303 | - } elseif($type !== null) { |
|
303 | + } elseif ($type !== null) { |
|
304 | 304 | $type_class = $type->getName(); |
305 | 305 | |
306 | 306 | if ($type_class === $name) { |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | $args[$param_name] = $this->findService($name, $type_class); |
311 | - } elseif($param->isDefaultValueAvailable()) { |
|
311 | + } elseif ($param->isDefaultValueAvailable()) { |
|
312 | 312 | $args[$param_name] = $param->getDefaultValue(); |
313 | - } elseif($param->allowsNull() && $param->hasType()) { |
|
313 | + } elseif ($param->allowsNull() && $param->hasType()) { |
|
314 | 314 | $args[$param_name] = null; |
315 | 315 | } else { |
316 | 316 | throw new Exception\Configuration('no value found for argument '.$param_name.' in method '.$method->getName().' for service '.$name); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | return str_replace($match[0], $env, $param); |
356 | - } elseif(preg_match('#^\{(.*)\}$#', $param, $match)) { |
|
356 | + } elseif (preg_match('#^\{(.*)\}$#', $param, $match)) { |
|
357 | 357 | return $this->findService($name, $match[1]); |
358 | 358 | } |
359 | 359 | |
@@ -372,11 +372,11 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function findService(string $current_service, string $service) |
374 | 374 | { |
375 | - if(isset($this->children[$current_service])) { |
|
375 | + if (isset($this->children[$current_service])) { |
|
376 | 376 | return $this->children[$current_service]->get($service); |
377 | 377 | } |
378 | 378 | |
379 | - if(isset($this->config[$current_service]['services'])) { |
|
379 | + if (isset($this->config[$current_service]['services'])) { |
|
380 | 380 | $this->children[$current_service] = new self($this->config[$current_service]['services'], $this); |
381 | 381 | return $this->children[$current_service]->get($service); |
382 | 382 | } |