@@ -66,7 +66,8 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function handle(Request $request): Response |
| 68 | 68 | { |
| 69 | - if ($this->controller === null) { |
|
| 69 | + if ($this->controller === null) |
|
| 70 | + { |
|
| 70 | 71 | throw new HandlerException('Controller and action pair is not set'); |
| 71 | 72 | } |
| 72 | 73 | |
@@ -76,7 +77,8 @@ discard block |
||
| 76 | 77 | $output = $result = null; |
| 77 | 78 | |
| 78 | 79 | $response = $this->responseFactory->createResponse(200); |
| 79 | - try { |
|
| 80 | + try |
|
| 81 | + { |
|
| 80 | 82 | $action = $this->getAction($request); |
| 81 | 83 | |
| 82 | 84 | // run the core withing PSR-7 Request/Response scope |
@@ -99,14 +101,21 @@ discard block |
||
| 99 | 101 | ] |
| 100 | 102 | ) |
| 101 | 103 | ); |
| 102 | - } catch (ControllerException $e) { |
|
| 104 | + } |
|
| 105 | + catch (ControllerException $e) |
|
| 106 | + { |
|
| 103 | 107 | \ob_get_clean(); |
| 104 | 108 | throw $this->mapException($e); |
| 105 | - } catch (\Throwable $e) { |
|
| 109 | + } |
|
| 110 | + catch (\Throwable $e) |
|
| 111 | + { |
|
| 106 | 112 | \ob_get_clean(); |
| 107 | 113 | throw $e; |
| 108 | - } finally { |
|
| 109 | - while (\ob_get_level() > $outputLevel + 1) { |
|
| 114 | + } |
|
| 115 | + finally |
|
| 116 | + { |
|
| 117 | + while (\ob_get_level() > $outputLevel + 1) |
|
| 118 | + { |
|
| 110 | 119 | $output = \ob_get_clean() . $output; |
| 111 | 120 | } |
| 112 | 121 | } |
@@ -120,7 +129,8 @@ discard block |
||
| 120 | 129 | |
| 121 | 130 | private function getAction(Request $request): string |
| 122 | 131 | { |
| 123 | - if ($this->verbActions) { |
|
| 132 | + if ($this->verbActions) |
|
| 133 | + { |
|
| 124 | 134 | return \strtolower($request->getMethod()) . \ucfirst($this->action); |
| 125 | 135 | } |
| 126 | 136 | |
@@ -136,21 +146,27 @@ discard block |
||
| 136 | 146 | */ |
| 137 | 147 | private function wrapResponse(Response $response, mixed $result = null, string $output = ''): Response |
| 138 | 148 | { |
| 139 | - if ($result instanceof Response) { |
|
| 140 | - if ($output !== '' && $result->getBody()->isWritable()) { |
|
| 149 | + if ($result instanceof Response) |
|
| 150 | + { |
|
| 151 | + if ($output !== '' && $result->getBody()->isWritable()) |
|
| 152 | + { |
|
| 141 | 153 | $result->getBody()->write($output); |
| 142 | 154 | } |
| 143 | 155 | |
| 144 | 156 | return $result; |
| 145 | 157 | } |
| 146 | 158 | |
| 147 | - if ($result instanceof \Generator) { |
|
| 159 | + if ($result instanceof \Generator) |
|
| 160 | + { |
|
| 148 | 161 | return $response->withBody(new GeneratorStream($result)); |
| 149 | 162 | } |
| 150 | 163 | |
| 151 | - if (\is_array($result) || $result instanceof \JsonSerializable) { |
|
| 164 | + if (\is_array($result) || $result instanceof \JsonSerializable) |
|
| 165 | + { |
|
| 152 | 166 | $response = $this->writeJson($response, $result); |
| 153 | - } else { |
|
| 167 | + } |
|
| 168 | + else |
|
| 169 | + { |
|
| 154 | 170 | $response->getBody()->write((string)$result); |
| 155 | 171 | } |
| 156 | 172 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | private readonly ScopeInterface $scope, |
| 39 | 39 | private readonly ResponseFactoryInterface $responseFactory, |
| 40 | 40 | ?TracerInterface $tracer = null |
| 41 | - ) { |
|
| 41 | + ){ |
|
| 42 | 42 | $this->tracer = $tracer ?? new NullTracer($scope); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function handle(Request $request): Response |
| 71 | 71 | { |
| 72 | - if ($this->controller === null) { |
|
| 72 | + if ($this->controller === null){ |
|
| 73 | 73 | throw new HandlerException('Controller and action pair is not set'); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $output = $result = null; |
| 80 | 80 | |
| 81 | 81 | $response = $this->responseFactory->createResponse(200); |
| 82 | - try { |
|
| 82 | + try{ |
|
| 83 | 83 | $action = $this->getAction($request); |
| 84 | 84 | |
| 85 | 85 | // run the core withing PSR-7 Request/Response scope |
@@ -102,29 +102,29 @@ discard block |
||
| 102 | 102 | ] |
| 103 | 103 | ) |
| 104 | 104 | ); |
| 105 | - } catch (ControllerException $e) { |
|
| 105 | + }catch (ControllerException $e){ |
|
| 106 | 106 | \ob_get_clean(); |
| 107 | 107 | throw $this->mapException($e); |
| 108 | - } catch (\Throwable $e) { |
|
| 108 | + }catch (\Throwable $e){ |
|
| 109 | 109 | \ob_get_clean(); |
| 110 | 110 | throw $e; |
| 111 | - } finally { |
|
| 112 | - while (\ob_get_level() > $outputLevel + 1) { |
|
| 113 | - $output = \ob_get_clean() . $output; |
|
| 111 | + }finally{ |
|
| 112 | + while (\ob_get_level() > $outputLevel + 1){ |
|
| 113 | + $output = \ob_get_clean().$output; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | return $this->wrapResponse( |
| 118 | 118 | $response, |
| 119 | 119 | $result, |
| 120 | - \ob_get_clean() . $output |
|
| 120 | + \ob_get_clean().$output |
|
| 121 | 121 | ); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | private function getAction(Request $request): string |
| 125 | 125 | { |
| 126 | - if ($this->verbActions) { |
|
| 127 | - return \strtolower($request->getMethod()) . \ucfirst($this->action); |
|
| 126 | + if ($this->verbActions){ |
|
| 127 | + return \strtolower($request->getMethod()).\ucfirst($this->action); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | return $this->action; |
@@ -139,21 +139,21 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | private function wrapResponse(Response $response, mixed $result = null, string $output = ''): Response |
| 141 | 141 | { |
| 142 | - if ($result instanceof Response) { |
|
| 143 | - if ($output !== '' && $result->getBody()->isWritable()) { |
|
| 142 | + if ($result instanceof Response){ |
|
| 143 | + if ($output !== '' && $result->getBody()->isWritable()){ |
|
| 144 | 144 | $result->getBody()->write($output); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | return $result; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if ($result instanceof \Generator) { |
|
| 150 | + if ($result instanceof \Generator){ |
|
| 151 | 151 | return $response->withBody(new GeneratorStream($result)); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if (\is_array($result) || $result instanceof \JsonSerializable) { |
|
| 154 | + if (\is_array($result) || $result instanceof \JsonSerializable){ |
|
| 155 | 155 | $response = $this->writeJson($response, $result); |
| 156 | - } else { |
|
| 156 | + }else{ |
|
| 157 | 157 | $response->getBody()->write((string)$result); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -63,14 +63,19 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | return $this->tracer->trace( |
| 65 | 65 | name: 'Routing', |
| 66 | - callback: function (SpanInterface $span) use ($request) { |
|
| 67 | - try { |
|
| 66 | + callback: function (SpanInterface $span) use ($request) |
|
| 67 | + { |
|
| 68 | + try |
|
| 69 | + { |
|
| 68 | 70 | $route = $this->matchRoute($request, $routeName); |
| 69 | - } catch (RouteException $e) { |
|
| 71 | + } |
|
| 72 | + catch (RouteException $e) |
|
| 73 | + { |
|
| 70 | 74 | throw new RouterException('Invalid route definition', $e->getCode(), $e); |
| 71 | 75 | } |
| 72 | 76 | |
| 73 | - if ($route === null) { |
|
| 77 | + if ($route === null) |
|
| 78 | + { |
|
| 74 | 79 | $this->eventDispatcher?->dispatch(new RouteNotFound($request)); |
| 75 | 80 | throw new RouteNotFoundException($request->getUri()); |
| 76 | 81 | } |
@@ -105,7 +110,8 @@ discard block |
||
| 105 | 110 | |
| 106 | 111 | public function getRoute(string $name): RouteInterface |
| 107 | 112 | { |
| 108 | - if (isset($this->routes[$name])) { |
|
| 113 | + if (isset($this->routes[$name])) |
|
| 114 | + { |
|
| 109 | 115 | return $this->routes[$name]; |
| 110 | 116 | } |
| 111 | 117 | |
@@ -114,7 +120,8 @@ discard block |
||
| 114 | 120 | |
| 115 | 121 | public function getRoutes(): array |
| 116 | 122 | { |
| 117 | - if (!empty($this->default)) { |
|
| 123 | + if (!empty($this->default)) |
|
| 124 | + { |
|
| 118 | 125 | return $this->routes + [null => $this->default]; |
| 119 | 126 | } |
| 120 | 127 | |
@@ -123,9 +130,12 @@ discard block |
||
| 123 | 130 | |
| 124 | 131 | public function uri(string $route, iterable $parameters = []): UriInterface |
| 125 | 132 | { |
| 126 | - try { |
|
| 133 | + try |
|
| 134 | + { |
|
| 127 | 135 | return $this->getRoute($route)->uri($parameters); |
| 128 | - } catch (UndefinedRouteException) { |
|
| 136 | + } |
|
| 137 | + catch (UndefinedRouteException) |
|
| 138 | + { |
|
| 129 | 139 | //In some cases route name can be provided as controller:action pair, we can try to |
| 130 | 140 | //generate such route automatically based on our default/fallback route |
| 131 | 141 | return $this->castRoute($route)->uri($parameters); |
@@ -137,9 +147,11 @@ discard block |
||
| 137 | 147 | /** @var GroupRegistry $groups */ |
| 138 | 148 | $groups = $this->container->get(GroupRegistry::class); |
| 139 | 149 | |
| 140 | - foreach ($routes->getCollection() as $name => $configurator) { |
|
| 150 | + foreach ($routes->getCollection() as $name => $configurator) |
|
| 151 | + { |
|
| 141 | 152 | $target = $configurator->target; |
| 142 | - if ($configurator->core !== null && $target instanceof AbstractTarget) { |
|
| 153 | + if ($configurator->core !== null && $target instanceof AbstractTarget) |
|
| 154 | + { |
|
| 143 | 155 | $target = $target->withCore($configurator->core); |
| 144 | 156 | } |
| 145 | 157 | |
@@ -149,19 +161,23 @@ discard block |
||
| 149 | 161 | $configurator->defaults |
| 150 | 162 | ); |
| 151 | 163 | |
| 152 | - if ($configurator->middleware !== null) { |
|
| 164 | + if ($configurator->middleware !== null) |
|
| 165 | + { |
|
| 153 | 166 | $route = $route->withMiddleware(...$configurator->middleware); |
| 154 | 167 | } |
| 155 | 168 | |
| 156 | - if ($configurator->methods !== null) { |
|
| 169 | + if ($configurator->methods !== null) |
|
| 170 | + { |
|
| 157 | 171 | $route = $route->withVerbs(...$configurator->methods); |
| 158 | 172 | } |
| 159 | 173 | |
| 160 | - if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) { |
|
| 174 | + if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) |
|
| 175 | + { |
|
| 161 | 176 | $groups->getGroup($configurator->group ?? $groups->getDefaultGroup())->addRoute($name, $route); |
| 162 | 177 | } |
| 163 | 178 | |
| 164 | - if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) { |
|
| 179 | + if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) |
|
| 180 | + { |
|
| 165 | 181 | $this->setDefault($route); |
| 166 | 182 | } |
| 167 | 183 | } |
@@ -172,17 +188,20 @@ discard block |
||
| 172 | 188 | */ |
| 173 | 189 | protected function matchRoute(ServerRequestInterface $request, string &$routeName = null): ?RouteInterface |
| 174 | 190 | { |
| 175 | - foreach ($this->routes as $name => $route) { |
|
| 191 | + foreach ($this->routes as $name => $route) |
|
| 192 | + { |
|
| 176 | 193 | // Matched route will return new route instance with matched parameters |
| 177 | 194 | $matched = $route->match($request); |
| 178 | 195 | |
| 179 | - if ($matched !== null) { |
|
| 196 | + if ($matched !== null) |
|
| 197 | + { |
|
| 180 | 198 | $routeName = $name; |
| 181 | 199 | return $matched; |
| 182 | 200 | } |
| 183 | 201 | } |
| 184 | 202 | |
| 185 | - if ($this->default !== null) { |
|
| 203 | + if ($this->default !== null) |
|
| 204 | + { |
|
| 186 | 205 | return $this->default->match($request); |
| 187 | 206 | } |
| 188 | 207 | |
@@ -195,7 +214,8 @@ discard block |
||
| 195 | 214 | */ |
| 196 | 215 | protected function configure(RouteInterface $route): RouteInterface |
| 197 | 216 | { |
| 198 | - if ($route instanceof ContainerizedInterface && !$route->hasContainer()) { |
|
| 217 | + if ($route instanceof ContainerizedInterface && !$route->hasContainer()) |
|
| 218 | + { |
|
| 199 | 219 | // isolating route in a given container |
| 200 | 220 | $route = $route->withContainer($this->container); |
| 201 | 221 | } |
@@ -225,11 +245,16 @@ discard block |
||
| 225 | 245 | ); |
| 226 | 246 | } |
| 227 | 247 | |
| 228 | - if (!empty($matches['name'])) { |
|
| 248 | + if (!empty($matches['name'])) |
|
| 249 | + { |
|
| 229 | 250 | $routeObject = $this->getRoute($matches['name']); |
| 230 | - } elseif ($this->default !== null) { |
|
| 251 | + } |
|
| 252 | + elseif ($this->default !== null) |
|
| 253 | + { |
|
| 231 | 254 | $routeObject = $this->default; |
| 232 | - } else { |
|
| 255 | + } |
|
| 256 | + else |
|
| 257 | + { |
|
| 233 | 258 | throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route)); |
| 234 | 259 | } |
| 235 | 260 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | private readonly ContainerInterface $container, |
| 50 | 50 | private readonly ?EventDispatcherInterface $eventDispatcher = null, |
| 51 | 51 | private readonly ?TracerInterface $tracer = new NullTracer(), |
| 52 | - ) { |
|
| 53 | - $this->basePath = '/' . \ltrim($basePath, '/'); |
|
| 52 | + ){ |
|
| 53 | + $this->basePath = '/'.\ltrim($basePath, '/'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | return $this->tracer->trace( |
| 65 | 65 | name: 'Routing', |
| 66 | 66 | callback: function (SpanInterface $span) use ($request) { |
| 67 | - try { |
|
| 67 | + try{ |
|
| 68 | 68 | $route = $this->matchRoute($request, $routeName); |
| 69 | - } catch (RouteException $e) { |
|
| 69 | + }catch (RouteException $e){ |
|
| 70 | 70 | throw new RouterException('Invalid route definition', $e->getCode(), $e); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if ($route === null) { |
|
| 73 | + if ($route === null){ |
|
| 74 | 74 | $this->eventDispatcher?->dispatch(new RouteNotFound($request)); |
| 75 | 75 | throw new RouteNotFoundException($request->getUri()); |
| 76 | 76 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | public function getRoute(string $name): RouteInterface |
| 107 | 107 | { |
| 108 | - if (isset($this->routes[$name])) { |
|
| 108 | + if (isset($this->routes[$name])){ |
|
| 109 | 109 | return $this->routes[$name]; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | public function getRoutes(): array |
| 116 | 116 | { |
| 117 | - if (!empty($this->default)) { |
|
| 117 | + if (!empty($this->default)){ |
|
| 118 | 118 | return $this->routes + [null => $this->default]; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | public function uri(string $route, iterable $parameters = []): UriInterface |
| 125 | 125 | { |
| 126 | - try { |
|
| 126 | + try{ |
|
| 127 | 127 | return $this->getRoute($route)->uri($parameters); |
| 128 | - } catch (UndefinedRouteException) { |
|
| 128 | + }catch (UndefinedRouteException){ |
|
| 129 | 129 | //In some cases route name can be provided as controller:action pair, we can try to |
| 130 | 130 | //generate such route automatically based on our default/fallback route |
| 131 | 131 | return $this->castRoute($route)->uri($parameters); |
@@ -137,31 +137,31 @@ discard block |
||
| 137 | 137 | /** @var GroupRegistry $groups */ |
| 138 | 138 | $groups = $this->container->get(GroupRegistry::class); |
| 139 | 139 | |
| 140 | - foreach ($routes->getCollection() as $name => $configurator) { |
|
| 140 | + foreach ($routes->getCollection() as $name => $configurator){ |
|
| 141 | 141 | $target = $configurator->target; |
| 142 | - if ($configurator->core !== null && $target instanceof AbstractTarget) { |
|
| 142 | + if ($configurator->core !== null && $target instanceof AbstractTarget){ |
|
| 143 | 143 | $target = $target->withCore($configurator->core); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $route = new Route( |
| 147 | - $configurator->prefix . '/' . \ltrim($configurator->pattern, '/'), |
|
| 147 | + $configurator->prefix.'/'.\ltrim($configurator->pattern, '/'), |
|
| 148 | 148 | $target, |
| 149 | 149 | $configurator->defaults |
| 150 | 150 | ); |
| 151 | 151 | |
| 152 | - if ($configurator->middleware !== null) { |
|
| 152 | + if ($configurator->middleware !== null){ |
|
| 153 | 153 | $route = $route->withMiddleware(...$configurator->middleware); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ($configurator->methods !== null) { |
|
| 156 | + if ($configurator->methods !== null){ |
|
| 157 | 157 | $route = $route->withVerbs(...$configurator->methods); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) { |
|
| 160 | + if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME){ |
|
| 161 | 161 | $groups->getGroup($configurator->group ?? $groups->getDefaultGroup())->addRoute($name, $route); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) { |
|
| 164 | + if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME){ |
|
| 165 | 165 | $this->setDefault($route); |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -172,17 +172,17 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | protected function matchRoute(ServerRequestInterface $request, string &$routeName = null): ?RouteInterface |
| 174 | 174 | { |
| 175 | - foreach ($this->routes as $name => $route) { |
|
| 175 | + foreach ($this->routes as $name => $route){ |
|
| 176 | 176 | // Matched route will return new route instance with matched parameters |
| 177 | 177 | $matched = $route->match($request); |
| 178 | 178 | |
| 179 | - if ($matched !== null) { |
|
| 179 | + if ($matched !== null){ |
|
| 180 | 180 | $routeName = $name; |
| 181 | 181 | return $matched; |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ($this->default !== null) { |
|
| 185 | + if ($this->default !== null){ |
|
| 186 | 186 | return $this->default->match($request); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | protected function configure(RouteInterface $route): RouteInterface |
| 197 | 197 | { |
| 198 | - if ($route instanceof ContainerizedInterface && !$route->hasContainer()) { |
|
| 198 | + if ($route instanceof ContainerizedInterface && !$route->hasContainer()){ |
|
| 199 | 199 | // isolating route in a given container |
| 200 | 200 | $route = $route->withContainer($this->container); |
| 201 | 201 | } |
@@ -219,17 +219,17 @@ discard block |
||
| 219 | 219 | $route, |
| 220 | 220 | $matches |
| 221 | 221 | ) |
| 222 | - ) { |
|
| 222 | + ){ |
|
| 223 | 223 | throw new UndefinedRouteException( |
| 224 | 224 | "Unable to locate route or use default route with 'name/controller:action' pattern" |
| 225 | 225 | ); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if (!empty($matches['name'])) { |
|
| 228 | + if (!empty($matches['name'])){ |
|
| 229 | 229 | $routeObject = $this->getRoute($matches['name']); |
| 230 | - } elseif ($this->default !== null) { |
|
| 230 | + } elseif ($this->default !== null){ |
|
| 231 | 231 | $routeObject = $this->default; |
| 232 | - } else { |
|
| 232 | + }else{ |
|
| 233 | 233 | throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route)); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function perform(PrototypeBootloader $prototypeBootloader): int |
| 23 | 23 | { |
| 24 | 24 | $dependencies = $this->registry->getPropertyBindings(); |
| 25 | - if ($dependencies === []) { |
|
| 25 | + if ($dependencies === []){ |
|
| 26 | 26 | $this->writeln('<comment>No prototyped shortcuts found.</comment>'); |
| 27 | 27 | |
| 28 | 28 | return self::SUCCESS; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $trait = new \ReflectionClass(PrototypeTrait::class); |
| 34 | 34 | $docComment = $trait->getDocComment(); |
| 35 | - if ($docComment === false) { |
|
| 35 | + if ($docComment === false){ |
|
| 36 | 36 | $this->write('<fg=red>DOCComment is missing</fg=red>'); |
| 37 | 37 | |
| 38 | 38 | return self::FAILURE; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $filename = $trait->getFileName(); |
| 42 | 42 | |
| 43 | - try { |
|
| 43 | + try{ |
|
| 44 | 44 | \file_put_contents( |
| 45 | 45 | $filename, |
| 46 | 46 | \str_replace( |
@@ -49,18 +49,18 @@ discard block |
||
| 49 | 49 | \file_get_contents($filename) |
| 50 | 50 | ) |
| 51 | 51 | ); |
| 52 | - } catch (\Throwable $e) { |
|
| 53 | - $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n"); |
|
| 52 | + }catch (\Throwable $e){ |
|
| 53 | + $this->write('<fg=red>'.$e->getMessage()."</fg=red>\n"); |
|
| 54 | 54 | |
| 55 | 55 | return self::FAILURE; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $this->write("<fg=green>complete</fg=green>\n"); |
| 59 | 59 | |
| 60 | - if ($this->isVerbose()) { |
|
| 60 | + if ($this->isVerbose()){ |
|
| 61 | 61 | $grid = $this->table(['Property:', 'Target:']); |
| 62 | 62 | |
| 63 | - foreach ($dependencies as $dependency) { |
|
| 63 | + foreach ($dependencies as $dependency){ |
|
| 64 | 64 | $grid->addRow([$dependency->var, $dependency->type->fullName]); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | ); |
| 79 | 79 | $an->lines[] = new Annotation\Line(''); |
| 80 | 80 | |
| 81 | - foreach ($dependencies as $dependency) { |
|
| 81 | + foreach ($dependencies as $dependency){ |
|
| 82 | 82 | $an->lines[] = new Annotation\Line( |
| 83 | 83 | \sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var), |
| 84 | 84 | 'property' |
@@ -22,7 +22,8 @@ discard block |
||
| 22 | 22 | public function perform(PrototypeBootloader $prototypeBootloader): int |
| 23 | 23 | { |
| 24 | 24 | $dependencies = $this->registry->getPropertyBindings(); |
| 25 | - if ($dependencies === []) { |
|
| 25 | + if ($dependencies === []) |
|
| 26 | + { |
|
| 26 | 27 | $this->writeln('<comment>No prototyped shortcuts found.</comment>'); |
| 27 | 28 | |
| 28 | 29 | return self::SUCCESS; |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | $trait = new \ReflectionClass(PrototypeTrait::class); |
| 34 | 35 | $docComment = $trait->getDocComment(); |
| 35 | - if ($docComment === false) { |
|
| 36 | + if ($docComment === false) |
|
| 37 | + { |
|
| 36 | 38 | $this->write('<fg=red>DOCComment is missing</fg=red>'); |
| 37 | 39 | |
| 38 | 40 | return self::FAILURE; |
@@ -40,7 +42,8 @@ discard block |
||
| 40 | 42 | |
| 41 | 43 | $filename = $trait->getFileName(); |
| 42 | 44 | |
| 43 | - try { |
|
| 45 | + try |
|
| 46 | + { |
|
| 44 | 47 | \file_put_contents( |
| 45 | 48 | $filename, |
| 46 | 49 | \str_replace( |
@@ -49,7 +52,9 @@ discard block |
||
| 49 | 52 | \file_get_contents($filename) |
| 50 | 53 | ) |
| 51 | 54 | ); |
| 52 | - } catch (\Throwable $e) { |
|
| 55 | + } |
|
| 56 | + catch (\Throwable $e) |
|
| 57 | + { |
|
| 53 | 58 | $this->write('<fg=red>' . $e->getMessage() . "</fg=red>\n"); |
| 54 | 59 | |
| 55 | 60 | return self::FAILURE; |
@@ -57,10 +62,12 @@ discard block |
||
| 57 | 62 | |
| 58 | 63 | $this->write("<fg=green>complete</fg=green>\n"); |
| 59 | 64 | |
| 60 | - if ($this->isVerbose()) { |
|
| 65 | + if ($this->isVerbose()) |
|
| 66 | + { |
|
| 61 | 67 | $grid = $this->table(['Property:', 'Target:']); |
| 62 | 68 | |
| 63 | - foreach ($dependencies as $dependency) { |
|
| 69 | + foreach ($dependencies as $dependency) |
|
| 70 | + { |
|
| 64 | 71 | $grid->addRow([$dependency->var, $dependency->type->fullName]); |
| 65 | 72 | } |
| 66 | 73 | |
@@ -78,7 +85,8 @@ discard block |
||
| 78 | 85 | ); |
| 79 | 86 | $an->lines[] = new Annotation\Line(''); |
| 80 | 87 | |
| 81 | - foreach ($dependencies as $dependency) { |
|
| 88 | + foreach ($dependencies as $dependency) |
|
| 89 | + { |
|
| 82 | 90 | $an->lines[] = new Annotation\Line( |
| 83 | 91 | \sprintf('\\%s $%s', $dependency->type->fullName, $dependency->var), |
| 84 | 92 | 'property' |
@@ -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 | |
@@ -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 | ); |
@@ -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, |