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