@@ -37,7 +37,7 @@ |
||
37 | 37 | $response = new Response('php://memory', $code, []); |
38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
39 | 39 | |
40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
40 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
41 | 41 | $response = $response->withAddedHeader($header, $value); |
42 | 42 | } |
43 | 43 |
@@ -37,7 +37,8 @@ |
||
37 | 37 | $response = new Response('php://memory', $code, []); |
38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
39 | 39 | |
40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
40 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
41 | + { |
|
41 | 42 | $response = $response->withAddedHeader($header, $value); |
42 | 43 | } |
43 | 44 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
48 | 48 | { |
49 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
49 | + if (!$this->container->has(ServerRequestInterface::class)){ |
|
50 | 50 | throw new ScopeException('Unable to create paginator, no request scope found'); |
51 | 51 | } |
52 | 52 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | //Getting page number |
58 | 58 | $page = 0; |
59 | - if (!empty($query[$parameter]) && is_scalar($query[$parameter])) { |
|
59 | + if (!empty($query[$parameter]) && is_scalar($query[$parameter])){ |
|
60 | 60 | $page = (int)$query[$parameter]; |
61 | 61 | } |
62 | 62 |
@@ -46,7 +46,8 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
48 | 48 | { |
49 | - if (!$this->container->has(ServerRequestInterface::class)) { |
|
49 | + if (!$this->container->has(ServerRequestInterface::class)) |
|
50 | + { |
|
50 | 51 | throw new ScopeException('Unable to create paginator, no request scope found'); |
51 | 52 | } |
52 | 53 | /** |
@@ -56,7 +57,8 @@ discard block |
||
56 | 57 | |
57 | 58 | //Getting page number |
58 | 59 | $page = 0; |
59 | - if (!empty($query[$parameter]) && is_scalar($query[$parameter])) { |
|
60 | + if (!empty($query[$parameter]) && is_scalar($query[$parameter])) |
|
61 | + { |
|
60 | 62 | $page = (int)$query[$parameter]; |
61 | 63 | } |
62 | 64 |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | FinalizerInterface $finalizer, |
50 | 50 | ContainerInterface $container, |
51 | 51 | FactoryInterface $factory |
52 | - ) { |
|
52 | + ){ |
|
53 | 53 | $this->env = $env; |
54 | 54 | $this->finalizer = $finalizer; |
55 | 55 | $this->container = $container; |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | |
76 | 76 | /** @var Http $http */ |
77 | 77 | $http = $this->container->get(Http::class); |
78 | - while ($request = $client->acceptRequest()) { |
|
79 | - try { |
|
78 | + while ($request = $client->acceptRequest()){ |
|
79 | + try{ |
|
80 | 80 | $client->respond($http->handle($request)); |
81 | - } catch (\Throwable $e) { |
|
81 | + }catch (\Throwable $e){ |
|
82 | 82 | $this->handleException($client, $e); |
83 | - } finally { |
|
83 | + }finally{ |
|
84 | 84 | $this->finalizer->finalize(false); |
85 | 85 | } |
86 | 86 | } |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | { |
95 | 95 | $handler = new HtmlHandler(); |
96 | 96 | |
97 | - try { |
|
97 | + try{ |
|
98 | 98 | /** @var SnapshotInterface $snapshot */ |
99 | 99 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
100 | 100 | error_log($snapshot->getMessage()); |
101 | 101 | |
102 | 102 | // on demand |
103 | 103 | $state = $this->container->get(StateInterface::class); |
104 | - if ($state !== null) { |
|
104 | + if ($state !== null){ |
|
105 | 105 | $handler = $handler->withState($state); |
106 | 106 | } |
107 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
107 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
108 | 108 | error_log((string)$e); |
109 | 109 | } |
110 | 110 |
@@ -75,12 +75,18 @@ discard block |
||
75 | 75 | |
76 | 76 | /** @var Http $http */ |
77 | 77 | $http = $this->container->get(Http::class); |
78 | - while ($request = $client->acceptRequest()) { |
|
79 | - try { |
|
78 | + while ($request = $client->acceptRequest()) |
|
79 | + { |
|
80 | + try |
|
81 | + { |
|
80 | 82 | $client->respond($http->handle($request)); |
81 | - } catch (\Throwable $e) { |
|
83 | + } |
|
84 | + catch (\Throwable $e) |
|
85 | + { |
|
82 | 86 | $this->handleException($client, $e); |
83 | - } finally { |
|
87 | + } |
|
88 | + finally |
|
89 | + { |
|
84 | 90 | $this->finalizer->finalize(false); |
85 | 91 | } |
86 | 92 | } |
@@ -94,17 +100,21 @@ discard block |
||
94 | 100 | { |
95 | 101 | $handler = new HtmlHandler(); |
96 | 102 | |
97 | - try { |
|
103 | + try |
|
104 | + { |
|
98 | 105 | /** @var SnapshotInterface $snapshot */ |
99 | 106 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
100 | 107 | error_log($snapshot->getMessage()); |
101 | 108 | |
102 | 109 | // on demand |
103 | 110 | $state = $this->container->get(StateInterface::class); |
104 | - if ($state !== null) { |
|
111 | + if ($state !== null) |
|
112 | + { |
|
105 | 113 | $handler = $handler->withState($state); |
106 | 114 | } |
107 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
115 | + } |
|
116 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
117 | + { |
|
108 | 118 | error_log((string)$e); |
109 | 119 | } |
110 | 120 |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
45 | 45 | { |
46 | - if ($this->isJsonPayload($request)) { |
|
46 | + if ($this->isJsonPayload($request)){ |
|
47 | 47 | $body = (string)$request->getBody(); |
48 | - if ($body !== '') { |
|
48 | + if ($body !== ''){ |
|
49 | 49 | $request = $request->withParsedBody(json_decode($body, true)); |
50 | - if (json_last_error() !== 0) { |
|
50 | + if (json_last_error() !== 0){ |
|
51 | 51 | throw new ClientException(400, 'invalid json payload'); |
52 | 52 | } |
53 | 53 | } |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | { |
65 | 65 | $contentType = $request->getHeaderLine('Content-Type'); |
66 | 66 | |
67 | - foreach ($this->config->getContentTypes() as $allowedType) { |
|
68 | - if (stripos($contentType, $allowedType) === 0) { |
|
67 | + foreach ($this->config->getContentTypes() as $allowedType){ |
|
68 | + if (stripos($contentType, $allowedType) === 0){ |
|
69 | 69 | return true; |
70 | 70 | } |
71 | 71 | } |
@@ -43,11 +43,14 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
45 | 45 | { |
46 | - if ($this->isJsonPayload($request)) { |
|
46 | + if ($this->isJsonPayload($request)) |
|
47 | + { |
|
47 | 48 | $body = (string)$request->getBody(); |
48 | - if ($body !== '') { |
|
49 | + if ($body !== '') |
|
50 | + { |
|
49 | 51 | $request = $request->withParsedBody(json_decode($body, true)); |
50 | - if (json_last_error() !== 0) { |
|
52 | + if (json_last_error() !== 0) |
|
53 | + { |
|
51 | 54 | throw new ClientException(400, 'invalid json payload'); |
52 | 55 | } |
53 | 56 | } |
@@ -64,8 +67,10 @@ discard block |
||
64 | 67 | { |
65 | 68 | $contentType = $request->getHeaderLine('Content-Type'); |
66 | 69 | |
67 | - foreach ($this->config->getContentTypes() as $allowedType) { |
|
68 | - if (stripos($contentType, $allowedType) === 0) { |
|
70 | + foreach ($this->config->getContentTypes() as $allowedType) |
|
71 | + { |
|
72 | + if (stripos($contentType, $allowedType) === 0) |
|
73 | + { |
|
69 | 74 | return true; |
70 | 75 | } |
71 | 76 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | EnvironmentInterface $env, |
40 | 40 | FinalizerInterface $finalizer, |
41 | 41 | ContainerInterface $container |
42 | - ) { |
|
42 | + ){ |
|
43 | 43 | $this->env = $env; |
44 | 44 | $this->finalizer = $finalizer; |
45 | 45 | $this->container = $container; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $consumer->serve( |
71 | 71 | $worker, |
72 | 72 | function (\Throwable $e = null): void { |
73 | - if ($e !== null) { |
|
73 | + if ($e !== null){ |
|
74 | 74 | $this->handleException($e); |
75 | 75 | } |
76 | 76 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function handleException(\Throwable $e): void |
86 | 86 | { |
87 | - try { |
|
87 | + try{ |
|
88 | 88 | $this->container->get(SnapshotterInterface::class)->register($e); |
89 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
89 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
90 | 90 | // no need to notify when unable to register an exception |
91 | 91 | } |
92 | 92 | } |
@@ -70,7 +70,8 @@ discard block |
||
70 | 70 | $consumer->serve( |
71 | 71 | $worker, |
72 | 72 | function (\Throwable $e = null): void { |
73 | - if ($e !== null) { |
|
73 | + if ($e !== null) |
|
74 | + { |
|
74 | 75 | $this->handleException($e); |
75 | 76 | } |
76 | 77 | |
@@ -84,9 +85,12 @@ discard block |
||
84 | 85 | */ |
85 | 86 | protected function handleException(\Throwable $e): void |
86 | 87 | { |
87 | - try { |
|
88 | + try |
|
89 | + { |
|
88 | 90 | $this->container->get(SnapshotterInterface::class)->register($e); |
89 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
91 | + } |
|
92 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
93 | + { |
|
90 | 94 | // no need to notify when unable to register an exception |
91 | 95 | } |
92 | 96 | } |
@@ -42,12 +42,12 @@ |
||
42 | 42 | */ |
43 | 43 | public function push(string $jobType, array $payload = [], Options $options = null): string |
44 | 44 | { |
45 | - if ($options === null) { |
|
45 | + if ($options === null){ |
|
46 | 46 | $options = new Options(); |
47 | 47 | } |
48 | 48 | |
49 | 49 | $pipeline = $this->registry->getPipeline($jobType); |
50 | - if ($pipeline !== null && $options->getPipeline() === null) { |
|
50 | + if ($pipeline !== null && $options->getPipeline() === null){ |
|
51 | 51 | $options = $options->withPipeline($pipeline); |
52 | 52 | } |
53 | 53 |
@@ -42,12 +42,14 @@ |
||
42 | 42 | */ |
43 | 43 | public function push(string $jobType, array $payload = [], Options $options = null): string |
44 | 44 | { |
45 | - if ($options === null) { |
|
45 | + if ($options === null) |
|
46 | + { |
|
46 | 47 | $options = new Options(); |
47 | 48 | } |
48 | 49 | |
49 | 50 | $pipeline = $this->registry->getPipeline($jobType); |
50 | - if ($pipeline !== null && $options->getPipeline() === null) { |
|
51 | + if ($pipeline !== null && $options->getPipeline() === null) |
|
52 | + { |
|
51 | 53 | $options = $options->withPipeline($pipeline); |
52 | 54 | } |
53 | 55 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | ContainerInterface $container, |
46 | 46 | HandlerRegistryInterface $handlers, |
47 | 47 | SerializerRegistryInterface $serializers |
48 | - ) { |
|
48 | + ){ |
|
49 | 49 | $this->container = $container; |
50 | 50 | $this->fallbackHandlers = $handlers; |
51 | 51 | $this->fallbackSerializers = $serializers; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getHandler(string $jobType): HandlerInterface |
68 | 68 | { |
69 | - if (isset($this->handlers[$jobType])) { |
|
70 | - if ($this->handlers[$jobType] instanceof HandlerInterface) { |
|
69 | + if (isset($this->handlers[$jobType])){ |
|
70 | + if ($this->handlers[$jobType] instanceof HandlerInterface){ |
|
71 | 71 | return $this->handlers[$jobType]; |
72 | 72 | } |
73 | 73 | |
@@ -92,20 +92,20 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function getSerializer(string $jobType): SerializerInterface |
94 | 94 | { |
95 | - if (isset($this->serializers[$jobType])) { |
|
96 | - if ($this->serializers[$jobType] instanceof SerializerInterface) { |
|
95 | + if (isset($this->serializers[$jobType])){ |
|
96 | + if ($this->serializers[$jobType] instanceof SerializerInterface){ |
|
97 | 97 | return $this->serializers[$jobType]; |
98 | 98 | } |
99 | 99 | |
100 | 100 | return $this->container->get($this->serializers[$jobType]); |
101 | 101 | } |
102 | 102 | |
103 | - if (!isset($this->handlers[$jobType])) { |
|
103 | + if (!isset($this->handlers[$jobType])){ |
|
104 | 104 | return $this->fallbackSerializers->getSerializer($jobType); |
105 | 105 | } |
106 | 106 | |
107 | 107 | $handler = $this->getHandler($jobType); |
108 | - if ($handler instanceof SerializerInterface) { |
|
108 | + if ($handler instanceof SerializerInterface){ |
|
109 | 109 | return $handler; |
110 | 110 | } |
111 | 111 |
@@ -66,8 +66,10 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getHandler(string $jobType): HandlerInterface |
68 | 68 | { |
69 | - if (isset($this->handlers[$jobType])) { |
|
70 | - if ($this->handlers[$jobType] instanceof HandlerInterface) { |
|
69 | + if (isset($this->handlers[$jobType])) |
|
70 | + { |
|
71 | + if ($this->handlers[$jobType] instanceof HandlerInterface) |
|
72 | + { |
|
71 | 73 | return $this->handlers[$jobType]; |
72 | 74 | } |
73 | 75 | |
@@ -92,20 +94,24 @@ discard block |
||
92 | 94 | */ |
93 | 95 | public function getSerializer(string $jobType): SerializerInterface |
94 | 96 | { |
95 | - if (isset($this->serializers[$jobType])) { |
|
96 | - if ($this->serializers[$jobType] instanceof SerializerInterface) { |
|
97 | + if (isset($this->serializers[$jobType])) |
|
98 | + { |
|
99 | + if ($this->serializers[$jobType] instanceof SerializerInterface) |
|
100 | + { |
|
97 | 101 | return $this->serializers[$jobType]; |
98 | 102 | } |
99 | 103 | |
100 | 104 | return $this->container->get($this->serializers[$jobType]); |
101 | 105 | } |
102 | 106 | |
103 | - if (!isset($this->handlers[$jobType])) { |
|
107 | + if (!isset($this->handlers[$jobType])) |
|
108 | + { |
|
104 | 109 | return $this->fallbackSerializers->getSerializer($jobType); |
105 | 110 | } |
106 | 111 | |
107 | 112 | $handler = $this->getHandler($jobType); |
108 | - if ($handler instanceof SerializerInterface) { |
|
113 | + if ($handler instanceof SerializerInterface) |
|
114 | + { |
|
109 | 115 | return $handler; |
110 | 116 | } |
111 | 117 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | EnvironmentInterface $env, |
49 | 49 | FinalizerInterface $finalizer, |
50 | 50 | ContainerInterface $container |
51 | - ) { |
|
51 | + ){ |
|
52 | 52 | $this->env = $env; |
53 | 53 | $this->finalizer = $finalizer; |
54 | 54 | $this->container = $container; |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | /** @var Console $console */ |
80 | 80 | $console = $this->container->get(Console::class); |
81 | 81 | |
82 | - try { |
|
82 | + try{ |
|
83 | 83 | return $console->start($input ?? new ArgvInput(), $output); |
84 | - } catch (Throwable $e) { |
|
84 | + }catch (Throwable $e){ |
|
85 | 85 | $this->handleException($e, $output); |
86 | 86 | |
87 | 87 | return 255; |
88 | - } finally { |
|
88 | + }finally{ |
|
89 | 89 | $listener->disable(); |
90 | 90 | $this->finalizer->finalize(false); |
91 | 91 | } |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function handleException(Throwable $e, OutputInterface $output): void |
99 | 99 | { |
100 | - try { |
|
100 | + try{ |
|
101 | 101 | $this->container->get(SnapshotterInterface::class)->register($e); |
102 | - } catch (Throwable | ContainerExceptionInterface $se) { |
|
102 | + }catch (Throwable | ContainerExceptionInterface $se){ |
|
103 | 103 | // no need to notify when unable to register an exception |
104 | 104 | } |
105 | 105 | |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | */ |
115 | 115 | private function mapVerbosity(OutputInterface $output): int |
116 | 116 | { |
117 | - if ($output->isDebug()) { |
|
117 | + if ($output->isDebug()){ |
|
118 | 118 | return ConsoleHandler::VERBOSITY_DEBUG; |
119 | 119 | } |
120 | 120 | |
121 | - if ($output->isVeryVerbose()) { |
|
121 | + if ($output->isVeryVerbose()){ |
|
122 | 122 | return ConsoleHandler::VERBOSITY_VERBOSE; |
123 | 123 | } |
124 | 124 |
@@ -79,13 +79,18 @@ discard block |
||
79 | 79 | /** @var Console $console */ |
80 | 80 | $console = $this->container->get(Console::class); |
81 | 81 | |
82 | - try { |
|
82 | + try |
|
83 | + { |
|
83 | 84 | return $console->start($input ?? new ArgvInput(), $output); |
84 | - } catch (Throwable $e) { |
|
85 | + } |
|
86 | + catch (Throwable $e) |
|
87 | + { |
|
85 | 88 | $this->handleException($e, $output); |
86 | 89 | |
87 | 90 | return 255; |
88 | - } finally { |
|
91 | + } |
|
92 | + finally |
|
93 | + { |
|
89 | 94 | $listener->disable(); |
90 | 95 | $this->finalizer->finalize(false); |
91 | 96 | } |
@@ -97,9 +102,12 @@ discard block |
||
97 | 102 | */ |
98 | 103 | protected function handleException(Throwable $e, OutputInterface $output): void |
99 | 104 | { |
100 | - try { |
|
105 | + try |
|
106 | + { |
|
101 | 107 | $this->container->get(SnapshotterInterface::class)->register($e); |
102 | - } catch (Throwable | ContainerExceptionInterface $se) { |
|
108 | + } |
|
109 | + catch (Throwable | ContainerExceptionInterface $se) |
|
110 | + { |
|
103 | 111 | // no need to notify when unable to register an exception |
104 | 112 | } |
105 | 113 | |
@@ -114,11 +122,13 @@ discard block |
||
114 | 122 | */ |
115 | 123 | private function mapVerbosity(OutputInterface $output): int |
116 | 124 | { |
117 | - if ($output->isDebug()) { |
|
125 | + if ($output->isDebug()) |
|
126 | + { |
|
118 | 127 | return ConsoleHandler::VERBOSITY_DEBUG; |
119 | 128 | } |
120 | 129 | |
121 | - if ($output->isVeryVerbose()) { |
|
130 | + if ($output->isVeryVerbose()) |
|
131 | + { |
|
122 | 132 | return ConsoleHandler::VERBOSITY_VERBOSE; |
123 | 133 | } |
124 | 134 |
@@ -37,8 +37,8 @@ |
||
37 | 37 | public function locateCommands(): array |
38 | 38 | { |
39 | 39 | $commands = []; |
40 | - foreach ($this->classes->getClasses(SymfonyCommand::class) as $class) { |
|
41 | - if ($class->isAbstract()) { |
|
40 | + foreach ($this->classes->getClasses(SymfonyCommand::class) as $class){ |
|
41 | + if ($class->isAbstract()){ |
|
42 | 42 | continue; |
43 | 43 | } |
44 | 44 |
@@ -37,8 +37,10 @@ |
||
37 | 37 | public function locateCommands(): array |
38 | 38 | { |
39 | 39 | $commands = []; |
40 | - foreach ($this->classes->getClasses(SymfonyCommand::class) as $class) { |
|
41 | - if ($class->isAbstract()) { |
|
40 | + foreach ($this->classes->getClasses(SymfonyCommand::class) as $class) |
|
41 | + { |
|
42 | + if ($class->isAbstract()) |
|
43 | + { |
|
42 | 44 | continue; |
43 | 45 | } |
44 | 46 |