@@ -32,11 +32,13 @@ |
||
32 | 32 | */ |
33 | 33 | protected function mapDirectories(array $directories): array |
34 | 34 | { |
35 | - if (!isset($directories['root'])) { |
|
35 | + if (!isset($directories['root'])) |
|
36 | + { |
|
36 | 37 | throw new FrameworkException("Missing required directory `root`."); |
37 | 38 | } |
38 | 39 | |
39 | - if (!isset($directories['app'])) { |
|
40 | + if (!isset($directories['app'])) |
|
41 | + { |
|
40 | 42 | $directories['app'] = $directories['root'] . '/app/'; |
41 | 43 | } |
42 | 44 |
@@ -57,9 +57,12 @@ discard block |
||
57 | 57 | $core = $this->container->get(ConsoleCore::class); |
58 | 58 | $output = new ConsoleOutput(); |
59 | 59 | |
60 | - try { |
|
60 | + try |
|
61 | + { |
|
61 | 62 | $core->start(new ArgvInput(), $output); |
62 | - } catch (\Throwable $e) { |
|
63 | + } |
|
64 | + catch (\Throwable $e) |
|
65 | + { |
|
63 | 66 | $this->handleException($e, $output); |
64 | 67 | } |
65 | 68 | } |
@@ -70,9 +73,12 @@ discard block |
||
70 | 73 | */ |
71 | 74 | protected function handleException(\Throwable $e, OutputInterface $output) |
72 | 75 | { |
73 | - try { |
|
76 | + try |
|
77 | + { |
|
74 | 78 | $this->container->get(SnapshotterInterface::class)->register($e); |
75 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
79 | + } |
|
80 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
81 | + { |
|
76 | 82 | // no need to notify when unable to register an exception |
77 | 83 | } |
78 | 84 | |
@@ -87,11 +93,13 @@ discard block |
||
87 | 93 | */ |
88 | 94 | private function mapVerbosity(OutputInterface $output): int |
89 | 95 | { |
90 | - if ($output->isDebug() || $output->isVeryVerbose()) { |
|
96 | + if ($output->isDebug() || $output->isVeryVerbose()) |
|
97 | + { |
|
91 | 98 | return ConsoleHandler::VERBOSITY_DEBUG; |
92 | 99 | } |
93 | 100 | |
94 | - if ($output->isVerbose()) { |
|
101 | + if ($output->isVerbose()) |
|
102 | + { |
|
95 | 103 | return ConsoleHandler::VERBOSITY_VERBOSE; |
96 | 104 | } |
97 | 105 |
@@ -58,10 +58,13 @@ discard block |
||
58 | 58 | $http = $this->container->get(HttpCore::class); |
59 | 59 | $emitter = $this->container->get(EmitterInterface::class); |
60 | 60 | |
61 | - try { |
|
61 | + try |
|
62 | + { |
|
62 | 63 | $response = $http->handle($this->initRequest()); |
63 | 64 | $emitter->emit($response); |
64 | - } catch (\Throwable $e) { |
|
65 | + } |
|
66 | + catch (\Throwable $e) |
|
67 | + { |
|
65 | 68 | $this->handleException($emitter, $e); |
66 | 69 | } |
67 | 70 | } |
@@ -82,10 +85,13 @@ discard block |
||
82 | 85 | { |
83 | 86 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
84 | 87 | |
85 | - try { |
|
88 | + try |
|
89 | + { |
|
86 | 90 | /** @var SnapshotInterface $snapshot */ |
87 | 91 | $this->container->get(SnapshotterInterface::class)->register($e); |
88 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
92 | + } |
|
93 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
94 | + { |
|
89 | 95 | // nothing to report |
90 | 96 | } |
91 | 97 |
@@ -70,7 +70,8 @@ discard block |
||
70 | 70 | |
71 | 71 | $response = $this->scope->runScope( |
72 | 72 | [SessionInterface::class => $session], |
73 | - function () use ($session, $request, $handler) { |
|
73 | + function () use ($session, $request, $handler) |
|
74 | + { |
|
74 | 75 | return $handler->handle($request->withAttribute(static::ATTRIBUTE, $session)); |
75 | 76 | } |
76 | 77 | ); |
@@ -90,14 +91,16 @@ discard block |
||
90 | 91 | Request $request, |
91 | 92 | Response $response |
92 | 93 | ): Response { |
93 | - if (!$session->isStarted()) { |
|
94 | + if (!$session->isStarted()) |
|
95 | + { |
|
94 | 96 | return $response; |
95 | 97 | } |
96 | 98 | |
97 | 99 | $session->commit(); |
98 | 100 | |
99 | 101 | //SID changed |
100 | - if ($this->fetchID($request) != $session->getID()) { |
|
102 | + if ($this->fetchID($request) != $session->getID()) |
|
103 | + { |
|
101 | 104 | return $this->withCookie($request, $response, $session->getID()); |
102 | 105 | } |
103 | 106 | |
@@ -115,7 +118,8 @@ discard block |
||
115 | 118 | protected function fetchID(Request $request): ?string |
116 | 119 | { |
117 | 120 | $cookies = $request->getCookieParams(); |
118 | - if (empty($cookies[$this->config->getCookie()])) { |
|
121 | + if (empty($cookies[$this->config->getCookie()])) |
|
122 | + { |
|
119 | 123 | return null; |
120 | 124 | } |
121 | 125 | |
@@ -150,7 +154,8 @@ discard block |
||
150 | 154 | protected function clientSignature(Request $request): string |
151 | 155 | { |
152 | 156 | $signature = ''; |
153 | - foreach (static::SIGNATURE_HEADERS as $header) { |
|
157 | + foreach (static::SIGNATURE_HEADERS as $header) |
|
158 | + { |
|
154 | 159 | $signature .= $request->getHeaderLine($header) . ';'; |
155 | 160 | } |
156 | 161 |
@@ -70,13 +70,20 @@ discard block |
||
70 | 70 | $http = $this->container->get(HttpCore::class); |
71 | 71 | $client = $this->psr7Client(); |
72 | 72 | |
73 | - while ($request = $client->acceptRequest()) { |
|
74 | - try { |
|
73 | + while ($request = $client->acceptRequest()) |
|
74 | + { |
|
75 | + try |
|
76 | + { |
|
75 | 77 | $client->respond($http->handle($request)); |
76 | - } catch (\Throwable $e) { |
|
78 | + } |
|
79 | + catch (\Throwable $e) |
|
80 | + { |
|
77 | 81 | $this->handleException($client, $e); |
78 | - } finally { |
|
79 | - foreach ($this->finalizers as $finalizer) { |
|
82 | + } |
|
83 | + finally |
|
84 | + { |
|
85 | + foreach ($this->finalizers as $finalizer) |
|
86 | + { |
|
80 | 87 | call_user_func($finalizer); |
81 | 88 | } |
82 | 89 | } |
@@ -101,11 +108,14 @@ discard block |
||
101 | 108 | { |
102 | 109 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
103 | 110 | |
104 | - try { |
|
111 | + try |
|
112 | + { |
|
105 | 113 | /** @var SnapshotInterface $snapshot */ |
106 | 114 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
107 | 115 | error_log($snapshot->getMessage()); |
108 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
116 | + } |
|
117 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
118 | + { |
|
109 | 119 | error_log($handler->getMessage($e)); |
110 | 120 | } |
111 | 121 |
@@ -33,7 +33,8 @@ discard block |
||
33 | 33 | { |
34 | 34 | $kernel->addDispatcher($rr); |
35 | 35 | |
36 | - if (function_exists('gc_collect_cycles')) { |
|
36 | + if (function_exists('gc_collect_cycles')) |
|
37 | + { |
|
37 | 38 | $rr->addFinalizer('gc_collect_cycles'); |
38 | 39 | } |
39 | 40 | } |
@@ -46,21 +47,26 @@ discard block |
||
46 | 47 | { |
47 | 48 | $conn = $environment->get('RR_RPC', static::RPC_DEFAULT); |
48 | 49 | |
49 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
50 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
51 | + { |
|
50 | 52 | throw new RoadRunnerException( |
51 | 53 | "Unable to create RPC connection, invalid DSN given `{$conn}`." |
52 | 54 | ); |
53 | 55 | } |
54 | 56 | |
55 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
57 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
58 | + { |
|
56 | 59 | throw new RoadRunnerException( |
57 | 60 | "Unable to create RPC connection, invalid DSN given `{$conn}`." |
58 | 61 | ); |
59 | 62 | } |
60 | 63 | |
61 | - if ($parts[1] == 'unix') { |
|
64 | + if ($parts[1] == 'unix') |
|
65 | + { |
|
62 | 66 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
63 | - } else { |
|
67 | + } |
|
68 | + else |
|
69 | + { |
|
64 | 70 | $relay = new SocketRelay($parts[2], $parts[3], SocketRelay::SOCK_TCP); |
65 | 71 | } |
66 | 72 |