@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | public function __construct( |
| 20 | 20 | public readonly \Closure $inflector, |
| 21 | - ) { |
|
| 21 | + ){ |
|
| 22 | 22 | $this->parametersCount = (new \ReflectionFunction($inflector))->getNumberOfParameters(); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct( |
| 13 | 13 | public \WeakReference $reference, |
| 14 | - ) { |
|
| 14 | + ){ |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function __toString(): string |
@@ -11,11 +11,11 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct( |
| 13 | 13 | public readonly object $value, |
| 14 | - ) { |
|
| 14 | + ){ |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function __toString(): string |
| 18 | 18 | { |
| 19 | - return 'Shared object of class ' . $this->value::class; |
|
| 19 | + return 'Shared object of class '.$this->value::class; |
|
| 20 | 20 | } |
| 21 | 21 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | public function __construct( |
| 13 | 13 | public readonly string $alias, |
| 14 | 14 | public readonly bool $singleton = false, |
| 15 | - ) { |
|
| 15 | + ){ |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function __toString(): string |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | public function __construct( |
| 16 | 16 | public readonly array $factory, |
| 17 | 17 | public readonly bool $singleton = false, |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function __toString(): string |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | public function __construct( |
| 19 | 19 | callable $callable, |
| 20 | 20 | public readonly bool $singleton = false, |
| 21 | - ) { |
|
| 21 | + ){ |
|
| 22 | 22 | $this->factory = $callable(...); |
| 23 | 23 | $this->parametersCount = (new \ReflectionFunction($this->factory))->getNumberOfParameters(); |
| 24 | 24 | $this->definition = match (true) { |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | \is_object($callable[0]) ? $callable[0]::class : $callable[0], |
| 29 | 29 | $callable[1] |
| 30 | 30 | ), |
| 31 | - \is_object($callable) && $callable::class !== \Closure::class => 'object ' . $callable::class, |
|
| 31 | + \is_object($callable) && $callable::class !== \Closure::class => 'object '.$callable::class, |
|
| 32 | 32 | default => null, |
| 33 | 33 | }; |
| 34 | 34 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | public function __construct( |
| 15 | 15 | public readonly AutowireAlias $autowire, |
| 16 | 16 | public readonly bool $singleton = false, |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function __toString(): string |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | public const DEFAULT_ROOT_SCOPE_NAME = 'root'; |
| 50 | 50 | |
| 51 | 51 | private Internal\State $state; |
| 52 | - private ResolverInterface|Internal\Resolver $resolver; |
|
| 53 | - private FactoryInterface|Internal\Factory $factory; |
|
| 54 | - private ContainerInterface|Internal\Container $container; |
|
| 55 | - private BinderInterface|Internal\Binder $binder; |
|
| 56 | - private InvokerInterface|Internal\Invoker $invoker; |
|
| 52 | + private ResolverInterface | Internal\Resolver $resolver; |
|
| 53 | + private FactoryInterface | Internal\Factory $factory; |
|
| 54 | + private ContainerInterface | Internal\Container $container; |
|
| 55 | + private BinderInterface | Internal\Binder $binder; |
|
| 56 | + private InvokerInterface | Internal\Invoker $invoker; |
|
| 57 | 57 | private Internal\Scope $scope; |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function __construct( |
| 63 | 63 | private Config $config = new Config(), |
| 64 | 64 | ?string $scopeName = self::DEFAULT_ROOT_SCOPE_NAME, |
| 65 | - ) { |
|
| 65 | + ){ |
|
| 66 | 66 | $this->initServices($this, $scopeName); |
| 67 | 67 | |
| 68 | 68 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * |
| 141 | 141 | * @psalm-suppress InvalidArgument, InvalidCast |
| 142 | 142 | */ |
| 143 | - public function get(string|Autowire $id, string $context = null): mixed |
|
| 143 | + public function get(string | Autowire $id, string $context = null): mixed |
|
| 144 | 144 | { |
| 145 | 145 | /** @psalm-suppress TooManyArguments */ |
| 146 | 146 | return $this->container->get($id, $context); |
@@ -167,26 +167,26 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | $binds = &$this->state->bindings; |
| 169 | 169 | $cleanup = $previous = []; |
| 170 | - foreach ($bindings as $alias => $resolver) { |
|
| 171 | - if (isset($binds[$alias])) { |
|
| 170 | + foreach ($bindings as $alias => $resolver){ |
|
| 171 | + if (isset($binds[$alias])){ |
|
| 172 | 172 | $previous[$alias] = $binds[$alias]; |
| 173 | - } else { |
|
| 173 | + }else{ |
|
| 174 | 174 | $cleanup[] = $alias; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $this->binder->bind($alias, $resolver); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - try { |
|
| 180 | + try{ |
|
| 181 | 181 | return ContainerScope::getContainer() !== $this |
| 182 | 182 | ? ContainerScope::runScope($this, $scope) |
| 183 | 183 | : $scope($this); |
| 184 | - } finally { |
|
| 185 | - foreach ($previous as $alias => $resolver) { |
|
| 184 | + }finally{ |
|
| 185 | + foreach ($previous as $alias => $resolver){ |
|
| 186 | 186 | $binds[$alias] = $resolver; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - foreach ($cleanup as $alias) { |
|
| 189 | + foreach ($cleanup as $alias){ |
|
| 190 | 190 | unset($binds[$alias]); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -200,32 +200,32 @@ discard block |
||
| 200 | 200 | // Open scope |
| 201 | 201 | $container = new self($this->config, $name); |
| 202 | 202 | |
| 203 | - try { |
|
| 203 | + try{ |
|
| 204 | 204 | // Configure scope |
| 205 | 205 | $container->scope->setParent($this, $this->scope); |
| 206 | 206 | |
| 207 | 207 | // Add specific bindings |
| 208 | - foreach ($bindings as $alias => $resolver) { |
|
| 208 | + foreach ($bindings as $alias => $resolver){ |
|
| 209 | 209 | $container->binder->bind($alias, $resolver); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | return ContainerScope::runScope( |
| 213 | 213 | $container, |
| 214 | 214 | static function (self $container) use ($autowire, $closure): mixed { |
| 215 | - try { |
|
| 215 | + try{ |
|
| 216 | 216 | return $autowire |
| 217 | 217 | ? $container->invoke($closure) |
| 218 | 218 | : $closure($container); |
| 219 | - } finally { |
|
| 219 | + }finally{ |
|
| 220 | 220 | $container->closeScope(); |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | ); |
| 224 | - } finally { |
|
| 224 | + }finally{ |
|
| 225 | 225 | // Check the container has not been leaked |
| 226 | 226 | $link = \WeakReference::create($container); |
| 227 | 227 | unset($container); |
| 228 | - if ($link->get() !== null) { |
|
| 228 | + if ($link->get() !== null){ |
|
| 229 | 229 | throw new ScopeContainerLeakedException($name, $this->scope->getParentScopeNames()); |
| 230 | 230 | } |
| 231 | 231 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @psalm-param TResolver $resolver |
| 259 | 259 | */ |
| 260 | - public function bindSingleton(string $alias, string|array|callable|object $resolver): void |
|
| 260 | + public function bindSingleton(string $alias, string | array | callable | object $resolver): void |
|
| 261 | 261 | { |
| 262 | 262 | $this->binder->bindSingleton($alias, $resolver); |
| 263 | 263 | } |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | ]); |
| 328 | 328 | |
| 329 | 329 | // Create container services |
| 330 | - foreach ($container->config as $property => $class) { |
|
| 331 | - if (\property_exists($container, $property)) { |
|
| 330 | + foreach ($container->config as $property => $class){ |
|
| 331 | + if (\property_exists($container, $property)){ |
|
| 332 | 332 | $container->$property = $constructor->get($property, $class); |
| 333 | 333 | } |
| 334 | 334 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | private function closeScope(): void |
| 343 | 343 | { |
| 344 | 344 | /** @psalm-suppress RedundantPropertyInitializationCheck */ |
| 345 | - if (!isset($this->scope)) { |
|
| 345 | + if (!isset($this->scope)){ |
|
| 346 | 346 | $this->destruct(); |
| 347 | 347 | return; |
| 348 | 348 | } |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | // Run finalizers |
| 353 | 353 | $errors = []; |
| 354 | - foreach ($this->state->finalizers as $finalizer) { |
|
| 355 | - try { |
|
| 354 | + foreach ($this->state->finalizers as $finalizer){ |
|
| 355 | + try{ |
|
| 356 | 356 | $this->invoker->invoke($finalizer); |
| 357 | - } catch (\Throwable $e) { |
|
| 357 | + }catch (\Throwable $e){ |
|
| 358 | 358 | $errors[] = $e; |
| 359 | 359 | } |
| 360 | 360 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | $this->destruct(); |
| 364 | 364 | |
| 365 | 365 | // Throw collected errors |
| 366 | - if ($errors !== []) { |
|
| 366 | + if ($errors !== []){ |
|
| 367 | 367 | throw new FinalizersException($scopeName, $errors); |
| 368 | 368 | } |
| 369 | 369 | } |