@@ -13,8 +13,10 @@ |
||
| 13 | 13 | |
| 14 | 14 | class TestJob extends AbstractJob |
| 15 | 15 | { |
| 16 | - public function do(EnvironmentInterface $env) |
|
| 16 | + public function do{ |
|
| 17 | + (EnvironmentInterface $env) |
|
| 17 | 18 | { |
| 18 | 19 | $env->set('FIRED', true); |
| 19 | 20 | } |
| 21 | + } |
|
| 20 | 22 | } |
| 21 | 23 | \ No newline at end of file |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | $this->output->writeln("<info>Detecting schema changes:</info>"); |
| 41 | 41 | |
| 42 | 42 | $this->changes = []; |
| 43 | - foreach ($registry->getIterator() as $e) { |
|
| 44 | - if ($registry->hasTable($e)) { |
|
| 43 | + foreach ($registry->getIterator() as $e){ |
|
| 44 | + if ($registry->hasTable($e)){ |
|
| 45 | 45 | $table = $registry->getTableSchema($e); |
| 46 | 46 | |
| 47 | - if ($table->getComparator()->hasChanges()) { |
|
| 47 | + if ($table->getComparator()->hasChanges()){ |
|
| 48 | 48 | $this->changes[] = [ |
| 49 | 49 | 'database' => $registry->getDatabase($e), |
| 50 | 50 | 'table' => $registry->getTable($e), |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if ($this->changes === []) { |
|
| 57 | + if ($this->changes === []){ |
|
| 58 | 58 | $this->output->writeln("<fg=yellow>no database changes has been detected</fg=yellow>"); |
| 59 | 59 | |
| 60 | 60 | return $registry; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - foreach ($this->changes as $change) { |
|
| 63 | + foreach ($this->changes as $change){ |
|
| 64 | 64 | $this->output->write(sprintf("• <fg=cyan>%s.%s</fg=cyan>", $change['database'], $change['table'])); |
| 65 | 65 | $this->describeChanges($change['schema']); |
| 66 | 66 | } |
@@ -73,22 +73,22 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function describeChanges(AbstractTable $table) |
| 75 | 75 | { |
| 76 | - if (!$this->output->isVerbose()) { |
|
| 76 | + if (!$this->output->isVerbose()){ |
|
| 77 | 77 | $this->output->writeln(sprintf( |
| 78 | 78 | ": <fg=green>%s</fg=green> change(s) detected", |
| 79 | 79 | $this->numChanges($table) |
| 80 | 80 | )); |
| 81 | 81 | |
| 82 | 82 | return; |
| 83 | - } else { |
|
| 83 | + }else{ |
|
| 84 | 84 | $this->output->write("\n"); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if (!$table->exists()) { |
|
| 87 | + if (!$table->exists()){ |
|
| 88 | 88 | $this->output->writeln(" - create table"); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
|
| 91 | + if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED){ |
|
| 92 | 92 | $this->output->writeln(" - drop table"); |
| 93 | 93 | return; |
| 94 | 94 | } |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | protected function describeColumns(Comparator $cmp) |
| 107 | 107 | { |
| 108 | - foreach ($cmp->addedColumns() as $column) { |
|
| 108 | + foreach ($cmp->addedColumns() as $column){ |
|
| 109 | 109 | $this->output->writeln(" - add column <fg=yellow>{$column->getName()}</fg=yellow>"); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - foreach ($cmp->droppedColumns() as $column) { |
|
| 112 | + foreach ($cmp->droppedColumns() as $column){ |
|
| 113 | 113 | $this->output->writeln(" - drop column <fg=yellow>{$column->getName()}</fg=yellow>"); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - foreach ($cmp->alteredColumns() as $column) { |
|
| 116 | + foreach ($cmp->alteredColumns() as $column){ |
|
| 117 | 117 | $column = $column[0]; |
| 118 | 118 | $this->output->writeln(" - alter column <fg=yellow>{$column->getName()}</fg=yellow>"); |
| 119 | 119 | } |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | protected function describeIndexes(Comparator $cmp) |
| 126 | 126 | { |
| 127 | - foreach ($cmp->addedIndexes() as $index) { |
|
| 127 | + foreach ($cmp->addedIndexes() as $index){ |
|
| 128 | 128 | $index = join(', ', $index->getColumns()); |
| 129 | 129 | $this->output->writeln(" - add index on <fg=yellow>[{$index}]</fg=yellow>"); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - foreach ($cmp->droppedIndexes() as $index) { |
|
| 132 | + foreach ($cmp->droppedIndexes() as $index){ |
|
| 133 | 133 | $index = join(', ', $index->getColumns()); |
| 134 | 134 | $this->output->writeln(" - drop index on <fg=yellow>[{$index}]</fg=yellow>"); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - foreach ($cmp->alteredIndexes() as $index) { |
|
| 137 | + foreach ($cmp->alteredIndexes() as $index){ |
|
| 138 | 138 | $index = $index[0]; |
| 139 | 139 | $index = join(', ', $index->getColumns()); |
| 140 | 140 | $this->output->writeln(" - alter index on <fg=yellow>[{$index}]</fg=yellow>"); |
@@ -146,15 +146,15 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | protected function describeFKs(Comparator $cmp) |
| 148 | 148 | { |
| 149 | - foreach ($cmp->addedForeignKeys() as $fk) { |
|
| 149 | + foreach ($cmp->addedForeignKeys() as $fk){ |
|
| 150 | 150 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
| 153 | + foreach ($cmp->droppedForeignKeys() as $fk){ |
|
| 154 | 154 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
| 157 | + foreach ($cmp->alteredForeignKeys() as $fk){ |
|
| 158 | 158 | $fk = $fk[0]; |
| 159 | 159 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
| 160 | 160 | } |
@@ -40,11 +40,14 @@ discard block |
||
| 40 | 40 | $this->output->writeln("<info>Detecting schema changes:</info>"); |
| 41 | 41 | |
| 42 | 42 | $this->changes = []; |
| 43 | - foreach ($registry->getIterator() as $e) { |
|
| 44 | - if ($registry->hasTable($e)) { |
|
| 43 | + foreach ($registry->getIterator() as $e) |
|
| 44 | + { |
|
| 45 | + if ($registry->hasTable($e)) |
|
| 46 | + { |
|
| 45 | 47 | $table = $registry->getTableSchema($e); |
| 46 | 48 | |
| 47 | - if ($table->getComparator()->hasChanges()) { |
|
| 49 | + if ($table->getComparator()->hasChanges()) |
|
| 50 | + { |
|
| 48 | 51 | $this->changes[] = [ |
| 49 | 52 | 'database' => $registry->getDatabase($e), |
| 50 | 53 | 'table' => $registry->getTable($e), |
@@ -54,13 +57,15 @@ discard block |
||
| 54 | 57 | } |
| 55 | 58 | } |
| 56 | 59 | |
| 57 | - if ($this->changes === []) { |
|
| 60 | + if ($this->changes === []) |
|
| 61 | + { |
|
| 58 | 62 | $this->output->writeln("<fg=yellow>no database changes has been detected</fg=yellow>"); |
| 59 | 63 | |
| 60 | 64 | return $registry; |
| 61 | 65 | } |
| 62 | 66 | |
| 63 | - foreach ($this->changes as $change) { |
|
| 67 | + foreach ($this->changes as $change) |
|
| 68 | + { |
|
| 64 | 69 | $this->output->write(sprintf("• <fg=cyan>%s.%s</fg=cyan>", $change['database'], $change['table'])); |
| 65 | 70 | $this->describeChanges($change['schema']); |
| 66 | 71 | } |
@@ -73,22 +78,27 @@ discard block |
||
| 73 | 78 | */ |
| 74 | 79 | protected function describeChanges(AbstractTable $table) |
| 75 | 80 | { |
| 76 | - if (!$this->output->isVerbose()) { |
|
| 81 | + if (!$this->output->isVerbose()) |
|
| 82 | + { |
|
| 77 | 83 | $this->output->writeln(sprintf( |
| 78 | 84 | ": <fg=green>%s</fg=green> change(s) detected", |
| 79 | 85 | $this->numChanges($table) |
| 80 | 86 | )); |
| 81 | 87 | |
| 82 | 88 | return; |
| 83 | - } else { |
|
| 89 | + } |
|
| 90 | + else |
|
| 91 | + { |
|
| 84 | 92 | $this->output->write("\n"); |
| 85 | 93 | } |
| 86 | 94 | |
| 87 | - if (!$table->exists()) { |
|
| 95 | + if (!$table->exists()) |
|
| 96 | + { |
|
| 88 | 97 | $this->output->writeln(" - create table"); |
| 89 | 98 | } |
| 90 | 99 | |
| 91 | - if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
|
| 100 | + if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) |
|
| 101 | + { |
|
| 92 | 102 | $this->output->writeln(" - drop table"); |
| 93 | 103 | return; |
| 94 | 104 | } |
@@ -105,15 +115,18 @@ discard block |
||
| 105 | 115 | */ |
| 106 | 116 | protected function describeColumns(Comparator $cmp) |
| 107 | 117 | { |
| 108 | - foreach ($cmp->addedColumns() as $column) { |
|
| 118 | + foreach ($cmp->addedColumns() as $column) |
|
| 119 | + { |
|
| 109 | 120 | $this->output->writeln(" - add column <fg=yellow>{$column->getName()}</fg=yellow>"); |
| 110 | 121 | } |
| 111 | 122 | |
| 112 | - foreach ($cmp->droppedColumns() as $column) { |
|
| 123 | + foreach ($cmp->droppedColumns() as $column) |
|
| 124 | + { |
|
| 113 | 125 | $this->output->writeln(" - drop column <fg=yellow>{$column->getName()}</fg=yellow>"); |
| 114 | 126 | } |
| 115 | 127 | |
| 116 | - foreach ($cmp->alteredColumns() as $column) { |
|
| 128 | + foreach ($cmp->alteredColumns() as $column) |
|
| 129 | + { |
|
| 117 | 130 | $column = $column[0]; |
| 118 | 131 | $this->output->writeln(" - alter column <fg=yellow>{$column->getName()}</fg=yellow>"); |
| 119 | 132 | } |
@@ -124,17 +137,20 @@ discard block |
||
| 124 | 137 | */ |
| 125 | 138 | protected function describeIndexes(Comparator $cmp) |
| 126 | 139 | { |
| 127 | - foreach ($cmp->addedIndexes() as $index) { |
|
| 140 | + foreach ($cmp->addedIndexes() as $index) |
|
| 141 | + { |
|
| 128 | 142 | $index = join(', ', $index->getColumns()); |
| 129 | 143 | $this->output->writeln(" - add index on <fg=yellow>[{$index}]</fg=yellow>"); |
| 130 | 144 | } |
| 131 | 145 | |
| 132 | - foreach ($cmp->droppedIndexes() as $index) { |
|
| 146 | + foreach ($cmp->droppedIndexes() as $index) |
|
| 147 | + { |
|
| 133 | 148 | $index = join(', ', $index->getColumns()); |
| 134 | 149 | $this->output->writeln(" - drop index on <fg=yellow>[{$index}]</fg=yellow>"); |
| 135 | 150 | } |
| 136 | 151 | |
| 137 | - foreach ($cmp->alteredIndexes() as $index) { |
|
| 152 | + foreach ($cmp->alteredIndexes() as $index) |
|
| 153 | + { |
|
| 138 | 154 | $index = $index[0]; |
| 139 | 155 | $index = join(', ', $index->getColumns()); |
| 140 | 156 | $this->output->writeln(" - alter index on <fg=yellow>[{$index}]</fg=yellow>"); |
@@ -146,15 +162,18 @@ discard block |
||
| 146 | 162 | */ |
| 147 | 163 | protected function describeFKs(Comparator $cmp) |
| 148 | 164 | { |
| 149 | - foreach ($cmp->addedForeignKeys() as $fk) { |
|
| 165 | + foreach ($cmp->addedForeignKeys() as $fk) |
|
| 166 | + { |
|
| 150 | 167 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
| 151 | 168 | } |
| 152 | 169 | |
| 153 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
| 170 | + foreach ($cmp->droppedForeignKeys() as $fk) |
|
| 171 | + { |
|
| 154 | 172 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
| 155 | 173 | } |
| 156 | 174 | |
| 157 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
| 175 | + foreach ($cmp->alteredForeignKeys() as $fk) |
|
| 176 | + { |
|
| 158 | 177 | $fk = $fk[0]; |
| 159 | 178 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fk->getColumn()}</fg=yellow>"); |
| 160 | 179 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | EnvironmentInterface $env, |
| 46 | 46 | FinalizerInterface $finalizer, |
| 47 | 47 | ContainerInterface $container |
| 48 | - ) { |
|
| 48 | + ){ |
|
| 49 | 49 | $this->env = $env; |
| 50 | 50 | $this->finalizer = $finalizer; |
| 51 | 51 | $this->container = $container; |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | /** @var Console $console */ |
| 75 | 75 | $console = $this->container->get(Console::class); |
| 76 | 76 | |
| 77 | - try { |
|
| 77 | + try{ |
|
| 78 | 78 | $console->start($input ?? new ArgvInput(), $output); |
| 79 | - } catch (\Throwable $e) { |
|
| 79 | + }catch (\Throwable $e){ |
|
| 80 | 80 | $this->handleException($e, $output); |
| 81 | - } finally { |
|
| 81 | + }finally{ |
|
| 82 | 82 | $listener->disable(); |
| 83 | 83 | $this->finalizer->finalize(false); |
| 84 | 84 | } |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | protected function handleException(\Throwable $e, OutputInterface $output) |
| 92 | 92 | { |
| 93 | - try { |
|
| 93 | + try{ |
|
| 94 | 94 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 95 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 95 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 96 | 96 | // no need to notify when unable to register an exception |
| 97 | 97 | } |
| 98 | 98 | |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | private function mapVerbosity(OutputInterface $output): int |
| 109 | 109 | { |
| 110 | - if ($output->isDebug() || $output->isVeryVerbose()) { |
|
| 110 | + if ($output->isDebug() || $output->isVeryVerbose()){ |
|
| 111 | 111 | return ConsoleHandler::VERBOSITY_DEBUG; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if ($output->isVerbose()) { |
|
| 114 | + if ($output->isVerbose()){ |
|
| 115 | 115 | return ConsoleHandler::VERBOSITY_VERBOSE; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -74,11 +74,16 @@ discard block |
||
| 74 | 74 | /** @var Console $console */ |
| 75 | 75 | $console = $this->container->get(Console::class); |
| 76 | 76 | |
| 77 | - try { |
|
| 77 | + try |
|
| 78 | + { |
|
| 78 | 79 | $console->start($input ?? new ArgvInput(), $output); |
| 79 | - } catch (\Throwable $e) { |
|
| 80 | + } |
|
| 81 | + catch (\Throwable $e) |
|
| 82 | + { |
|
| 80 | 83 | $this->handleException($e, $output); |
| 81 | - } finally { |
|
| 84 | + } |
|
| 85 | + finally |
|
| 86 | + { |
|
| 82 | 87 | $listener->disable(); |
| 83 | 88 | $this->finalizer->finalize(false); |
| 84 | 89 | } |
@@ -90,9 +95,12 @@ discard block |
||
| 90 | 95 | */ |
| 91 | 96 | protected function handleException(\Throwable $e, OutputInterface $output) |
| 92 | 97 | { |
| 93 | - try { |
|
| 98 | + try |
|
| 99 | + { |
|
| 94 | 100 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 95 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 101 | + } |
|
| 102 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 103 | + { |
|
| 96 | 104 | // no need to notify when unable to register an exception |
| 97 | 105 | } |
| 98 | 106 | |
@@ -107,11 +115,13 @@ discard block |
||
| 107 | 115 | */ |
| 108 | 116 | private function mapVerbosity(OutputInterface $output): int |
| 109 | 117 | { |
| 110 | - if ($output->isDebug() || $output->isVeryVerbose()) { |
|
| 118 | + if ($output->isDebug() || $output->isVeryVerbose()) |
|
| 119 | + { |
|
| 111 | 120 | return ConsoleHandler::VERBOSITY_DEBUG; |
| 112 | 121 | } |
| 113 | 122 | |
| 114 | - if ($output->isVerbose()) { |
|
| 123 | + if ($output->isVerbose()) |
|
| 124 | + { |
|
| 115 | 125 | return ConsoleHandler::VERBOSITY_VERBOSE; |
| 116 | 126 | } |
| 117 | 127 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | HttpConfig $httpConfig, |
| 52 | 52 | SessionFactory $factory, |
| 53 | 53 | ScopeInterface $scope |
| 54 | - ) { |
|
| 54 | + ){ |
|
| 55 | 55 | $this->config = $config; |
| 56 | 56 | $this->httpConfig = $httpConfig; |
| 57 | 57 | $this->factory = $factory; |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | $this->fetchID($request) |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | - try { |
|
| 72 | + try{ |
|
| 73 | 73 | $response = $this->scope->runScope( |
| 74 | 74 | [SessionInterface::class => $session], |
| 75 | 75 | function () use ($session, $request, $handler) { |
| 76 | 76 | return $handler->handle($request->withAttribute(static::ATTRIBUTE, $session)); |
| 77 | 77 | } |
| 78 | 78 | ); |
| 79 | - } catch (\Throwable $e) { |
|
| 79 | + }catch (\Throwable $e){ |
|
| 80 | 80 | $session->abort(); |
| 81 | 81 | throw $e; |
| 82 | 82 | } |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | Request $request, |
| 96 | 96 | Response $response |
| 97 | 97 | ): Response { |
| 98 | - if (!$session->isStarted()) { |
|
| 98 | + if (!$session->isStarted()){ |
|
| 99 | 99 | return $response; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $session->commit(); |
| 103 | 103 | |
| 104 | 104 | //SID changed |
| 105 | - if ($this->fetchID($request) != $session->getID()) { |
|
| 105 | + if ($this->fetchID($request) != $session->getID()){ |
|
| 106 | 106 | return $this->withCookie($request, $response, $session->getID()); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | protected function fetchID(Request $request): ?string |
| 120 | 120 | { |
| 121 | 121 | $cookies = $request->getCookieParams(); |
| 122 | - if (empty($cookies[$this->config->getCookie()])) { |
|
| 122 | + if (empty($cookies[$this->config->getCookie()])){ |
|
| 123 | 123 | return null; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | protected function clientSignature(Request $request): string |
| 153 | 153 | { |
| 154 | 154 | $signature = ''; |
| 155 | - foreach (static::SIGNATURE_HEADERS as $header) { |
|
| 156 | - $signature .= $request->getHeaderLine($header) . ';'; |
|
| 155 | + foreach (static::SIGNATURE_HEADERS as $header){ |
|
| 156 | + $signature .= $request->getHeaderLine($header).';'; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | return hash('sha256', $signature); |
@@ -69,14 +69,18 @@ discard block |
||
| 69 | 69 | $this->fetchID($request) |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | - try { |
|
| 72 | + try |
|
| 73 | + { |
|
| 73 | 74 | $response = $this->scope->runScope( |
| 74 | 75 | [SessionInterface::class => $session], |
| 75 | - function () use ($session, $request, $handler) { |
|
| 76 | + function () use ($session, $request, $handler) |
|
| 77 | + { |
|
| 76 | 78 | return $handler->handle($request->withAttribute(static::ATTRIBUTE, $session)); |
| 77 | 79 | } |
| 78 | 80 | ); |
| 79 | - } catch (\Throwable $e) { |
|
| 81 | + } |
|
| 82 | + catch (\Throwable $e) |
|
| 83 | + { |
|
| 80 | 84 | $session->abort(); |
| 81 | 85 | throw $e; |
| 82 | 86 | } |
@@ -95,14 +99,16 @@ discard block |
||
| 95 | 99 | Request $request, |
| 96 | 100 | Response $response |
| 97 | 101 | ): Response { |
| 98 | - if (!$session->isStarted()) { |
|
| 102 | + if (!$session->isStarted()) |
|
| 103 | + { |
|
| 99 | 104 | return $response; |
| 100 | 105 | } |
| 101 | 106 | |
| 102 | 107 | $session->commit(); |
| 103 | 108 | |
| 104 | 109 | //SID changed |
| 105 | - if ($this->fetchID($request) != $session->getID()) { |
|
| 110 | + if ($this->fetchID($request) != $session->getID()) |
|
| 111 | + { |
|
| 106 | 112 | return $this->withCookie($request, $response, $session->getID()); |
| 107 | 113 | } |
| 108 | 114 | |
@@ -119,7 +125,8 @@ discard block |
||
| 119 | 125 | protected function fetchID(Request $request): ?string |
| 120 | 126 | { |
| 121 | 127 | $cookies = $request->getCookieParams(); |
| 122 | - if (empty($cookies[$this->config->getCookie()])) { |
|
| 128 | + if (empty($cookies[$this->config->getCookie()])) |
|
| 129 | + { |
|
| 123 | 130 | return null; |
| 124 | 131 | } |
| 125 | 132 | |
@@ -152,7 +159,8 @@ discard block |
||
| 152 | 159 | protected function clientSignature(Request $request): string |
| 153 | 160 | { |
| 154 | 161 | $signature = ''; |
| 155 | - foreach (static::SIGNATURE_HEADERS as $header) { |
|
| 162 | + foreach (static::SIGNATURE_HEADERS as $header) |
|
| 163 | + { |
|
| 156 | 164 | $signature .= $request->getHeaderLine($header) . ';'; |
| 157 | 165 | } |
| 158 | 166 | |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | $http = $this->container->get(HttpCore::class); |
| 60 | 60 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
| 61 | 61 | |
| 62 | - try { |
|
| 62 | + try{ |
|
| 63 | 63 | $response = $http->handle($this->initRequest()); |
| 64 | 64 | $emitter->emit($response); |
| 65 | - } catch (\Throwable $e) { |
|
| 65 | + }catch (\Throwable $e){ |
|
| 66 | 66 | $this->handleException($emitter, $e); |
| 67 | - } finally { |
|
| 67 | + }finally{ |
|
| 68 | 68 | $this->finalizer->finalize(false); |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
| 87 | 87 | |
| 88 | - try { |
|
| 88 | + try{ |
|
| 89 | 89 | /** @var SnapshotInterface $snapshot */ |
| 90 | 90 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 91 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 91 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 92 | 92 | // nothing to report |
| 93 | 93 | } |
| 94 | 94 | |
@@ -59,12 +59,17 @@ discard block |
||
| 59 | 59 | $http = $this->container->get(HttpCore::class); |
| 60 | 60 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
| 61 | 61 | |
| 62 | - try { |
|
| 62 | + try |
|
| 63 | + { |
|
| 63 | 64 | $response = $http->handle($this->initRequest()); |
| 64 | 65 | $emitter->emit($response); |
| 65 | - } catch (\Throwable $e) { |
|
| 66 | + } |
|
| 67 | + catch (\Throwable $e) |
|
| 68 | + { |
|
| 66 | 69 | $this->handleException($emitter, $e); |
| 67 | - } finally { |
|
| 70 | + } |
|
| 71 | + finally |
|
| 72 | + { |
|
| 68 | 73 | $this->finalizer->finalize(false); |
| 69 | 74 | } |
| 70 | 75 | } |
@@ -85,10 +90,13 @@ discard block |
||
| 85 | 90 | { |
| 86 | 91 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
| 87 | 92 | |
| 88 | - try { |
|
| 93 | + try |
|
| 94 | + { |
|
| 89 | 95 | /** @var SnapshotInterface $snapshot */ |
| 90 | 96 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 91 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 97 | + } |
|
| 98 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 99 | + { |
|
| 92 | 100 | // nothing to report |
| 93 | 101 | } |
| 94 | 102 | |
@@ -38,15 +38,15 @@ |
||
| 38 | 38 | public function getServices(): array |
| 39 | 39 | { |
| 40 | 40 | $result = []; |
| 41 | - foreach ($this->classes->getClasses(ServiceInterface::class) as $service) { |
|
| 42 | - if (!$service->isInstantiable()) { |
|
| 41 | + foreach ($this->classes->getClasses(ServiceInterface::class) as $service){ |
|
| 42 | + if (!$service->isInstantiable()){ |
|
| 43 | 43 | continue; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $instance = $this->container->get($service->getName()); |
| 47 | 47 | |
| 48 | - foreach ($service->getInterfaces() as $interface) { |
|
| 49 | - if ($interface->isSubclassOf(ServiceInterface::class)) { |
|
| 48 | + foreach ($service->getInterfaces() as $interface){ |
|
| 49 | + if ($interface->isSubclassOf(ServiceInterface::class)){ |
|
| 50 | 50 | $result[$interface->getName()] = $instance; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -38,15 +38,19 @@ |
||
| 38 | 38 | public function getServices(): array |
| 39 | 39 | { |
| 40 | 40 | $result = []; |
| 41 | - foreach ($this->classes->getClasses(ServiceInterface::class) as $service) { |
|
| 42 | - if (!$service->isInstantiable()) { |
|
| 41 | + foreach ($this->classes->getClasses(ServiceInterface::class) as $service) |
|
| 42 | + { |
|
| 43 | + if (!$service->isInstantiable()) |
|
| 44 | + { |
|
| 43 | 45 | continue; |
| 44 | 46 | } |
| 45 | 47 | |
| 46 | 48 | $instance = $this->container->get($service->getName()); |
| 47 | 49 | |
| 48 | - foreach ($service->getInterfaces() as $interface) { |
|
| 49 | - if ($interface->isSubclassOf(ServiceInterface::class)) { |
|
| 50 | + foreach ($service->getInterfaces() as $interface) |
|
| 51 | + { |
|
| 52 | + if ($interface->isSubclassOf(ServiceInterface::class)) |
|
| 53 | + { |
|
| 50 | 54 | $result[$interface->getName()] = $instance; |
| 51 | 55 | } |
| 52 | 56 | } |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | escapeshellarg($protoFile) |
| 56 | 56 | ), $output); |
| 57 | 57 | |
| 58 | - if (isset($output[0]) && trim($output[0]) !== '') { |
|
| 58 | + if (isset($output[0]) && trim($output[0]) !== ''){ |
|
| 59 | 59 | $this->files->deleteDirectory($tmpDir); |
| 60 | 60 | throw new CompileException(trim($output[0], ' ,')); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // copying files (using relative path and namespace) |
| 64 | 64 | $result = []; |
| 65 | - foreach ($this->files->getFiles($tmpDir) as $file) { |
|
| 65 | + foreach ($this->files->getFiles($tmpDir) as $file){ |
|
| 66 | 66 | $result[] = $this->copy($tmpDir, $file); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | private function copy(string $tmpDir, string $file): string |
| 80 | 80 | { |
| 81 | 81 | $source = ltrim($this->files->relativePath($file, $tmpDir), '\\/'); |
| 82 | - if (strpos($source, $this->baseNamespace) === 0) { |
|
| 82 | + if (strpos($source, $this->baseNamespace) === 0){ |
|
| 83 | 83 | $source = ltrim(substr($source, strlen($this->baseNamespace)), '\\/'); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $target = $this->files->normalizePath($this->basePath . '/' . $source); |
|
| 86 | + $target = $this->files->normalizePath($this->basePath.'/'.$source); |
|
| 87 | 87 | |
| 88 | 88 | $this->files->ensureDirectory(dirname($target)); |
| 89 | 89 | $this->files->copy($file, $target); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | private function tmpDir(): string |
| 98 | 98 | { |
| 99 | - $directory = sys_get_temp_dir() . '/' . spl_object_hash($this); |
|
| 99 | + $directory = sys_get_temp_dir().'/'.spl_object_hash($this); |
|
| 100 | 100 | $this->files->ensureDirectory($directory); |
| 101 | 101 | |
| 102 | 102 | return $this->files->normalizePath($directory, true); |
@@ -55,14 +55,16 @@ discard block |
||
| 55 | 55 | escapeshellarg($protoFile) |
| 56 | 56 | ), $output); |
| 57 | 57 | |
| 58 | - if (isset($output[0]) && trim($output[0]) !== '') { |
|
| 58 | + if (isset($output[0]) && trim($output[0]) !== '') |
|
| 59 | + { |
|
| 59 | 60 | $this->files->deleteDirectory($tmpDir); |
| 60 | 61 | throw new CompileException(trim($output[0], ' ,')); |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | // copying files (using relative path and namespace) |
| 64 | 65 | $result = []; |
| 65 | - foreach ($this->files->getFiles($tmpDir) as $file) { |
|
| 66 | + foreach ($this->files->getFiles($tmpDir) as $file) |
|
| 67 | + { |
|
| 66 | 68 | $result[] = $this->copy($tmpDir, $file); |
| 67 | 69 | } |
| 68 | 70 | |
@@ -79,7 +81,8 @@ discard block |
||
| 79 | 81 | private function copy(string $tmpDir, string $file): string |
| 80 | 82 | { |
| 81 | 83 | $source = ltrim($this->files->relativePath($file, $tmpDir), '\\/'); |
| 82 | - if (strpos($source, $this->baseNamespace) === 0) { |
|
| 84 | + if (strpos($source, $this->baseNamespace) === 0) |
|
| 85 | + { |
|
| 83 | 86 | $source = ltrim(substr($source, strlen($this->baseNamespace)), '\\/'); |
| 84 | 87 | } |
| 85 | 88 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | EnvironmentInterface $env, |
| 38 | 38 | FinalizerInterface $finalizer, |
| 39 | 39 | ContainerInterface $container |
| 40 | - ) { |
|
| 40 | + ){ |
|
| 41 | 41 | $this->env = $env; |
| 42 | 42 | $this->finalizer = $finalizer; |
| 43 | 43 | $this->container = $container; |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | $worker = $this->container->get(Worker::class); |
| 66 | 66 | $locator = $this->container->get(LocatorInterface::class); |
| 67 | 67 | |
| 68 | - foreach ($locator->getServices() as $interface => $service) { |
|
| 68 | + foreach ($locator->getServices() as $interface => $service){ |
|
| 69 | 69 | $server->registerService($interface, $service); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $server->serve($worker, function (\Throwable $e = null) { |
|
| 73 | - if ($e !== null) { |
|
| 72 | + $server->serve($worker, function (\Throwable $e = null){ |
|
| 73 | + if ($e !== null){ |
|
| 74 | 74 | $this->handleException($e); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function handleException(\Throwable $e) |
| 85 | 85 | { |
| 86 | - try { |
|
| 86 | + try{ |
|
| 87 | 87 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 88 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 88 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 89 | 89 | // no need to notify when unable to register an exception |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -65,12 +65,15 @@ discard block |
||
| 65 | 65 | $worker = $this->container->get(Worker::class); |
| 66 | 66 | $locator = $this->container->get(LocatorInterface::class); |
| 67 | 67 | |
| 68 | - foreach ($locator->getServices() as $interface => $service) { |
|
| 68 | + foreach ($locator->getServices() as $interface => $service) |
|
| 69 | + { |
|
| 69 | 70 | $server->registerService($interface, $service); |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | - $server->serve($worker, function (\Throwable $e = null) { |
|
| 73 | - if ($e !== null) { |
|
| 73 | + $server->serve($worker, function (\Throwable $e = null) |
|
| 74 | + { |
|
| 75 | + if ($e !== null) |
|
| 76 | + { |
|
| 74 | 77 | $this->handleException($e); |
| 75 | 78 | } |
| 76 | 79 | |
@@ -83,9 +86,12 @@ discard block |
||
| 83 | 86 | */ |
| 84 | 87 | protected function handleException(\Throwable $e) |
| 85 | 88 | { |
| 86 | - try { |
|
| 89 | + try |
|
| 90 | + { |
|
| 87 | 91 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 88 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 92 | + } |
|
| 93 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 94 | + { |
|
| 89 | 95 | // no need to notify when unable to register an exception |
| 90 | 96 | } |
| 91 | 97 | } |
@@ -43,19 +43,19 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $runtimeDirectory = $this->dirs->get('runtime'); |
| 45 | 45 | |
| 46 | - if (!$this->files->exists($runtimeDirectory)) { |
|
| 46 | + if (!$this->files->exists($runtimeDirectory)){ |
|
| 47 | 47 | $this->files->ensureDirectory($runtimeDirectory); |
| 48 | 48 | $output->writeln("<comment>created</comment>"); |
| 49 | 49 | return; |
| 50 | - } else { |
|
| 50 | + }else{ |
|
| 51 | 51 | $output->writeln("<info>exists</info>"); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - foreach ($this->files->getFiles($runtimeDirectory) as $filename) { |
|
| 55 | - try { |
|
| 54 | + foreach ($this->files->getFiles($runtimeDirectory) as $filename){ |
|
| 55 | + try{ |
|
| 56 | 56 | $this->files->setPermissions($filename, FilesInterface::RUNTIME); |
| 57 | 57 | $this->files->setPermissions(dirname($filename), FilesInterface::RUNTIME); |
| 58 | - } catch (\Throwable $e) { |
|
| 58 | + }catch (\Throwable $e){ |
|
| 59 | 59 | // @codeCoverageIgnoreStart |
| 60 | 60 | $output->writeln(sprintf( |
| 61 | 61 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | // @codeCoverageIgnoreEnd |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ($output->isVerbose()) { |
|
| 69 | + if ($output->isVerbose()){ |
|
| 70 | 70 | $output->writeln(sprintf( |
| 71 | 71 | "<fg=green>[updated]</fg=green> `%s`", |
| 72 | 72 | $this->files->relativePath($filename, $runtimeDirectory) |
@@ -43,19 +43,26 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $runtimeDirectory = $this->dirs->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 | // @codeCoverageIgnoreStart |
| 60 | 67 | $output->writeln(sprintf( |
| 61 | 68 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>", |
@@ -66,7 +73,8 @@ discard block |
||
| 66 | 73 | // @codeCoverageIgnoreEnd |
| 67 | 74 | } |
| 68 | 75 | |
| 69 | - if ($output->isVerbose()) { |
|
| 76 | + if ($output->isVerbose()) |
|
| 77 | + { |
|
| 70 | 78 | $output->writeln(sprintf( |
| 71 | 79 | "<fg=green>[updated]</fg=green> `%s`", |
| 72 | 80 | $this->files->relativePath($filename, $runtimeDirectory) |