@@ -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 | |
@@ -6,7 +6,8 @@ |
||
| 6 | 6 | * @author Anton Titov (Wolfy-J) |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if (!function_exists('bind')) { |
|
| 9 | +if (!function_exists('bind')) |
|
| 10 | +{ |
|
| 10 | 11 | /** |
| 11 | 12 | * Shortcut to container Autowire definition. |
| 12 | 13 | * |
@@ -91,17 +91,23 @@ |
||
| 91 | 91 | protected function rotateSnapshots() |
| 92 | 92 | { |
| 93 | 93 | $finder = new Finder(); |
| 94 | - $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) { |
|
| 94 | + $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) |
|
| 95 | + { |
|
| 95 | 96 | return $b->getMTime() - $a->getMTime(); |
| 96 | 97 | }); |
| 97 | 98 | |
| 98 | 99 | $count = 0; |
| 99 | - foreach ($finder as $file) { |
|
| 100 | + foreach ($finder as $file) |
|
| 101 | + { |
|
| 100 | 102 | $count++; |
| 101 | - if ($count > $this->maxFiles) { |
|
| 102 | - try { |
|
| 103 | + if ($count > $this->maxFiles) |
|
| 104 | + { |
|
| 105 | + try |
|
| 106 | + { |
|
| 103 | 107 | $this->files->delete($file->getRealPath()); |
| 104 | - } catch (FilesException $e) { |
|
| 108 | + } |
|
| 109 | + catch (FilesException $e) |
|
| 110 | + { |
|
| 105 | 111 | |
| 106 | 112 | } |
| 107 | 113 | } |
@@ -63,11 +63,16 @@ discard block |
||
| 63 | 63 | /** @var ConsoleCore $core */ |
| 64 | 64 | $core = $this->container->get(ConsoleCore::class); |
| 65 | 65 | |
| 66 | - try { |
|
| 66 | + try |
|
| 67 | + { |
|
| 67 | 68 | $core->start(new ArgvInput(), $output); |
| 68 | - } catch (\Throwable $e) { |
|
| 69 | + } |
|
| 70 | + catch (\Throwable $e) |
|
| 71 | + { |
|
| 69 | 72 | $this->handleException($e, $output); |
| 70 | - } finally { |
|
| 73 | + } |
|
| 74 | + finally |
|
| 75 | + { |
|
| 71 | 76 | $listener->disable(); |
| 72 | 77 | } |
| 73 | 78 | } |
@@ -78,9 +83,12 @@ discard block |
||
| 78 | 83 | */ |
| 79 | 84 | protected function handleException(\Throwable $e, OutputInterface $output) |
| 80 | 85 | { |
| 81 | - try { |
|
| 86 | + try |
|
| 87 | + { |
|
| 82 | 88 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 83 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 89 | + } |
|
| 90 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 91 | + { |
|
| 84 | 92 | // no need to notify when unable to register an exception |
| 85 | 93 | } |
| 86 | 94 | |
@@ -95,11 +103,13 @@ discard block |
||
| 95 | 103 | */ |
| 96 | 104 | private function mapVerbosity(OutputInterface $output): int |
| 97 | 105 | { |
| 98 | - if ($output->isDebug()) { |
|
| 106 | + if ($output->isDebug()) |
|
| 107 | + { |
|
| 99 | 108 | return ConsoleHandler::VERBOSITY_DEBUG; |
| 100 | 109 | } |
| 101 | 110 | |
| 102 | - if ($output->isVerbose() || $output->isVeryVerbose()) { |
|
| 111 | + if ($output->isVerbose() || $output->isVeryVerbose()) |
|
| 112 | + { |
|
| 103 | 113 | return ConsoleHandler::VERBOSITY_VERBOSE; |
| 104 | 114 | } |
| 105 | 115 | |
@@ -48,12 +48,14 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function __invoke(LogEvent $event) |
| 50 | 50 | { |
| 51 | - if (empty($this->output)) { |
|
| 51 | + if (empty($this->output)) |
|
| 52 | + { |
|
| 52 | 53 | return; |
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | |
| 56 | - if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE) { |
|
| 57 | + if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERY_VERBOSE) |
|
| 58 | + { |
|
| 57 | 59 | return; |
| 58 | 60 | } |
| 59 | 61 | |
@@ -89,7 +91,8 @@ discard block |
||
| 89 | 91 | */ |
| 90 | 92 | public function enable(): self |
| 91 | 93 | { |
| 92 | - if (!empty($this->logs)) { |
|
| 94 | + if (!empty($this->logs)) |
|
| 95 | + { |
|
| 93 | 96 | $this->logs->addListener($this); |
| 94 | 97 | } |
| 95 | 98 | |
@@ -103,7 +106,8 @@ discard block |
||
| 103 | 106 | */ |
| 104 | 107 | public function disable(): self |
| 105 | 108 | { |
| 106 | - if (!empty($this->logs)) { |
|
| 109 | + if (!empty($this->logs)) |
|
| 110 | + { |
|
| 107 | 111 | $this->logs->removeListener($this); |
| 108 | 112 | } |
| 109 | 113 | |
@@ -127,7 +131,8 @@ discard block |
||
| 127 | 131 | */ |
| 128 | 132 | private function getChannel(string $channel): string |
| 129 | 133 | { |
| 130 | - if (!class_exists($channel, false)) { |
|
| 134 | + if (!class_exists($channel, false)) |
|
| 135 | + { |
|
| 131 | 136 | return "[{$channel}]"; |
| 132 | 137 | } |
| 133 | 138 | |
@@ -143,7 +148,8 @@ discard block |
||
| 143 | 148 | */ |
| 144 | 149 | private function getMessage(bool $decorated, string $message) |
| 145 | 150 | { |
| 146 | - if (!$decorated) { |
|
| 151 | + if (!$decorated) |
|
| 152 | + { |
|
| 147 | 153 | return $message; |
| 148 | 154 | } |
| 149 | 155 | |
@@ -43,19 +43,26 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $runtimeDirectory = $this->directories->get('runtime'); |
| 45 | 45 | |
| 46 | - if (!$this->files->exists($runtimeDirectory)) { |
|
| 46 | + if (!$this->files->exists($runtimeDirectory)) |
|
| 47 | + { |
|
| 47 | 48 | $this->files->ensureDirectory($runtimeDirectory); |
| 48 | 49 | $output->writeln("<comment>created</comment>"); |
| 49 | 50 | return; |
| 50 | - } else { |
|
| 51 | + } |
|
| 52 | + else |
|
| 53 | + { |
|
| 51 | 54 | $output->writeln("<info>exists</info>"); |
| 52 | 55 | } |
| 53 | 56 | |
| 54 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
| 55 | - try { |
|
| 57 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename) |
|
| 58 | + { |
|
| 59 | + try |
|
| 60 | + { |
|
| 56 | 61 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
| 57 | 62 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
| 58 | - } catch (\Throwable $e) { |
|
| 63 | + } |
|
| 64 | + catch (\Throwable $e) |
|
| 65 | + { |
|
| 59 | 66 | $output->writeln(sprintf( |
| 60 | 67 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
| 61 | 68 | $this->files->relativePath($filename, $runtimeDirectory), |
@@ -64,7 +71,8 @@ discard block |
||
| 64 | 71 | continue; |
| 65 | 72 | } |
| 66 | 73 | |
| 67 | - if ($output->isVerbose()) { |
|
| 74 | + if ($output->isVerbose()) |
|
| 75 | + { |
|
| 68 | 76 | $output->writeln(sprintf( |
| 69 | 77 | "<fg=green>[updated]</fg=green> `%s`", |
| 70 | 78 | $this->files->relativePath($filename, $runtimeDirectory) |
@@ -77,7 +77,8 @@ |
||
| 77 | 77 | */ |
| 78 | 78 | private function sequencePatch(string $target, $sequence, string $header, string $footer, array $options) |
| 79 | 79 | { |
| 80 | - if (is_array($sequence)) { |
|
| 80 | + if (is_array($sequence)) |
|
| 81 | + { |
|
| 81 | 82 | return new AppendPatch($target, null, new CallableSequence($sequence, $options, $header, $footer)); |
| 82 | 83 | } |
| 83 | 84 | |
@@ -25,7 +25,8 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | public function perform(ConsoleCore $console) |
| 27 | 27 | { |
| 28 | - if (!$this->verifyEnvironment()) { |
|
| 28 | + if (!$this->verifyEnvironment()) |
|
| 29 | + { |
|
| 29 | 30 | //Making sure we can safely migrate in this environment |
| 30 | 31 | return; |
| 31 | 32 | } |
@@ -33,9 +34,12 @@ discard block |
||
| 33 | 34 | $rollback = ['--force' => true]; |
| 34 | 35 | $migrate = ['--force' => true]; |
| 35 | 36 | |
| 36 | - if ($this->option('all')) { |
|
| 37 | + if ($this->option('all')) |
|
| 38 | + { |
|
| 37 | 39 | $rollback['--all'] = true; |
| 38 | - } else { |
|
| 40 | + } |
|
| 41 | + else |
|
| 42 | + { |
|
| 39 | 43 | $migrate['--one'] = true; |
| 40 | 44 | } |
| 41 | 45 | |