@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | public function __construct( |
| 34 | 34 | protected readonly State $state, |
| 35 | - ) { |
|
| 35 | + ){ |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function bind(string $alias, mixed $resolver): void |
| 42 | 42 | { |
| 43 | - if ($resolver instanceof Inflector && (\interface_exists($alias) || \class_exists($alias))) { |
|
| 43 | + if ($resolver instanceof Inflector && (\interface_exists($alias) || \class_exists($alias))){ |
|
| 44 | 44 | $this->state->inflectors[$alias][] = $resolver; |
| 45 | 45 | return; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - try { |
|
| 48 | + try{ |
|
| 49 | 49 | $config = $this->makeConfig($resolver, false); |
| 50 | - } catch (\Throwable $e) { |
|
| 50 | + }catch (\Throwable $e){ |
|
| 51 | 51 | throw $this->invalidBindingException($alias, $e); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function bindSingleton(string $alias, mixed $resolver): void |
| 61 | 61 | { |
| 62 | - try { |
|
| 62 | + try{ |
|
| 63 | 63 | $config = $this->makeConfig($resolver, true); |
| 64 | - } catch (\Throwable $e) { |
|
| 64 | + }catch (\Throwable $e){ |
|
| 65 | 65 | throw $this->invalidBindingException($alias, $e); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | $bindings = &$this->state->bindings; |
| 74 | 74 | |
| 75 | 75 | $flags = []; |
| 76 | - while ($binding = $bindings[$alias] ?? null and $binding::class === Alias::class) { |
|
| 76 | + while ($binding = $bindings[$alias] ?? null and $binding::class === Alias::class){ |
|
| 77 | 77 | //Checking alias tree |
| 78 | - if ($flags[$binding->alias] ?? false) { |
|
| 78 | + if ($flags[$binding->alias] ?? false){ |
|
| 79 | 79 | return $binding->alias === $alias ?: throw new Exception('Circular alias detected'); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (\array_key_exists($alias, $this->state->singletons)) { |
|
| 82 | + if (\array_key_exists($alias, $this->state->singletons)){ |
|
| 83 | 83 | return true; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | public function removeInjector(string $class): void |
| 105 | 105 | { |
| 106 | 106 | unset($this->state->injectors[$class]); |
| 107 | - if (!isset($this->state->bindings[$class]) || $this->state->bindings[$class]::class !== Injectable::class) { |
|
| 107 | + if (!isset($this->state->bindings[$class]) || $this->state->bindings[$class]::class !== Injectable::class){ |
|
| 108 | 108 | return; |
| 109 | 109 | } |
| 110 | 110 | unset($this->state->bindings[$class]); |
@@ -112,20 +112,20 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public function hasInjector(string $class): bool |
| 114 | 114 | { |
| 115 | - if (\array_key_exists($class, $this->state->injectors)) { |
|
| 115 | + if (\array_key_exists($class, $this->state->injectors)){ |
|
| 116 | 116 | return true; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - try { |
|
| 119 | + try{ |
|
| 120 | 120 | $reflection = new \ReflectionClass($class); |
| 121 | - } catch (\ReflectionException $e) { |
|
| 121 | + }catch (\ReflectionException $e){ |
|
| 122 | 122 | throw new ContainerException($e->getMessage(), $e->getCode(), $e); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if ( |
| 126 | 126 | $reflection->implementsInterface(InjectableInterface::class) |
| 127 | 127 | && $reflection->hasConstant('INJECTOR') |
| 128 | - ) { |
|
| 128 | + ){ |
|
| 129 | 129 | $const = $reflection->getConstant('INJECTOR'); |
| 130 | 130 | $this->bindInjector($class, $const); |
| 131 | 131 | |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // check interfaces |
| 136 | - foreach ($this->state->injectors as $target => $injector) { |
|
| 136 | + foreach ($this->state->injectors as $target => $injector){ |
|
| 137 | 137 | if ( |
| 138 | 138 | (\class_exists($target, true) && $reflection->isSubclassOf($target)) |
| 139 | 139 | || |
| 140 | 140 | (\interface_exists($target, true) && $reflection->implementsInterface($target)) |
| 141 | - ) { |
|
| 141 | + ){ |
|
| 142 | 142 | $this->state->bindings[$class] = new Injectable($injector); |
| 143 | 143 | |
| 144 | 144 | return true; |
@@ -165,15 +165,15 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | private function makeConfigFromArray(array $resolver, bool $singleton): Binding |
| 167 | 167 | { |
| 168 | - if (\is_callable($resolver)) { |
|
| 168 | + if (\is_callable($resolver)){ |
|
| 169 | 169 | return new Factory($resolver, $singleton); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // Validate lazy invokable array |
| 173 | - if (!isset($resolver[0]) || !isset($resolver[1]) || !\is_string($resolver[1]) || $resolver[1] === '') { |
|
| 173 | + if (!isset($resolver[0]) || !isset($resolver[1]) || !\is_string($resolver[1]) || $resolver[1] === ''){ |
|
| 174 | 174 | throw new InvalidArgumentException('Incompatible array declaration for resolver.'); |
| 175 | 175 | } |
| 176 | - if ((!\is_string($resolver[0]) && !\is_object($resolver[0])) || $resolver[0] === '') { |
|
| 176 | + if ((!\is_string($resolver[0]) && !\is_object($resolver[0])) || $resolver[0] === ''){ |
|
| 177 | 177 | throw new InvalidArgumentException('Incompatible array declaration for resolver.'); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | private function setBinding(string $alias, Binding $config): void |
| 193 | 193 | { |
| 194 | - if (isset($this->state->singletons[$alias])) { |
|
| 194 | + if (isset($this->state->singletons[$alias])){ |
|
| 195 | 195 | throw new SingletonOverloadException($alias); |
| 196 | 196 | } |
| 197 | 197 | |