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