@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | $inspector = new ReflectionClass($abstract); |
| 118 | 118 | |
| 119 | 119 | if (($constructor = $inspector->getConstructor()) && ($dependencies = $constructor->getParameters())) { |
| 120 | - return function (string $abstract, array $parameters) use ($inspector, $dependencies) { |
|
| 120 | + return function(string $abstract, array $parameters) use ($inspector, $dependencies) { |
|
| 121 | 121 | return $inspector->newInstanceArgs( |
| 122 | 122 | $this->process($abstract, $parameters, $dependencies) |
| 123 | 123 | ); |
| 124 | 124 | }; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - return function (string $abstract) { |
|
| 127 | + return function(string $abstract) { |
|
| 128 | 128 | return new $abstract; |
| 129 | 129 | }; |
| 130 | 130 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | { |
| 166 | 166 | $key = $abstract.$dependency->name; |
| 167 | 167 | |
| 168 | - if (! isset($this->resolved[$key])) { |
|
| 168 | + if (!isset($this->resolved[$key])) { |
|
| 169 | 169 | $this->resolved[$key] = $this->generate($abstract, $dependency); |
| 170 | 170 | } |
| 171 | 171 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | return $this->dependencies[$key]; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - return function () use ($classname) { |
|
| 195 | + return function() use ($classname) { |
|
| 196 | 196 | return $this->make($classname); |
| 197 | 197 | }; |
| 198 | 198 | } |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | try { |
| 201 | 201 | $value = $dependency->getDefaultValue(); |
| 202 | 202 | |
| 203 | - return function () use ($value) { |
|
| 203 | + return function() use ($value) { |
|
| 204 | 204 | return $value; |
| 205 | 205 | }; |
| 206 | 206 | } catch (ReflectionException $e) { |
| 207 | - throw new ContainerException("Cannot resolve '" . $dependency->name . "' of '$abstract'", 0, $e); |
|
| 207 | + throw new ContainerException("Cannot resolve '".$dependency->name."' of '$abstract'", 0, $e); |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | public function get($abstract) |
| 238 | 238 | { |
| 239 | - if (! isset($this->collection[$abstract])) { |
|
| 239 | + if (!isset($this->collection[$abstract])) { |
|
| 240 | 240 | throw new NotFoundException("Element '$abstract' not found"); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | if ($concrete instanceof Closure === false) { |
| 311 | - $concrete = function (Container $container) use ($concrete) { |
|
| 311 | + $concrete = function(Container $container) use ($concrete) { |
|
| 312 | 312 | return $container->make($concrete); |
| 313 | 313 | }; |
| 314 | 314 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | |
| 333 | 333 | public function setIf(string $abstract, $concrete, bool $shared = false) : self |
| 334 | 334 | { |
| 335 | - if (! isset($this->collection[$abstract])) { |
|
| 335 | + if (!isset($this->collection[$abstract])) { |
|
| 336 | 336 | $this->set($abstract, $concrete, $shared); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -353,11 +353,11 @@ discard block |
||
| 353 | 353 | { |
| 354 | 354 | if ($dependency instanceof Closure === false) { |
| 355 | 355 | if (is_object($dependency)) { |
| 356 | - $dependency = function () use ($dependency) { |
|
| 356 | + $dependency = function() use ($dependency) { |
|
| 357 | 357 | return $dependency; |
| 358 | 358 | }; |
| 359 | 359 | } else { |
| 360 | - $dependency = function () use ($dependency) { |
|
| 360 | + $dependency = function() use ($dependency) { |
|
| 361 | 361 | return $this->get($dependency); |
| 362 | 362 | }; |
| 363 | 363 | } |
@@ -397,8 +397,8 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | public function instance(string $abstract, $instance) : self |
| 399 | 399 | { |
| 400 | - if (! is_object($instance)) { |
|
| 401 | - throw new ContainerException('Trying to store ' . gettype($type) . ' as object.'); |
|
| 400 | + if (!is_object($instance)) { |
|
| 401 | + throw new ContainerException('Trying to store '.gettype($type).' as object.'); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | $this->collection[$abstract] = $instance; |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | |
| 419 | 419 | public function extend(string $abstract, closure $extension) : self |
| 420 | 420 | { |
| 421 | - if (! isset($this->collection[$abstract])) { |
|
| 421 | + if (!isset($this->collection[$abstract])) { |
|
| 422 | 422 | throw new NotFoundException($abstract); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | $object = $this->collection[$abstract]; |
| 426 | 426 | |
| 427 | 427 | if ($object instanceof Closure) { |
| 428 | - $this->collection[$abstract] = function () use ($object, $extension) { |
|
| 428 | + $this->collection[$abstract] = function() use ($object, $extension) { |
|
| 429 | 429 | return $extension($object($this), $this); |
| 430 | 430 | }; |
| 431 | 431 | } else { |
@@ -448,11 +448,11 @@ discard block |
||
| 448 | 448 | |
| 449 | 449 | public function share(string $abstract) : self |
| 450 | 450 | { |
| 451 | - if (! isset($this->collection[$abstract])) { |
|
| 451 | + if (!isset($this->collection[$abstract])) { |
|
| 452 | 452 | throw new NotFoundException("Element '$abstract' not found"); |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if (! $this->collection[$abstract] instanceof Closure) { |
|
| 455 | + if (!$this->collection[$abstract] instanceof Closure) { |
|
| 456 | 456 | throw new ContainerException("'$abstract' must be a resolvable element"); |
| 457 | 457 | } |
| 458 | 458 | |