@@ -15,7 +15,7 @@ |
||
| 15 | 15 | private readonly ScopeInterface $scope, |
| 16 | 16 | private readonly ClockInterface $clock, |
| 17 | 17 | private readonly LoggerInterface $logger |
| 18 | - ) { |
|
| 18 | + ){ |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function trace( |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | private readonly ClockInterface $clock, |
| 20 | 20 | LogsInterface $logs, |
| 21 | 21 | string $channel = self::LOG_CHANNEL |
| 22 | - ) { |
|
| 22 | + ){ |
|
| 23 | 23 | $this->logger = $logs->getLogger($channel); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -11,8 +11,8 @@ |
||
| 11 | 11 | * @param non-empty-string|null $description |
| 12 | 12 | */ |
| 13 | 13 | public function __construct( |
| 14 | - public readonly string|int $code, |
|
| 14 | + public readonly string | int $code, |
|
| 15 | 15 | public readonly ?string $description = null |
| 16 | - ) { |
|
| 16 | + ){ |
|
| 17 | 17 | } |
| 18 | 18 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function __construct( |
| 13 | 13 | private readonly ?ScopeInterface $scope = new Container(), |
| 14 | - ) { |
|
| 14 | + ){ |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public function make(array $context = []): TracerInterface |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function __construct( |
| 38 | 38 | private readonly ConfiguratorInterface $config |
| 39 | - ) { |
|
| 39 | + ){ |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function init(EnvironmentInterface $env): void |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @param class-string<TracerFactoryInterface>|TracerFactoryInterface|Autowire $driver |
| 49 | 49 | */ |
| 50 | - public function registerTracer(string $name, string|TracerFactoryInterface|Autowire $driver): void |
|
| 50 | + public function registerTracer(string $name, string | TracerFactoryInterface | Autowire $driver): void |
|
| 51 | 51 | { |
| 52 | 52 | $this->config->modify( |
| 53 | 53 | TelemetryConfig::CONFIG, |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | public function __construct( |
| 14 | 14 | private readonly ContainerInterface $container |
| 15 | - ) { |
|
| 15 | + ){ |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function __invoke(array $record) |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | $context = $tracer->getContext(); |
| 24 | 24 | |
| 25 | - if (!empty($context)) { |
|
| 25 | + if (!empty($context)){ |
|
| 26 | 26 | $record['extra']['telemetry'] = $context; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -22,7 +22,8 @@ |
||
| 22 | 22 | |
| 23 | 23 | $context = $tracer->getContext(); |
| 24 | 24 | |
| 25 | - if (!empty($context)) { |
|
| 25 | + if (!empty($context)) |
|
| 26 | + { |
|
| 26 | 27 | $record['extra']['telemetry'] = $context; |
| 27 | 28 | } |
| 28 | 29 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * @param non-empty-string|int $code |
| 29 | 29 | * @param non-empty-string|null $description |
| 30 | 30 | */ |
| 31 | - public function setStatus(string|int $code, string $description = null): self; |
|
| 31 | + public function setStatus(string | int $code, string $description = null): self; |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Get the current span status. |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $core = $this->getCore(); |
| 47 | 47 | |
| 48 | - $core->setHandler(function () { |
|
| 48 | + $core->setHandler(function (){ |
|
| 49 | 49 | return 'hello world'; |
| 50 | 50 | }); |
| 51 | 51 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $core = $this->getCore(); |
| 69 | 69 | $core->setHandler( |
| 70 | - new CallableHandler(function () { |
|
| 70 | + new CallableHandler(function (){ |
|
| 71 | 71 | return 'hello world'; |
| 72 | 72 | }, new ResponseFactory(new HttpConfig(['headers' => []]))) |
| 73 | 73 | ); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | { |
| 81 | 81 | $core = $this->getCore(); |
| 82 | 82 | |
| 83 | - $core->setHandler(function ($req, $resp) { |
|
| 83 | + $core->setHandler(function ($req, $resp){ |
|
| 84 | 84 | return $resp->withAddedHeader('hello', 'value'); |
| 85 | 85 | }); |
| 86 | 86 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $core = $this->getCore(); |
| 95 | 95 | |
| 96 | - $core->setHandler(function ($req, $resp) { |
|
| 96 | + $core->setHandler(function ($req, $resp){ |
|
| 97 | 97 | echo 'hello!'; |
| 98 | 98 | |
| 99 | 99 | return $resp->withAddedHeader('hello', 'value'); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | { |
| 110 | 110 | $core = $this->getCore(); |
| 111 | 111 | |
| 112 | - $core->setHandler(function ($req, $resp) { |
|
| 112 | + $core->setHandler(function ($req, $resp){ |
|
| 113 | 113 | echo 'hello!'; |
| 114 | 114 | $resp->getBody()->write('world '); |
| 115 | 115 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $core = $this->getCore(); |
| 128 | 128 | |
| 129 | - $core->setHandler(function () { |
|
| 129 | + $core->setHandler(function (){ |
|
| 130 | 130 | ob_start(); |
| 131 | 131 | ob_start(); |
| 132 | 132 | echo 'hello!'; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | $core = $this->getCore(); |
| 149 | 149 | |
| 150 | - $core->setHandler(function () { |
|
| 150 | + $core->setHandler(function (){ |
|
| 151 | 151 | return [ |
| 152 | 152 | 'status' => 404, |
| 153 | 153 | 'message' => 'not found', |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $core = $this->getCore(); |
| 165 | 165 | |
| 166 | - $core->setHandler(function () { |
|
| 166 | + $core->setHandler(function (){ |
|
| 167 | 167 | return new Json([ |
| 168 | 168 | 'status' => 404, |
| 169 | 169 | 'message' => 'not found', |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | $core = $this->getCore([HeaderMiddleware::class]); |
| 181 | 181 | |
| 182 | - $core->setHandler(function () { |
|
| 182 | + $core->setHandler(function (){ |
|
| 183 | 183 | return 'hello?'; |
| 184 | 184 | }); |
| 185 | 185 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $core->getPipeline()->pushMiddleware(new Header2Middleware()); |
| 197 | 197 | $core->getPipeline()->riseMiddleware(new HeaderMiddleware()); |
| 198 | 198 | |
| 199 | - $core->setHandler(function () { |
|
| 199 | + $core->setHandler(function (){ |
|
| 200 | 200 | return 'hello?'; |
| 201 | 201 | }); |
| 202 | 202 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $core->getPipeline()->pushMiddleware(new HeaderMiddleware()); |
| 214 | 214 | $core->getPipeline()->riseMiddleware(new Header2Middleware()); |
| 215 | 215 | |
| 216 | - $core->setHandler(function () { |
|
| 216 | + $core->setHandler(function (){ |
|
| 217 | 217 | return 'hello?'; |
| 218 | 218 | }); |
| 219 | 219 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | { |
| 228 | 228 | $core = $this->getCore(); |
| 229 | 229 | |
| 230 | - $core->setHandler(function () { |
|
| 230 | + $core->setHandler(function (){ |
|
| 231 | 231 | $this->assertTrue($this->container->has(ServerRequestInterface::class)); |
| 232 | 232 | |
| 233 | 233 | return 'OK'; |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | $dispatcher |
| 261 | 261 | ->expects(self::exactly(2)) |
| 262 | 262 | ->method('dispatch') |
| 263 | - ->with($this->callback(static fn(RequestReceived|RequestHandled $event): bool => true)); |
|
| 263 | + ->with($this->callback(static fn(RequestReceived | RequestHandled $event): bool => true)); |
|
| 264 | 264 | $this->container->bind(EventDispatcherInterface::class, $dispatcher); |
| 265 | 265 | |
| 266 | 266 | $core = $this->getCore(); |
| 267 | 267 | |
| 268 | - $core->setHandler(function () { |
|
| 268 | + $core->setHandler(function (){ |
|
| 269 | 269 | return 'hello world'; |
| 270 | 270 | }); |
| 271 | 271 | |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $tracerFactory = m::mock(TracerFactoryInterface::class), |
| 288 | 288 | ); |
| 289 | 289 | |
| 290 | - $http->setHandler(function () { |
|
| 290 | + $http->setHandler(function (){ |
|
| 291 | 291 | return 'hello world'; |
| 292 | 292 | }); |
| 293 | 293 | |
@@ -45,7 +45,8 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $core = $this->getCore(); |
| 47 | 47 | |
| 48 | - $core->setHandler(function () { |
|
| 48 | + $core->setHandler(function () |
|
| 49 | + { |
|
| 49 | 50 | return 'hello world'; |
| 50 | 51 | }); |
| 51 | 52 | |
@@ -67,7 +68,8 @@ discard block |
||
| 67 | 68 | { |
| 68 | 69 | $core = $this->getCore(); |
| 69 | 70 | $core->setHandler( |
| 70 | - new CallableHandler(function () { |
|
| 71 | + new CallableHandler(function () |
|
| 72 | + { |
|
| 71 | 73 | return 'hello world'; |
| 72 | 74 | }, new ResponseFactory(new HttpConfig(['headers' => []]))) |
| 73 | 75 | ); |
@@ -80,7 +82,8 @@ discard block |
||
| 80 | 82 | { |
| 81 | 83 | $core = $this->getCore(); |
| 82 | 84 | |
| 83 | - $core->setHandler(function ($req, $resp) { |
|
| 85 | + $core->setHandler(function ($req, $resp) |
|
| 86 | + { |
|
| 84 | 87 | return $resp->withAddedHeader('hello', 'value'); |
| 85 | 88 | }); |
| 86 | 89 | |
@@ -93,7 +96,8 @@ discard block |
||
| 93 | 96 | { |
| 94 | 97 | $core = $this->getCore(); |
| 95 | 98 | |
| 96 | - $core->setHandler(function ($req, $resp) { |
|
| 99 | + $core->setHandler(function ($req, $resp) |
|
| 100 | + { |
|
| 97 | 101 | echo 'hello!'; |
| 98 | 102 | |
| 99 | 103 | return $resp->withAddedHeader('hello', 'value'); |
@@ -109,7 +113,8 @@ discard block |
||
| 109 | 113 | { |
| 110 | 114 | $core = $this->getCore(); |
| 111 | 115 | |
| 112 | - $core->setHandler(function ($req, $resp) { |
|
| 116 | + $core->setHandler(function ($req, $resp) |
|
| 117 | + { |
|
| 113 | 118 | echo 'hello!'; |
| 114 | 119 | $resp->getBody()->write('world '); |
| 115 | 120 | |
@@ -126,7 +131,8 @@ discard block |
||
| 126 | 131 | { |
| 127 | 132 | $core = $this->getCore(); |
| 128 | 133 | |
| 129 | - $core->setHandler(function () { |
|
| 134 | + $core->setHandler(function () |
|
| 135 | + { |
|
| 130 | 136 | ob_start(); |
| 131 | 137 | ob_start(); |
| 132 | 138 | echo 'hello!'; |
@@ -147,7 +153,8 @@ discard block |
||
| 147 | 153 | { |
| 148 | 154 | $core = $this->getCore(); |
| 149 | 155 | |
| 150 | - $core->setHandler(function () { |
|
| 156 | + $core->setHandler(function () |
|
| 157 | + { |
|
| 151 | 158 | return [ |
| 152 | 159 | 'status' => 404, |
| 153 | 160 | 'message' => 'not found', |
@@ -163,7 +170,8 @@ discard block |
||
| 163 | 170 | { |
| 164 | 171 | $core = $this->getCore(); |
| 165 | 172 | |
| 166 | - $core->setHandler(function () { |
|
| 173 | + $core->setHandler(function () |
|
| 174 | + { |
|
| 167 | 175 | return new Json([ |
| 168 | 176 | 'status' => 404, |
| 169 | 177 | 'message' => 'not found', |
@@ -179,7 +187,8 @@ discard block |
||
| 179 | 187 | { |
| 180 | 188 | $core = $this->getCore([HeaderMiddleware::class]); |
| 181 | 189 | |
| 182 | - $core->setHandler(function () { |
|
| 190 | + $core->setHandler(function () |
|
| 191 | + { |
|
| 183 | 192 | return 'hello?'; |
| 184 | 193 | }); |
| 185 | 194 | |
@@ -196,7 +205,8 @@ discard block |
||
| 196 | 205 | $core->getPipeline()->pushMiddleware(new Header2Middleware()); |
| 197 | 206 | $core->getPipeline()->riseMiddleware(new HeaderMiddleware()); |
| 198 | 207 | |
| 199 | - $core->setHandler(function () { |
|
| 208 | + $core->setHandler(function () |
|
| 209 | + { |
|
| 200 | 210 | return 'hello?'; |
| 201 | 211 | }); |
| 202 | 212 | |
@@ -213,7 +223,8 @@ discard block |
||
| 213 | 223 | $core->getPipeline()->pushMiddleware(new HeaderMiddleware()); |
| 214 | 224 | $core->getPipeline()->riseMiddleware(new Header2Middleware()); |
| 215 | 225 | |
| 216 | - $core->setHandler(function () { |
|
| 226 | + $core->setHandler(function () |
|
| 227 | + { |
|
| 217 | 228 | return 'hello?'; |
| 218 | 229 | }); |
| 219 | 230 | |
@@ -227,7 +238,8 @@ discard block |
||
| 227 | 238 | { |
| 228 | 239 | $core = $this->getCore(); |
| 229 | 240 | |
| 230 | - $core->setHandler(function () { |
|
| 241 | + $core->setHandler(function () |
|
| 242 | + { |
|
| 231 | 243 | $this->assertTrue($this->container->has(ServerRequestInterface::class)); |
| 232 | 244 | |
| 233 | 245 | return 'OK'; |
@@ -265,7 +277,8 @@ discard block |
||
| 265 | 277 | |
| 266 | 278 | $core = $this->getCore(); |
| 267 | 279 | |
| 268 | - $core->setHandler(function () { |
|
| 280 | + $core->setHandler(function () |
|
| 281 | + { |
|
| 269 | 282 | return 'hello world'; |
| 270 | 283 | }); |
| 271 | 284 | |
@@ -287,7 +300,8 @@ discard block |
||
| 287 | 300 | $tracerFactory = m::mock(TracerFactoryInterface::class), |
| 288 | 301 | ); |
| 289 | 302 | |
| 290 | - $http->setHandler(function () { |
|
| 303 | + $http->setHandler(function () |
|
| 304 | + { |
|
| 291 | 305 | return 'hello world'; |
| 292 | 306 | }); |
| 293 | 307 | |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | private readonly ContainerInterface $container, |
| 36 | 36 | ?ScopeInterface $scope = null, |
| 37 | 37 | ?TracerFactoryInterface $tracerFactory = null |
| 38 | - ) { |
|
| 39 | - foreach ($this->config->getMiddleware() as $middleware) { |
|
| 38 | + ){ |
|
| 39 | + foreach ($this->config->getMiddleware() as $middleware){ |
|
| 40 | 40 | $this->pipeline->pushMiddleware($this->container->get($middleware)); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | return $this->pipeline; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function setHandler(callable|RequestHandlerInterface $handler): self |
|
| 52 | + public function setHandler(callable | RequestHandlerInterface $handler): self |
|
| 53 | 53 | { |
| 54 | 54 | $this->handler = $handler instanceof RequestHandlerInterface |
| 55 | 55 | ? $handler |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $dispatcher?->dispatch(new RequestReceived($request)); |
| 72 | 72 | |
| 73 | - if ($this->handler === null) { |
|
| 73 | + if ($this->handler === null){ |
|
| 74 | 74 | throw new HttpException('Unable to run HttpCore, no handler is set.'); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | traceKind: TraceKind::SERVER |
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | - foreach ($tracer->getContext() as $key => $value) { |
|
| 113 | + foreach ($tracer->getContext() as $key => $value){ |
|
| 114 | 114 | $response = $response->withHeader($key, $value); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -36,7 +36,8 @@ discard block |
||
| 36 | 36 | ?ScopeInterface $scope = null, |
| 37 | 37 | ?TracerFactoryInterface $tracerFactory = null |
| 38 | 38 | ) { |
| 39 | - foreach ($this->config->getMiddleware() as $middleware) { |
|
| 39 | + foreach ($this->config->getMiddleware() as $middleware) |
|
| 40 | + { |
|
| 40 | 41 | $this->pipeline->pushMiddleware($this->container->get($middleware)); |
| 41 | 42 | } |
| 42 | 43 | |
@@ -70,7 +71,8 @@ discard block |
||
| 70 | 71 | |
| 71 | 72 | $dispatcher?->dispatch(new RequestReceived($request)); |
| 72 | 73 | |
| 73 | - if ($this->handler === null) { |
|
| 74 | + if ($this->handler === null) |
|
| 75 | + { |
|
| 74 | 76 | throw new HttpException('Unable to run HttpCore, no handler is set.'); |
| 75 | 77 | } |
| 76 | 78 | |
@@ -110,7 +112,8 @@ discard block |
||
| 110 | 112 | traceKind: TraceKind::SERVER |
| 111 | 113 | ); |
| 112 | 114 | |
| 113 | - foreach ($tracer->getContext() as $key => $value) { |
|
| 115 | + foreach ($tracer->getContext() as $key => $value) |
|
| 116 | + { |
|
| 114 | 117 | $response = $response->withHeader($key, $value); |
| 115 | 118 | } |
| 116 | 119 | |