| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Spiral\Telemetry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Spiral\Core\BinderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Spiral\Core\Container; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Spiral\Core\ContainerScope; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Spiral\Core\InvokerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Spiral\Core\Scope; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Spiral\Core\ScopeInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @internal The component is under development. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * Something may be changed in the future. We will stable it soon. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * Feedback is welcome {@link https://github.com/spiral/framework/discussions/822}. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | abstract class AbstractTracer implements TracerInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 | 626 |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 | 626 |  |         private readonly ?ScopeInterface $scope = new Container(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     ) {} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * @throws \Throwable | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 27 | 177 |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     final protected function runScope(SpanInterface $span, callable $callback): mixed | 
            
                                                                        
                            
            
                                    
            
            
                | 29 | 177 |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 30 | 177 |  |         $container = ContainerScope::getContainer(); | 
            
                                                                        
                            
            
                                    
            
            
                | 31 | 112 |  |         if ($container === null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 32 | 112 |  |             return $this->scope->runScope([ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 33 | 112 |  |                 SpanInterface::class => $span, | 
            
                                                                        
                            
            
                                    
            
            
                | 34 | 112 |  |                 TracerInterface::class => $this, | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |             ], static fn(InvokerInterface $invoker): mixed => $invoker->invoke($callback)); | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 37 | 125 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 | 124 |  |         if ($container instanceof Container) { | 
            
                                                                        
                            
            
                                    
            
            
                | 39 | 124 |  |             $invoker = $container; | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |             $binder = $container; | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 42 | 1 |  |             /** @var InvokerInterface $invoker */ | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |             $invoker = $container->get(InvokerInterface::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 44 | 1 |  |             /** @var BinderInterface $binder */ | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |             $binder = $container->get(BinderInterface::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 48 | 125 |  |         try { | 
            
                                                                        
                            
            
                                    
            
            
                | 49 | 65 |  |             $prevSpan = $container->get(SpanInterface::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 50 | 65 |  |         } catch (\Throwable) { | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |             $prevSpan = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 53 | 125 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |         $binder->bindSingleton(SpanInterface::class, $span); | 
            
                                                                        
                            
            
                                    
            
            
                | 55 | 125 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         try { | 
            
                                                                        
                            
            
                                    
            
            
                | 57 | 125 |  |             return $prevSpan === null | 
            
                                                                        
                            
            
                                    
            
            
                | 58 | 65 |  |                 ? $this->scope->runScope( | 
            
                                                                        
                            
            
                                    
            
            
                | 59 | 125 |  |                     new Scope( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |                         bindings: [ | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |                             TracerInterface::class => $this, | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |                         ], | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |                     ), | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |                     static fn(): mixed => $invoker->invoke($callback), | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |                 ) | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |                 : $invoker->invoke($callback); | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |         } finally { | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |             $prevSpan === null | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |                 ? $binder->removeBinding(SpanInterface::class) | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |                 : $binder->bindSingleton(SpanInterface::class, $prevSpan); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 73 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.