@@ -124,9 +124,9 @@ |
||
124 | 124 | */ |
125 | 125 | public function getActiveSession(): SessionInterface |
126 | 126 | { |
127 | - try { |
|
127 | + try{ |
|
128 | 128 | return $this->container->get(SessionInterface::class); |
129 | - } catch (NotFoundExceptionInterface $e) { |
|
129 | + }catch (NotFoundExceptionInterface $e){ |
|
130 | 130 | throw new ScopeException( |
131 | 131 | 'Unable to receive active session, invalid request scope', |
132 | 132 | $e->getCode(), |
@@ -124,9 +124,12 @@ |
||
124 | 124 | */ |
125 | 125 | public function getActiveSession(): SessionInterface |
126 | 126 | { |
127 | - try { |
|
127 | + try |
|
128 | + { |
|
128 | 129 | return $this->container->get(SessionInterface::class); |
129 | - } catch (NotFoundExceptionInterface $e) { |
|
130 | + } |
|
131 | + catch (NotFoundExceptionInterface $e) |
|
132 | + { |
|
130 | 133 | throw new ScopeException( |
131 | 134 | 'Unable to receive active session, invalid request scope', |
132 | 135 | $e->getCode(), |
@@ -19,14 +19,14 @@ |
||
19 | 19 | { |
20 | 20 | parent::tearDown(); |
21 | 21 | |
22 | - if (file_exists(sys_get_temp_dir() . '/messages.ru.php')) { |
|
23 | - unlink(sys_get_temp_dir() . '/messages.ru.php'); |
|
22 | + if (file_exists(sys_get_temp_dir().'/messages.ru.php')){ |
|
23 | + unlink(sys_get_temp_dir().'/messages.ru.php'); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | 27 | public function testReset(): void |
28 | 28 | { |
29 | - $this->assertFileNotExists(sys_get_temp_dir() . '/messages.ru.php'); |
|
29 | + $this->assertFileNotExists(sys_get_temp_dir().'/messages.ru.php'); |
|
30 | 30 | |
31 | 31 | $this->runCommandDebug('i18n:index'); |
32 | 32 | $this->runCommandDebug('configure'); |
@@ -19,7 +19,8 @@ |
||
19 | 19 | { |
20 | 20 | parent::tearDown(); |
21 | 21 | |
22 | - if (file_exists(sys_get_temp_dir() . '/messages.ru.php')) { |
|
22 | + if (file_exists(sys_get_temp_dir() . '/messages.ru.php')) |
|
23 | + { |
|
23 | 24 | unlink(sys_get_temp_dir() . '/messages.ru.php'); |
24 | 25 | } |
25 | 26 | } |
@@ -43,9 +43,9 @@ 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 | $request = $request->withParsedBody(json_decode((string)$request->getBody(), true)); |
48 | - if (json_last_error() !== 0) { |
|
48 | + if (json_last_error() !== 0){ |
|
49 | 49 | throw new ClientException(400, 'invalid json payload'); |
50 | 50 | } |
51 | 51 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | { |
62 | 62 | $contentType = $request->getHeaderLine('Content-Type'); |
63 | 63 | |
64 | - foreach ($this->config->getContentTypes() as $allowedType) { |
|
65 | - if (stripos($contentType, $allowedType) === 0) { |
|
64 | + foreach ($this->config->getContentTypes() as $allowedType){ |
|
65 | + if (stripos($contentType, $allowedType) === 0){ |
|
66 | 66 | return true; |
67 | 67 | } |
68 | 68 | } |
@@ -43,9 +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 | 48 | $request = $request->withParsedBody(json_decode((string)$request->getBody(), true)); |
48 | - if (json_last_error() !== 0) { |
|
49 | + if (json_last_error() !== 0) |
|
50 | + { |
|
49 | 51 | throw new ClientException(400, 'invalid json payload'); |
50 | 52 | } |
51 | 53 | } |
@@ -61,8 +63,10 @@ discard block |
||
61 | 63 | { |
62 | 64 | $contentType = $request->getHeaderLine('Content-Type'); |
63 | 65 | |
64 | - foreach ($this->config->getContentTypes() as $allowedType) { |
|
65 | - if (stripos($contentType, $allowedType) === 0) { |
|
66 | + foreach ($this->config->getContentTypes() as $allowedType) |
|
67 | + { |
|
68 | + if (stripos($contentType, $allowedType) === 0) |
|
69 | + { |
|
66 | 70 | return true; |
67 | 71 | } |
68 | 72 | } |
@@ -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 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function populate(StateInterface $state): void |
41 | 41 | { |
42 | - if ($this->request === null) { |
|
42 | + if ($this->request === null){ |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | |
49 | 49 | $state->setVariable('headers', $this->request->getHeaders()); |
50 | 50 | |
51 | - if ($this->request->getQueryParams() !== []) { |
|
51 | + if ($this->request->getQueryParams() !== []){ |
|
52 | 52 | $state->setVariable('query', $this->request->getQueryParams()); |
53 | 53 | } |
54 | 54 | |
55 | - if ($this->request->getParsedBody() !== null) { |
|
55 | + if ($this->request->getParsedBody() !== null){ |
|
56 | 56 | $state->setVariable('data', $this->request->getParsedBody()); |
57 | 57 | } |
58 | 58 | } |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function populate(StateInterface $state): void |
41 | 41 | { |
42 | - if ($this->request === null) { |
|
42 | + if ($this->request === null) |
|
43 | + { |
|
43 | 44 | return; |
44 | 45 | } |
45 | 46 | |
@@ -48,11 +49,13 @@ discard block |
||
48 | 49 | |
49 | 50 | $state->setVariable('headers', $this->request->getHeaders()); |
50 | 51 | |
51 | - if ($this->request->getQueryParams() !== []) { |
|
52 | + if ($this->request->getQueryParams() !== []) |
|
53 | + { |
|
52 | 54 | $state->setVariable('query', $this->request->getQueryParams()); |
53 | 55 | } |
54 | 56 | |
55 | - if ($this->request->getParsedBody() !== null) { |
|
57 | + if ($this->request->getParsedBody() !== null) |
|
58 | + { |
|
56 | 59 | $state->setVariable('data', $this->request->getParsedBody()); |
57 | 60 | } |
58 | 61 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs): void |
38 | 38 | { |
39 | 39 | $protoFile = $this->argument('proto'); |
40 | - if (!file_exists($protoFile)) { |
|
40 | + if (!file_exists($protoFile)){ |
|
41 | 41 | $this->sprintf('<error>File `%s` not found.</error>', $protoFile); |
42 | 42 | return; |
43 | 43 | } |
@@ -50,19 +50,19 @@ discard block |
||
50 | 50 | |
51 | 51 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
52 | 52 | |
53 | - try { |
|
53 | + try{ |
|
54 | 54 | $result = $compiler->compile($protoFile); |
55 | - } catch (\Throwable $e) { |
|
55 | + }catch (\Throwable $e){ |
|
56 | 56 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | - if ($result === []) { |
|
60 | + if ($result === []){ |
|
61 | 61 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - foreach ($result as $file) { |
|
65 | + foreach ($result as $file){ |
|
66 | 66 | $this->sprintf( |
67 | 67 | "<fg=green>•</fg=green> %s%s%s\n", |
68 | 68 | Color::LIGHT_WHITE, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | protected function getPath(KernelInterface $kernel): string |
82 | 82 | { |
83 | 83 | $path = $this->argument('path'); |
84 | - if ($path !== 'auto') { |
|
84 | + if ($path !== 'auto'){ |
|
85 | 85 | return $path; |
86 | 86 | } |
87 | 87 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | protected function getNamespace(KernelInterface $kernel): string |
100 | 100 | { |
101 | 101 | $namespace = $this->argument('namespace'); |
102 | - if ($namespace !== 'auto') { |
|
102 | + if ($namespace !== 'auto'){ |
|
103 | 103 | return $namespace; |
104 | 104 | } |
105 | 105 |
@@ -37,7 +37,8 @@ discard block |
||
37 | 37 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs): void |
38 | 38 | { |
39 | 39 | $protoFile = $this->argument('proto'); |
40 | - if (!file_exists($protoFile)) { |
|
40 | + if (!file_exists($protoFile)) |
|
41 | + { |
|
41 | 42 | $this->sprintf('<error>File `%s` not found.</error>', $protoFile); |
42 | 43 | return; |
43 | 44 | } |
@@ -50,19 +51,24 @@ discard block |
||
50 | 51 | |
51 | 52 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
52 | 53 | |
53 | - try { |
|
54 | + try |
|
55 | + { |
|
54 | 56 | $result = $compiler->compile($protoFile); |
55 | - } catch (\Throwable $e) { |
|
57 | + } |
|
58 | + catch (\Throwable $e) |
|
59 | + { |
|
56 | 60 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
57 | 61 | return; |
58 | 62 | } |
59 | 63 | |
60 | - if ($result === []) { |
|
64 | + if ($result === []) |
|
65 | + { |
|
61 | 66 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
62 | 67 | return; |
63 | 68 | } |
64 | 69 | |
65 | - foreach ($result as $file) { |
|
70 | + foreach ($result as $file) |
|
71 | + { |
|
66 | 72 | $this->sprintf( |
67 | 73 | "<fg=green>•</fg=green> %s%s%s\n", |
68 | 74 | Color::LIGHT_WHITE, |
@@ -81,7 +87,8 @@ discard block |
||
81 | 87 | protected function getPath(KernelInterface $kernel): string |
82 | 88 | { |
83 | 89 | $path = $this->argument('path'); |
84 | - if ($path !== 'auto') { |
|
90 | + if ($path !== 'auto') |
|
91 | + { |
|
85 | 92 | return $path; |
86 | 93 | } |
87 | 94 | |
@@ -99,7 +106,8 @@ discard block |
||
99 | 106 | protected function getNamespace(KernelInterface $kernel): string |
100 | 107 | { |
101 | 108 | $namespace = $this->argument('namespace'); |
102 | - if ($namespace !== 'auto') { |
|
109 | + if ($namespace !== 'auto') |
|
110 | + { |
|
103 | 111 | return $namespace; |
104 | 112 | } |
105 | 113 |