@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * @param mixed $value |
| 41 | 41 | * @return self |
| 42 | 42 | */ |
| 43 | - public function to(string|array|callable $value): Bindings |
|
| 43 | + public function to(string | array | callable $value): Bindings |
|
| 44 | 44 | { |
| 45 | - if(isset($this->bindings[$this->activeKey])) { |
|
| 45 | + if (isset($this->bindings[$this->activeKey])) { |
|
| 46 | 46 | $this->bindings[$this->activeKey]['binding'] = $value; |
| 47 | 47 | } else { |
| 48 | 48 | $this->bindings[$this->activeKey] = ['binding' => $value, 'calls' => [], 'properties' => []]; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | public function get(string $key): array |
| 60 | 60 | { |
| 61 | 61 | $binding = $this->bindings[$key]; |
| 62 | - if(!isset($binding['binding'])) { |
|
| 62 | + if (!isset($binding['binding'])) { |
|
| 63 | 63 | $binding['binding'] = $key; |
| 64 | 64 | } |
| 65 | 65 | return $binding; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | private function setArrayBinding(array $binding): void |
| 95 | 95 | { |
| 96 | - if(isset($binding[0])) { |
|
| 96 | + if (isset($binding[0])) { |
|
| 97 | 97 | $this->to($binding[0]); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function merge(array $bindings): void |
| 109 | 109 | { |
| 110 | - foreach($bindings as $key => $binding) { |
|
| 110 | + foreach ($bindings as $key => $binding) { |
|
| 111 | 111 | $this->activeKey = $key; |
| 112 | - if(is_array($binding)) { |
|
| 112 | + if (is_array($binding)) { |
|
| 113 | 113 | $this->setArrayBinding($binding); |
| 114 | 114 | } else { |
| 115 | 115 | $this->bindings[$key] = ['binding' => $binding, 'calls' => [], 'properties' => []]; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | return $this; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function with(string|array|callable $value): Bindings |
|
| 126 | + public function with(string | array | callable $value): Bindings |
|
| 127 | 127 | { |
| 128 | 128 | return $this->to($value); |
| 129 | 129 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } else if ($argumentValue === null) { |
| 166 | 166 | throw new exceptions\InjectionException("Could not resolve a value for {$argumentName} of type {$className} for {$method->getDeclaringClass()->getName()}{$method->getName()}"); |
| 167 | 167 | } |
| 168 | - $argumentValues[]=$argumentValue; |
|
| 168 | + $argumentValues[] = $argumentValue; |
|
| 169 | 169 | } else { |
| 170 | 170 | throw new exceptions\InjectionException("Could not resolve a value for {$argumentName} of type {$type} for {$method->getDeclaringClass()->getName()}{$method->getName()}"); |
| 171 | 171 | } |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | private function injectAttributed(mixed $instance, \ReflectionClass $reflection): void |
| 193 | 193 | { |
| 194 | 194 | // Properties |
| 195 | - foreach($reflection->getProperties() as $property) { |
|
| 196 | - if (count($property->getAttributes(Inject::class)) == 0 ) { |
|
| 195 | + foreach ($reflection->getProperties() as $property) { |
|
| 196 | + if (count($property->getAttributes(Inject::class)) == 0) { |
|
| 197 | 197 | continue; |
| 198 | 198 | } |
| 199 | 199 | $type = $property->getType(); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $propertyValue = $this->bindings->has("$$name:$typeName") |
| 204 | 204 | ? $this->resolve($typeName, $name) |
| 205 | 205 | : $this->resolve($typeName); |
| 206 | - if($propertyValue === null) { |
|
| 206 | + if ($propertyValue === null) { |
|
| 207 | 207 | throw new exceptions\InjectionException("Failed to resolve a value for property."); |
| 208 | 208 | } |
| 209 | 209 | $property->setValue($instance, $propertyValue); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // Methods |
| 216 | - foreach($reflection->getMethods() as $method) { |
|
| 216 | + foreach ($reflection->getMethods() as $method) { |
|
| 217 | 217 | if (count($method->getAttributes(Inject::class)) == 0) { |
| 218 | 218 | continue; |
| 219 | 219 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @return mixed |
| 230 | 230 | * @throws exceptions\ResolutionException |
| 231 | 231 | */ |
| 232 | - private function getInstance(string|callable $class): mixed |
|
| 232 | + private function getInstance(string | callable $class): mixed |
|
| 233 | 233 | { |
| 234 | 234 | // If the class is a function call it as a factory. |
| 235 | 235 | if (is_callable($class)) { |