@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function to($value): Bindings |
| 59 | 59 | { |
| 60 | - if(isset($this->bindings[$this->activeKey])) { |
|
| 60 | + if (isset($this->bindings[$this->activeKey])) { |
|
| 61 | 61 | $this->bindings[$this->activeKey]['binding'] = $value; |
| 62 | 62 | } else { |
| 63 | 63 | $this->bindings[$this->activeKey] = ['binding' => $value, 'calls' => [], 'properties' => []]; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function get(string $key): array |
| 80 | 80 | { |
| 81 | 81 | $binding = $this->bindings[$key]; |
| 82 | - if(!isset($binding['binding'])) { |
|
| 82 | + if (!isset($binding['binding'])) { |
|
| 83 | 83 | $binding['binding'] = $key; |
| 84 | 84 | } |
| 85 | 85 | return $binding; |
@@ -113,16 +113,16 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | private function setArrayBinding(array $binding): void |
| 115 | 115 | { |
| 116 | - if(isset($binding[0])) { |
|
| 116 | + if (isset($binding[0])) { |
|
| 117 | 117 | $this->to($binding[0]); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if(isset($binding['calls'])){ |
|
| 121 | - foreach($binding['calls'] as $key => $call) { |
|
| 122 | - if(is_string($call)) { |
|
| 120 | + if (isset($binding['calls'])) { |
|
| 121 | + foreach ($binding['calls'] as $key => $call) { |
|
| 122 | + if (is_string($call)) { |
|
| 123 | 123 | $method = $call; |
| 124 | 124 | $parameters = []; |
| 125 | - } else if(is_array($call)) { |
|
| 125 | + } else if (is_array($call)) { |
|
| 126 | 126 | $method = $key; |
| 127 | 127 | $parameters = $call; |
| 128 | 128 | } |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function merge(array $bindings): void |
| 144 | 144 | { |
| 145 | - foreach($bindings as $key => $binding) { |
|
| 145 | + foreach ($bindings as $key => $binding) { |
|
| 146 | 146 | $this->activeKey = $key; |
| 147 | - if(is_array($binding)) { |
|
| 147 | + if (is_array($binding)) { |
|
| 148 | 148 | $this->setArrayBinding($binding); |
| 149 | 149 | } else { |
| 150 | 150 | $this->bindings[$key] = ['binding' => $binding, 'calls' => [], 'properties' => []]; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $instance = $this->getInstance($resolvedClass['binding']); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - foreach($resolvedClass['calls'] ?? [] as $calls) { |
|
| 125 | + foreach ($resolvedClass['calls'] ?? [] as $calls) { |
|
| 126 | 126 | $method = new \ReflectionMethod($instance, $calls[0]); |
| 127 | 127 | $method->invokeArgs($instance, $this->getMethodArguments($method, $calls[1])); |
| 128 | 128 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | private function resolveArgument($argument, $class) |
| 156 | 156 | { |
| 157 | - if($class && is_string($argument)) { |
|
| 157 | + if ($class && is_string($argument)) { |
|
| 158 | 158 | return $this->resolve($argument); |
| 159 | 159 | } |
| 160 | 160 | return $argument; |
@@ -179,8 +179,7 @@ discard block |
||
| 179 | 179 | if (isset($methodArguments[$parameter->getName()])) { |
| 180 | 180 | $argumentValues[] = $this->resolveArgument($methodArguments[$parameter->getName()], $className); |
| 181 | 181 | } else { |
| 182 | - $argumentValues[] = $className ? $this->resolve($className) : |
|
| 183 | - ($parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null); |
|
| 182 | + $argumentValues[] = $className ? $this->resolve($className) : ($parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null); |
|
| 184 | 183 | } |
| 185 | 184 | } |
| 186 | 185 | return $argumentValues; |
@@ -205,8 +204,8 @@ discard block |
||
| 205 | 204 | private function injectAttributed(mixed $instance, \ReflectionClass $reflection): void |
| 206 | 205 | { |
| 207 | 206 | // Properties |
| 208 | - foreach($reflection->getProperties() as $property) { |
|
| 209 | - if (count($property->getAttributes(Inject::class)) == 0 ) { |
|
| 207 | + foreach ($reflection->getProperties() as $property) { |
|
| 208 | + if (count($property->getAttributes(Inject::class)) == 0) { |
|
| 210 | 209 | continue; |
| 211 | 210 | } |
| 212 | 211 | $type = $property->getType(); |
@@ -226,7 +225,7 @@ discard block |
||
| 226 | 225 | * @return mixed |
| 227 | 226 | * @throws exceptions\ResolutionException |
| 228 | 227 | */ |
| 229 | - private function getInstance(string|callable $class): mixed |
|
| 228 | + private function getInstance(string | callable $class): mixed |
|
| 230 | 229 | { |
| 231 | 230 | // If the class is a function call it as a factory. |
| 232 | 231 | if (is_callable($class)) { |