@@ -13,7 +13,9 @@ |
||
| 13 | 13 | { |
| 14 | 14 | public function testCallAction(): void |
| 15 | 15 | { |
| 16 | - $event = new class() {}; |
|
| 16 | + $event = new class() |
|
| 17 | + { |
|
| 18 | +}; |
|
| 17 | 19 | |
| 18 | 20 | $dispatcher = m::mock(EventDispatcherInterface::class); |
| 19 | 21 | $dispatcher |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct( |
| 13 | 13 | private readonly CoreInterface $core |
| 14 | - ) { |
|
| 14 | + ){ |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function dispatch(object $event): object |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | { |
| 15 | 15 | public function __construct( |
| 16 | 16 | private readonly EventDispatcherInterface $dispatcher |
| 17 | - ) { |
|
| 17 | + ){ |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function __construct( |
| 48 | 48 | private readonly ConfiguratorInterface $configs |
| 49 | - ) { |
|
| 49 | + ){ |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function init(): void |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | FinalizerInterface $finalizer, |
| 71 | 71 | ?EventDispatcherInterface $eventDispatcher = null |
| 72 | 72 | ): void { |
| 73 | - if ($eventDispatcher !== null) { |
|
| 73 | + if ($eventDispatcher !== null){ |
|
| 74 | 74 | $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - foreach ($config->getProcessors() as $processor) { |
|
| 77 | + foreach ($config->getProcessors() as $processor){ |
|
| 78 | 78 | $processor = $this->autowire($processor, $container, $factory); |
| 79 | 79 | |
| 80 | 80 | \assert($processor instanceof ProcessorInterface); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $registry->process(); |
| 86 | 86 | }); |
| 87 | 87 | |
| 88 | - if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) { |
|
| 88 | + if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null){ |
|
| 89 | 89 | $finalizer->setEventDispatcher($eventDispatcher); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | /** |
| 94 | 94 | * @param TInterceptor $interceptor |
| 95 | 95 | */ |
| 96 | - public function addInterceptor(string|CoreInterceptorInterface|Container\Autowire $interceptor): void |
|
| 96 | + public function addInterceptor(string | CoreInterceptorInterface | Container\Autowire $interceptor): void |
|
| 97 | 97 | { |
| 98 | 98 | $this->configs->modify(EventsConfig::CONFIG, new Append('interceptors', null, $interceptor)); |
| 99 | 99 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | ): void { |
| 107 | 107 | $core = new InterceptableCore($core); |
| 108 | 108 | |
| 109 | - foreach ($config->getInterceptors() as $interceptor) { |
|
| 109 | + foreach ($config->getInterceptors() as $interceptor){ |
|
| 110 | 110 | $interceptor = $this->autowire($interceptor, $container, $factory); |
| 111 | 111 | |
| 112 | 112 | \assert($interceptor instanceof CoreInterceptorInterface); |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | $container->bindSingleton(EventDispatcherInterface::class, new EventDispatcher($core)); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - private function autowire(string|object $id, ContainerInterface $container, FactoryInterface $factory): object |
|
| 119 | + private function autowire(string | object $id, ContainerInterface $container, FactoryInterface $factory): object |
|
| 120 | 120 | { |
| 121 | - if (\is_string($id)) { |
|
| 121 | + if (\is_string($id)){ |
|
| 122 | 122 | $id = $container->get($id); |
| 123 | - } elseif ($id instanceof Autowire) { |
|
| 123 | + } elseif ($id instanceof Autowire){ |
|
| 124 | 124 | $id = $id->resolve($factory); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -70,11 +70,13 @@ discard block |
||
| 70 | 70 | FinalizerInterface $finalizer, |
| 71 | 71 | ?EventDispatcherInterface $eventDispatcher = null |
| 72 | 72 | ): void { |
| 73 | - if ($eventDispatcher !== null) { |
|
| 73 | + if ($eventDispatcher !== null) |
|
| 74 | + { |
|
| 74 | 75 | $this->initEventDispatcher(new Core($eventDispatcher), $config, $container, $factory); |
| 75 | 76 | } |
| 76 | 77 | |
| 77 | - foreach ($config->getProcessors() as $processor) { |
|
| 78 | + foreach ($config->getProcessors() as $processor) |
|
| 79 | + { |
|
| 78 | 80 | $processor = $this->autowire($processor, $container, $factory); |
| 79 | 81 | |
| 80 | 82 | \assert($processor instanceof ProcessorInterface); |
@@ -85,7 +87,8 @@ discard block |
||
| 85 | 87 | $registry->process(); |
| 86 | 88 | }); |
| 87 | 89 | |
| 88 | - if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) { |
|
| 90 | + if ($finalizer instanceof EventDispatcherAwareInterface && $eventDispatcher !== null) |
|
| 91 | + { |
|
| 89 | 92 | $finalizer->setEventDispatcher($eventDispatcher); |
| 90 | 93 | } |
| 91 | 94 | } |
@@ -106,7 +109,8 @@ discard block |
||
| 106 | 109 | ): void { |
| 107 | 110 | $core = new InterceptableCore($core); |
| 108 | 111 | |
| 109 | - foreach ($config->getInterceptors() as $interceptor) { |
|
| 112 | + foreach ($config->getInterceptors() as $interceptor) |
|
| 113 | + { |
|
| 110 | 114 | $interceptor = $this->autowire($interceptor, $container, $factory); |
| 111 | 115 | |
| 112 | 116 | \assert($interceptor instanceof CoreInterceptorInterface); |
@@ -118,9 +122,12 @@ discard block |
||
| 118 | 122 | |
| 119 | 123 | private function autowire(string|object $id, ContainerInterface $container, FactoryInterface $factory): object |
| 120 | 124 | { |
| 121 | - if (\is_string($id)) { |
|
| 125 | + if (\is_string($id)) |
|
| 126 | + { |
|
| 122 | 127 | $id = $container->get($id); |
| 123 | - } elseif ($id instanceof Autowire) { |
|
| 128 | + } |
|
| 129 | + elseif ($id instanceof Autowire) |
|
| 130 | + { |
|
| 124 | 131 | $id = $id->resolve($factory); |
| 125 | 132 | } |
| 126 | 133 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | public function __construct( |
| 14 | 14 | \ReflectionFunctionAbstract $reflection, |
| 15 | 15 | private readonly string $parameter |
| 16 | - ) { |
|
| 16 | + ){ |
|
| 17 | 17 | $pattern = "Invalid argument value type for the `$parameter` parameter when validating arguments for `%s`."; |
| 18 | 18 | parent::__construct($this->renderFunctionAndParameter($reflection, $pattern)); |
| 19 | 19 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | public function __toString(): string |
| 20 | 20 | { |
| 21 | - return $this->traces === [] ? '' : "Container trace list:\n" . $this->renderTraceList($this->traces); |
|
| 21 | + return $this->traces === [] ? '' : "Container trace list:\n".$this->renderTraceList($this->traces); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -34,19 +34,19 @@ discard block |
||
| 34 | 34 | public function push(bool $nextLevel, mixed ...$details): void |
| 35 | 35 | { |
| 36 | 36 | $trace = $details === [] ? null : new Trace($details); |
| 37 | - if ($nextLevel || $this->traces === []) { |
|
| 37 | + if ($nextLevel || $this->traces === []){ |
|
| 38 | 38 | $this->traces[] = $trace === null ? [] : [$trace]; |
| 39 | - } elseif ($trace !== null) { |
|
| 39 | + } elseif ($trace !== null){ |
|
| 40 | 40 | $this->traces[\array_key_last($this->traces)][] = $trace; |
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function pop(bool $previousLevel = false): void |
| 45 | 45 | { |
| 46 | - if ($this->traces === []) { |
|
| 46 | + if ($this->traces === []){ |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | - if ($previousLevel) { |
|
| 49 | + if ($previousLevel){ |
|
| 50 | 50 | \array_pop($this->traces); |
| 51 | 51 | return; |
| 52 | 52 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $result = []; |
| 69 | 69 | $i = 0; |
| 70 | - foreach ($blocks as $block) { |
|
| 70 | + foreach ($blocks as $block){ |
|
| 71 | 71 | \array_push($result, ...$this->blockToStringList($block, $i++)); |
| 72 | 72 | } |
| 73 | 73 | return \implode("\n", $result); |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | // Separator |
| 88 | 88 | $s = "\n"; |
| 89 | 89 | $nexPrefix = "$s$padding "; |
| 90 | - foreach ($items as $item) { |
|
| 91 | - $result[] = $firstPrefix . \str_replace($s, $nexPrefix, (string)$item); |
|
| 90 | + foreach ($items as $item){ |
|
| 91 | + $result[] = $firstPrefix.\str_replace($s, $nexPrefix, (string)$item); |
|
| 92 | 92 | } |
| 93 | 93 | return $result; |
| 94 | 94 | } |
@@ -34,19 +34,24 @@ discard block |
||
| 34 | 34 | public function push(bool $nextLevel, mixed ...$details): void |
| 35 | 35 | { |
| 36 | 36 | $trace = $details === [] ? null : new Trace($details); |
| 37 | - if ($nextLevel || $this->traces === []) { |
|
| 37 | + if ($nextLevel || $this->traces === []) |
|
| 38 | + { |
|
| 38 | 39 | $this->traces[] = $trace === null ? [] : [$trace]; |
| 39 | - } elseif ($trace !== null) { |
|
| 40 | + } |
|
| 41 | + elseif ($trace !== null) |
|
| 42 | + { |
|
| 40 | 43 | $this->traces[\array_key_last($this->traces)][] = $trace; |
| 41 | 44 | } |
| 42 | 45 | } |
| 43 | 46 | |
| 44 | 47 | public function pop(bool $previousLevel = false): void |
| 45 | 48 | { |
| 46 | - if ($this->traces === []) { |
|
| 49 | + if ($this->traces === []) |
|
| 50 | + { |
|
| 47 | 51 | return; |
| 48 | 52 | } |
| 49 | - if ($previousLevel) { |
|
| 53 | + if ($previousLevel) |
|
| 54 | + { |
|
| 50 | 55 | \array_pop($this->traces); |
| 51 | 56 | return; |
| 52 | 57 | } |
@@ -67,7 +72,8 @@ discard block |
||
| 67 | 72 | { |
| 68 | 73 | $result = []; |
| 69 | 74 | $i = 0; |
| 70 | - foreach ($blocks as $block) { |
|
| 75 | + foreach ($blocks as $block) |
|
| 76 | + { |
|
| 71 | 77 | \array_push($result, ...$this->blockToStringList($block, $i++)); |
| 72 | 78 | } |
| 73 | 79 | return \implode("\n", $result); |
@@ -87,7 +93,8 @@ discard block |
||
| 87 | 93 | // Separator |
| 88 | 94 | $s = "\n"; |
| 89 | 95 | $nexPrefix = "$s$padding "; |
| 90 | - foreach ($items as $item) { |
|
| 96 | + foreach ($items as $item) |
|
| 97 | + { |
|
| 91 | 98 | $result[] = $firstPrefix . \str_replace($s, $nexPrefix, (string)$item); |
| 92 | 99 | } |
| 93 | 100 | return $result; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | public function __construct( |
| 14 | 14 | private string $name, |
| 15 | 15 | private array $attributes = [] |
| 16 | - ) { |
|
| 16 | + ){ |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function getName(): string |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | return $this->attributes[$name] ?? null; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function setStatus(string|int $code, string $description = null): self |
|
| 60 | + public function setStatus(string | int $code, string $description = null): self |
|
| 61 | 61 | { |
| 62 | 62 | $this->status = new Status($code, $description); |
| 63 | 63 | |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly TelemetryConfig $config, |
| 18 | 18 | private readonly FactoryInterface $factory |
| 19 | - ) { |
|
| 19 | + ){ |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function getTracerFactory(?string $name = null): TracerFactoryInterface |
| 23 | 23 | { |
| 24 | 24 | $name ??= $this->config->getDefaultDriver(); |
| 25 | 25 | |
| 26 | - if (isset($this->drivers[$name])) { |
|
| 26 | + if (isset($this->drivers[$name])){ |
|
| 27 | 27 | return $this->drivers[$name]; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $config = $this->config->getDriverConfig($name); |
| 36 | 36 | |
| 37 | - if ($config instanceof TracerFactoryInterface) { |
|
| 37 | + if ($config instanceof TracerFactoryInterface){ |
|
| 38 | 38 | return $config; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if ($config instanceof Autowire) { |
|
| 41 | + if ($config instanceof Autowire){ |
|
| 42 | 42 | return $config->resolve($this->factory); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $name ??= $this->config->getDefaultDriver(); |
| 25 | 25 | |
| 26 | - if (isset($this->drivers[$name])) { |
|
| 26 | + if (isset($this->drivers[$name])) |
|
| 27 | + { |
|
| 27 | 28 | return $this->drivers[$name]; |
| 28 | 29 | } |
| 29 | 30 | |
@@ -34,11 +35,13 @@ discard block |
||
| 34 | 35 | { |
| 35 | 36 | $config = $this->config->getDriverConfig($name); |
| 36 | 37 | |
| 37 | - if ($config instanceof TracerFactoryInterface) { |
|
| 38 | + if ($config instanceof TracerFactoryInterface) |
|
| 39 | + { |
|
| 38 | 40 | return $config; |
| 39 | 41 | } |
| 40 | 42 | |
| 41 | - if ($config instanceof Autowire) { |
|
| 43 | + if ($config instanceof Autowire) |
|
| 44 | + { |
|
| 42 | 45 | return $config->resolve($this->factory); |
| 43 | 46 | } |
| 44 | 47 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function getDefaultDriver(): string |
| 27 | 27 | { |
| 28 | - if (!\is_string($this->config['default'])) { |
|
| 28 | + if (!\is_string($this->config['default'])){ |
|
| 29 | 29 | throw new InvalidArgumentException('Default trace driver config value must be a string'); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | * @return class-string<TracerFactoryInterface>|Autowire|TracerFactoryInterface |
| 38 | 38 | * @throws InvalidArgumentException |
| 39 | 39 | */ |
| 40 | - public function getDriverConfig(string $name): string|Autowire|TracerFactoryInterface |
|
| 40 | + public function getDriverConfig(string $name): string | Autowire | TracerFactoryInterface |
|
| 41 | 41 | { |
| 42 | - if (!isset($this->config['drivers'][$name])) { |
|
| 42 | + if (!isset($this->config['drivers'][$name])){ |
|
| 43 | 43 | throw new InvalidArgumentException( |
| 44 | 44 | \sprintf('Config for telemetry driver `%s` is not defined.', $name) |
| 45 | 45 | ); |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $driver = $this->config['drivers'][$name]; |
| 49 | 49 | |
| 50 | - if ($driver instanceof TracerFactoryInterface) { |
|
| 50 | + if ($driver instanceof TracerFactoryInterface){ |
|
| 51 | 51 | return $driver; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if (!\is_string($driver) && !$driver instanceof Autowire) { |
|
| 54 | + if (!\is_string($driver) && !$driver instanceof Autowire){ |
|
| 55 | 55 | throw new InvalidArgumentException( |
| 56 | 56 | \sprintf('Trace type value for `%s` must be a string or %s', $name, Autowire::class) |
| 57 | 57 | ); |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function getDefaultDriver(): string |
| 27 | 27 | { |
| 28 | - if (!\is_string($this->config['default'])) { |
|
| 28 | + if (!\is_string($this->config['default'])) |
|
| 29 | + { |
|
| 29 | 30 | throw new InvalidArgumentException('Default trace driver config value must be a string'); |
| 30 | 31 | } |
| 31 | 32 | |
@@ -39,7 +40,8 @@ discard block |
||
| 39 | 40 | */ |
| 40 | 41 | public function getDriverConfig(string $name): string|Autowire|TracerFactoryInterface |
| 41 | 42 | { |
| 42 | - if (!isset($this->config['drivers'][$name])) { |
|
| 43 | + if (!isset($this->config['drivers'][$name])) |
|
| 44 | + { |
|
| 43 | 45 | throw new InvalidArgumentException( |
| 44 | 46 | \sprintf('Config for telemetry driver `%s` is not defined.', $name) |
| 45 | 47 | ); |
@@ -47,11 +49,13 @@ discard block |
||
| 47 | 49 | |
| 48 | 50 | $driver = $this->config['drivers'][$name]; |
| 49 | 51 | |
| 50 | - if ($driver instanceof TracerFactoryInterface) { |
|
| 52 | + if ($driver instanceof TracerFactoryInterface) |
|
| 53 | + { |
|
| 51 | 54 | return $driver; |
| 52 | 55 | } |
| 53 | 56 | |
| 54 | - if (!\is_string($driver) && !$driver instanceof Autowire) { |
|
| 57 | + if (!\is_string($driver) && !$driver instanceof Autowire) |
|
| 58 | + { |
|
| 55 | 59 | throw new InvalidArgumentException( |
| 56 | 60 | \sprintf('Trace type value for `%s` must be a string or %s', $name, Autowire::class) |
| 57 | 61 | ); |