@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | public function __construct( |
| 21 | 21 | private readonly ?ScopeInterface $scope = new Container(), |
| 22 | - ) {} |
|
| 22 | + ){} |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @throws \Throwable |
@@ -27,38 +27,38 @@ discard block |
||
| 27 | 27 | final protected function runScope(SpanInterface $span, callable $callback): mixed |
| 28 | 28 | { |
| 29 | 29 | $container = ContainerScope::getContainer(); |
| 30 | - if ($container === null) { |
|
| 30 | + if ($container === null){ |
|
| 31 | 31 | return $this->scope->runScope([ |
| 32 | 32 | SpanInterface::class => $span, |
| 33 | 33 | TracerInterface::class => $this, |
| 34 | 34 | ], static fn(InvokerInterface $invoker): mixed => $invoker->invoke($callback)); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if ($container instanceof Container) { |
|
| 37 | + if ($container instanceof Container){ |
|
| 38 | 38 | $invoker = $container; |
| 39 | 39 | $binder = $container; |
| 40 | - } else { |
|
| 40 | + }else{ |
|
| 41 | 41 | /** @var InvokerInterface $invoker */ |
| 42 | 42 | $invoker = $container->get(InvokerInterface::class); |
| 43 | 43 | /** @var BinderInterface $binder */ |
| 44 | 44 | $binder = $container->get(BinderInterface::class); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - try { |
|
| 47 | + try{ |
|
| 48 | 48 | $prevSpan = $container->get(SpanInterface::class); |
| 49 | - } catch (\Throwable) { |
|
| 49 | + }catch (\Throwable){ |
|
| 50 | 50 | $prevSpan = null; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $binder->bindSingleton(SpanInterface::class, $span); |
| 54 | 54 | |
| 55 | - try { |
|
| 55 | + try{ |
|
| 56 | 56 | return $prevSpan === null |
| 57 | 57 | ? $this->scope->runScope([ |
| 58 | 58 | TracerInterface::class => $this, |
| 59 | - ], static fn(): mixed => $invoker->invoke($callback)) |
|
| 59 | + ], static fn() : mixed => $invoker->invoke($callback)) |
|
| 60 | 60 | : $invoker->invoke($callback); |
| 61 | - } finally { |
|
| 61 | + }finally{ |
|
| 62 | 62 | $prevSpan === null |
| 63 | 63 | ? $binder->removeBinding(SpanInterface::class) |
| 64 | 64 | : $binder->bindSingleton(SpanInterface::class, $prevSpan); |
@@ -19,7 +19,8 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | public function __construct( |
| 21 | 21 | private readonly ?ScopeInterface $scope = new Container(), |
| 22 | - ) {} |
|
| 22 | + ) { |
|
| 23 | +} |
|
| 23 | 24 | |
| 24 | 25 | /** |
| 25 | 26 | * @throws \Throwable |
@@ -27,38 +28,48 @@ discard block |
||
| 27 | 28 | final protected function runScope(SpanInterface $span, callable $callback): mixed |
| 28 | 29 | { |
| 29 | 30 | $container = ContainerScope::getContainer(); |
| 30 | - if ($container === null) { |
|
| 31 | + if ($container === null) |
|
| 32 | + { |
|
| 31 | 33 | return $this->scope->runScope([ |
| 32 | 34 | SpanInterface::class => $span, |
| 33 | 35 | TracerInterface::class => $this, |
| 34 | 36 | ], static fn(InvokerInterface $invoker): mixed => $invoker->invoke($callback)); |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | - if ($container instanceof Container) { |
|
| 39 | + if ($container instanceof Container) |
|
| 40 | + { |
|
| 38 | 41 | $invoker = $container; |
| 39 | 42 | $binder = $container; |
| 40 | - } else { |
|
| 43 | + } |
|
| 44 | + else |
|
| 45 | + { |
|
| 41 | 46 | /** @var InvokerInterface $invoker */ |
| 42 | 47 | $invoker = $container->get(InvokerInterface::class); |
| 43 | 48 | /** @var BinderInterface $binder */ |
| 44 | 49 | $binder = $container->get(BinderInterface::class); |
| 45 | 50 | } |
| 46 | 51 | |
| 47 | - try { |
|
| 52 | + try |
|
| 53 | + { |
|
| 48 | 54 | $prevSpan = $container->get(SpanInterface::class); |
| 49 | - } catch (\Throwable) { |
|
| 55 | + } |
|
| 56 | + catch (\Throwable) |
|
| 57 | + { |
|
| 50 | 58 | $prevSpan = null; |
| 51 | 59 | } |
| 52 | 60 | |
| 53 | 61 | $binder->bindSingleton(SpanInterface::class, $span); |
| 54 | 62 | |
| 55 | - try { |
|
| 63 | + try |
|
| 64 | + { |
|
| 56 | 65 | return $prevSpan === null |
| 57 | 66 | ? $this->scope->runScope([ |
| 58 | 67 | TracerInterface::class => $this, |
| 59 | 68 | ], static fn(): mixed => $invoker->invoke($callback)) |
| 60 | 69 | : $invoker->invoke($callback); |
| 61 | - } finally { |
|
| 70 | + } |
|
| 71 | + finally |
|
| 72 | + { |
|
| 62 | 73 | $prevSpan === null |
| 63 | 74 | ? $binder->removeBinding(SpanInterface::class) |
| 64 | 75 | : $binder->bindSingleton(SpanInterface::class, $prevSpan); |