@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
| 41 | 41 | $response = $response->withAddedHeader($header, $value); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -37,7 +37,8 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
| 41 | + { |
|
| 41 | 42 | $response = $response->withAddedHeader($header, $value); |
| 42 | 43 | } |
| 43 | 44 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | FinalizerInterface $finalizer, |
| 47 | 47 | ContainerInterface $container, |
| 48 | 48 | FactoryInterface $factory |
| 49 | - ) { |
|
| 49 | + ){ |
|
| 50 | 50 | $this->env = $env; |
| 51 | 51 | $this->finalizer = $finalizer; |
| 52 | 52 | $this->container = $container; |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | /** @var Http $http */ |
| 72 | 72 | $http = $this->container->get(Http::class); |
| 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 { |
|
| 78 | + }finally{ |
|
| 79 | 79 | $this->finalizer->finalize(false); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
| 91 | 91 | |
| 92 | - try { |
|
| 92 | + try{ |
|
| 93 | 93 | /** @var SnapshotInterface $snapshot */ |
| 94 | 94 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
| 95 | 95 | error_log($snapshot->getMessage()); |
| 96 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 96 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 97 | 97 | error_log((string)$e); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -70,12 +70,18 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | /** @var Http $http */ |
| 72 | 72 | $http = $this->container->get(Http::class); |
| 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 { |
|
| 82 | + } |
|
| 83 | + finally |
|
| 84 | + { |
|
| 79 | 85 | $this->finalizer->finalize(false); |
| 80 | 86 | } |
| 81 | 87 | } |
@@ -89,11 +95,14 @@ discard block |
||
| 89 | 95 | { |
| 90 | 96 | $handler = new HtmlHandler(HtmlHandler::INVERTED); |
| 91 | 97 | |
| 92 | - try { |
|
| 98 | + try |
|
| 99 | + { |
|
| 93 | 100 | /** @var SnapshotInterface $snapshot */ |
| 94 | 101 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
| 95 | 102 | error_log($snapshot->getMessage()); |
| 96 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 103 | + } |
|
| 104 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 105 | + { |
|
| 97 | 106 | error_log((string)$e); |
| 98 | 107 | } |
| 99 | 108 | |
@@ -50,13 +50,13 @@ |
||
| 50 | 50 | CookiesBootloader $cookies, |
| 51 | 51 | HttpBootloader $http, |
| 52 | 52 | DirectoriesInterface $directories |
| 53 | - ) { |
|
| 53 | + ){ |
|
| 54 | 54 | $config->setDefaults('session', [ |
| 55 | 55 | 'lifetime' => 86400, |
| 56 | 56 | 'cookie' => 'sid', |
| 57 | 57 | 'secure' => false, |
| 58 | 58 | 'handler' => new Autowire(FileHandler::class, [ |
| 59 | - 'directory' => $directories->get('runtime') . 'session', |
|
| 59 | + 'directory' => $directories->get('runtime').'session', |
|
| 60 | 60 | 'lifetime' => 86400 |
| 61 | 61 | ] |
| 62 | 62 | ) |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | |
| 67 | 67 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 68 | 68 | |
| 69 | - if (class_exists(PSR7Client::class)) { |
|
| 69 | + if (class_exists(PSR7Client::class)){ |
|
| 70 | 70 | $kernel->addDispatcher($factory->make(RrDispacher::class)); |
| 71 | 71 | } |
| 72 | 72 | } |
@@ -66,7 +66,8 @@ |
||
| 66 | 66 | |
| 67 | 67 | $kernel->addDispatcher($factory->make(SapiDispatcher::class)); |
| 68 | 68 | |
| 69 | - if (class_exists(PSR7Client::class)) { |
|
| 69 | + if (class_exists(PSR7Client::class)) |
|
| 70 | + { |
|
| 70 | 71 | $kernel->addDispatcher($factory->make(RrDispacher::class)); |
| 71 | 72 | } |
| 72 | 73 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function boot(SchemaInterface $schema = null) |
| 76 | 76 | { |
| 77 | - if (!is_null($schema)) { |
|
| 77 | + if (!is_null($schema)){ |
|
| 78 | 78 | $this->bootRepositories($schema); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function bootRepositories(SchemaInterface $schema) |
| 86 | 86 | { |
| 87 | - foreach ($schema->getRoles() as $role) { |
|
| 87 | + foreach ($schema->getRoles() as $role){ |
|
| 88 | 88 | $repository = $schema->define($role, Schema::REPOSITORY); |
| 89 | - if ($repository === Repository::class || $repository === null) { |
|
| 89 | + if ($repository === Repository::class || $repository === null){ |
|
| 90 | 90 | // default repository can not be wired |
| 91 | 91 | continue; |
| 92 | 92 | } |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | public function getGenerators(): array |
| 126 | 126 | { |
| 127 | 127 | $result = []; |
| 128 | - foreach ($this->generators as $group) { |
|
| 129 | - foreach ($group as $generator) { |
|
| 130 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 128 | + foreach ($this->generators as $group){ |
|
| 129 | + foreach ($group as $generator){ |
|
| 130 | + if (is_object($generator) && !$generator instanceof Container\Autowire){ |
|
| 131 | 131 | $result[] = $generator; |
| 132 | - } else { |
|
| 132 | + }else{ |
|
| 133 | 133 | $result[] = $this->container->get($generator); |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 146 | 146 | { |
| 147 | 147 | $schema = $memory->loadData('cycle'); |
| 148 | - if (is_null($schema)) { |
|
| 148 | + if (is_null($schema)){ |
|
| 149 | 149 | return null; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -74,7 +74,8 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function boot(SchemaInterface $schema = null) |
| 76 | 76 | { |
| 77 | - if (!is_null($schema)) { |
|
| 77 | + if (!is_null($schema)) |
|
| 78 | + { |
|
| 78 | 79 | $this->bootRepositories($schema); |
| 79 | 80 | } |
| 80 | 81 | } |
@@ -84,9 +85,11 @@ discard block |
||
| 84 | 85 | */ |
| 85 | 86 | public function bootRepositories(SchemaInterface $schema) |
| 86 | 87 | { |
| 87 | - foreach ($schema->getRoles() as $role) { |
|
| 88 | + foreach ($schema->getRoles() as $role) |
|
| 89 | + { |
|
| 88 | 90 | $repository = $schema->define($role, Schema::REPOSITORY); |
| 89 | - if ($repository === Repository::class || $repository === null) { |
|
| 91 | + if ($repository === Repository::class || $repository === null) |
|
| 92 | + { |
|
| 90 | 93 | // default repository can not be wired |
| 91 | 94 | continue; |
| 92 | 95 | } |
@@ -125,11 +128,16 @@ discard block |
||
| 125 | 128 | public function getGenerators(): array |
| 126 | 129 | { |
| 127 | 130 | $result = []; |
| 128 | - foreach ($this->generators as $group) { |
|
| 129 | - foreach ($group as $generator) { |
|
| 130 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
| 131 | + foreach ($this->generators as $group) |
|
| 132 | + { |
|
| 133 | + foreach ($group as $generator) |
|
| 134 | + { |
|
| 135 | + if (is_object($generator) && !$generator instanceof Container\Autowire) |
|
| 136 | + { |
|
| 131 | 137 | $result[] = $generator; |
| 132 | - } else { |
|
| 138 | + } |
|
| 139 | + else |
|
| 140 | + { |
|
| 133 | 141 | $result[] = $this->container->get($generator); |
| 134 | 142 | } |
| 135 | 143 | } |
@@ -145,7 +153,8 @@ discard block |
||
| 145 | 153 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
| 146 | 154 | { |
| 147 | 155 | $schema = $memory->loadData('cycle'); |
| 148 | - if (is_null($schema)) { |
|
| 156 | + if (is_null($schema)) |
|
| 157 | + { |
|
| 149 | 158 | return null; |
| 150 | 159 | } |
| 151 | 160 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | EnvironmentInterface $env, |
| 45 | 45 | FinalizerInterface $finalizer, |
| 46 | 46 | ContainerInterface $container |
| 47 | - ) { |
|
| 47 | + ){ |
|
| 48 | 48 | $this->env = $env; |
| 49 | 49 | $this->finalizer = $finalizer; |
| 50 | 50 | $this->container = $container; |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | /** @var Console $console */ |
| 74 | 74 | $console = $this->container->get(Console::class); |
| 75 | 75 | |
| 76 | - try { |
|
| 76 | + try{ |
|
| 77 | 77 | $console->start($input ?? new ArgvInput(), $output); |
| 78 | - } catch (\Throwable $e) { |
|
| 78 | + }catch (\Throwable $e){ |
|
| 79 | 79 | $this->handleException($e, $output); |
| 80 | - } finally { |
|
| 80 | + }finally{ |
|
| 81 | 81 | $listener->disable(); |
| 82 | 82 | $this->finalizer->finalize(false); |
| 83 | 83 | } |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | protected function handleException(\Throwable $e, OutputInterface $output) |
| 91 | 91 | { |
| 92 | - try { |
|
| 92 | + try{ |
|
| 93 | 93 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 94 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 94 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 95 | 95 | // no need to notify when unable to register an exception |
| 96 | 96 | } |
| 97 | 97 | |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | private function mapVerbosity(OutputInterface $output): int |
| 108 | 108 | { |
| 109 | - if ($output->isDebug()) { |
|
| 109 | + if ($output->isDebug()){ |
|
| 110 | 110 | return ConsoleHandler::VERBOSITY_DEBUG; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ($output->isVeryVerbose()) { |
|
| 113 | + if ($output->isVeryVerbose()){ |
|
| 114 | 114 | return ConsoleHandler::VERBOSITY_VERBOSE; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -73,11 +73,16 @@ discard block |
||
| 73 | 73 | /** @var Console $console */ |
| 74 | 74 | $console = $this->container->get(Console::class); |
| 75 | 75 | |
| 76 | - try { |
|
| 76 | + try |
|
| 77 | + { |
|
| 77 | 78 | $console->start($input ?? new ArgvInput(), $output); |
| 78 | - } catch (\Throwable $e) { |
|
| 79 | + } |
|
| 80 | + catch (\Throwable $e) |
|
| 81 | + { |
|
| 79 | 82 | $this->handleException($e, $output); |
| 80 | - } finally { |
|
| 83 | + } |
|
| 84 | + finally |
|
| 85 | + { |
|
| 81 | 86 | $listener->disable(); |
| 82 | 87 | $this->finalizer->finalize(false); |
| 83 | 88 | } |
@@ -89,9 +94,12 @@ discard block |
||
| 89 | 94 | */ |
| 90 | 95 | protected function handleException(\Throwable $e, OutputInterface $output) |
| 91 | 96 | { |
| 92 | - try { |
|
| 97 | + try |
|
| 98 | + { |
|
| 93 | 99 | $this->container->get(SnapshotterInterface::class)->register($e); |
| 94 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
| 100 | + } |
|
| 101 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
| 102 | + { |
|
| 95 | 103 | // no need to notify when unable to register an exception |
| 96 | 104 | } |
| 97 | 105 | |
@@ -106,11 +114,13 @@ discard block |
||
| 106 | 114 | */ |
| 107 | 115 | private function mapVerbosity(OutputInterface $output): int |
| 108 | 116 | { |
| 109 | - if ($output->isDebug()) { |
|
| 117 | + if ($output->isDebug()) |
|
| 118 | + { |
|
| 110 | 119 | return ConsoleHandler::VERBOSITY_DEBUG; |
| 111 | 120 | } |
| 112 | 121 | |
| 113 | - if ($output->isVeryVerbose()) { |
|
| 122 | + if ($output->isVeryVerbose()) |
|
| 123 | + { |
|
| 114 | 124 | return ConsoleHandler::VERBOSITY_VERBOSE; |
| 115 | 125 | } |
| 116 | 126 | |
@@ -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,17 +146,17 @@ 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 | $fkColumns = join(', ', $fk->getColumns()); |
| 151 | 151 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fkColumns}</fg=yellow>"); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
| 154 | + foreach ($cmp->droppedForeignKeys() as $fk){ |
|
| 155 | 155 | $fkColumns = join(', ', $fk->getColumns()); |
| 156 | 156 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
| 159 | + foreach ($cmp->alteredForeignKeys() as $fk){ |
|
| 160 | 160 | $fk = $fk[0]; |
| 161 | 161 | $fkColumns = join(', ', $fk->getColumns()); |
| 162 | 162 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
@@ -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,17 +162,20 @@ 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 | $fkColumns = join(', ', $fk->getColumns()); |
| 151 | 168 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fkColumns}</fg=yellow>"); |
| 152 | 169 | } |
| 153 | 170 | |
| 154 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
| 171 | + foreach ($cmp->droppedForeignKeys() as $fk) |
|
| 172 | + { |
|
| 155 | 173 | $fkColumns = join(', ', $fk->getColumns()); |
| 156 | 174 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
| 157 | 175 | } |
| 158 | 176 | |
| 159 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
| 177 | + foreach ($cmp->alteredForeignKeys() as $fk) |
|
| 178 | + { |
|
| 160 | 179 | $fk = $fk[0]; |
| 161 | 180 | $fkColumns = join(', ', $fk->getColumns()); |
| 162 | 181 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
@@ -40,21 +40,21 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
| 42 | 42 | |
| 43 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 43 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
| 44 | 44 | throw new BootException( |
| 45 | 45 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 46 | 46 | ); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 49 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
| 50 | 50 | throw new BootException( |
| 51 | 51 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 52 | 52 | ); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ($parts[1] == 'unix') { |
|
| 55 | + if ($parts[1] == 'unix'){ |
|
| 56 | 56 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 57 | - } else { |
|
| 57 | + }else{ |
|
| 58 | 58 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -69,25 +69,25 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $conn = $env->get('RR_RELAY', static::WORKER_DEFAULT); |
| 71 | 71 | |
| 72 | - if ($conn === 'pipes' || empty($conn)) { |
|
| 72 | + if ($conn === 'pipes' || empty($conn)){ |
|
| 73 | 73 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 76 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
| 77 | 77 | throw new BootException( |
| 78 | 78 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 79 | 79 | ); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 82 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
| 83 | 83 | throw new BootException( |
| 84 | 84 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ($parts[1] == 'unix') { |
|
| 88 | + if ($parts[1] == 'unix'){ |
|
| 89 | 89 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 90 | - } else { |
|
| 90 | + }else{ |
|
| 91 | 91 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -40,21 +40,26 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
| 42 | 42 | |
| 43 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 43 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
| 44 | + { |
|
| 44 | 45 | throw new BootException( |
| 45 | 46 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 46 | 47 | ); |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 50 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
| 51 | + { |
|
| 50 | 52 | throw new BootException( |
| 51 | 53 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
| 52 | 54 | ); |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | - if ($parts[1] == 'unix') { |
|
| 57 | + if ($parts[1] == 'unix') |
|
| 58 | + { |
|
| 56 | 59 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 57 | - } else { |
|
| 60 | + } |
|
| 61 | + else |
|
| 62 | + { |
|
| 58 | 63 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 59 | 64 | } |
| 60 | 65 | |
@@ -69,25 +74,31 @@ discard block |
||
| 69 | 74 | { |
| 70 | 75 | $conn = $env->get('RR_RELAY', static::WORKER_DEFAULT); |
| 71 | 76 | |
| 72 | - if ($conn === 'pipes' || empty($conn)) { |
|
| 77 | + if ($conn === 'pipes' || empty($conn)) |
|
| 78 | + { |
|
| 73 | 79 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
| 74 | 80 | } |
| 75 | 81 | |
| 76 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
| 82 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
| 83 | + { |
|
| 77 | 84 | throw new BootException( |
| 78 | 85 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 79 | 86 | ); |
| 80 | 87 | } |
| 81 | 88 | |
| 82 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
| 89 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
| 90 | + { |
|
| 83 | 91 | throw new BootException( |
| 84 | 92 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
| 85 | 93 | ); |
| 86 | 94 | } |
| 87 | 95 | |
| 88 | - if ($parts[1] == 'unix') { |
|
| 96 | + if ($parts[1] == 'unix') |
|
| 97 | + { |
|
| 89 | 98 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
| 90 | - } else { |
|
| 99 | + } |
|
| 100 | + else |
|
| 101 | + { |
|
| 91 | 102 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
| 92 | 103 | } |
| 93 | 104 | |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function perform(ViewsConfig $config, FilesInterface $files) |
| 29 | 29 | { |
| 30 | - if (!$files->exists($config->getCacheDirectory())) { |
|
| 30 | + if (!$files->exists($config->getCacheDirectory())){ |
|
| 31 | 31 | $this->writeln("Cache directory is missing, no cache to be cleaned."); |
| 32 | 32 | |
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ($this->isVerbose()) { |
|
| 36 | + if ($this->isVerbose()){ |
|
| 37 | 37 | $this->writeln("<info>Cleaning view cache:</info>"); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - foreach ($files->getFiles($config->getCacheDirectory()) as $filename) { |
|
| 41 | - try { |
|
| 40 | + foreach ($files->getFiles($config->getCacheDirectory()) as $filename){ |
|
| 41 | + try{ |
|
| 42 | 42 | $files->delete($filename); |
| 43 | - } catch (\Throwable $e) { |
|
| 43 | + }catch (\Throwable $e){ |
|
| 44 | 44 | // @codeCoverageIgnoreStart |
| 45 | 45 | $this->sprintf("<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
| 46 | 46 | $files->relativePath($filename, $config->getCacheDirectory()), |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | // @codeCoverageIgnoreEnd |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ($this->isVerbose()) { |
|
| 55 | + if ($this->isVerbose()){ |
|
| 56 | 56 | $this->sprintf( |
| 57 | 57 | "<fg=green>[deleted]</fg=green> `%s`\n", |
| 58 | 58 | $files->relativePath($filename, $config->getCacheDirectory()) |
@@ -27,20 +27,26 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function perform(ViewsConfig $config, FilesInterface $files) |
| 29 | 29 | { |
| 30 | - if (!$files->exists($config->getCacheDirectory())) { |
|
| 30 | + if (!$files->exists($config->getCacheDirectory())) |
|
| 31 | + { |
|
| 31 | 32 | $this->writeln("Cache directory is missing, no cache to be cleaned."); |
| 32 | 33 | |
| 33 | 34 | return; |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | - if ($this->isVerbose()) { |
|
| 37 | + if ($this->isVerbose()) |
|
| 38 | + { |
|
| 37 | 39 | $this->writeln("<info>Cleaning view cache:</info>"); |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | - foreach ($files->getFiles($config->getCacheDirectory()) as $filename) { |
|
| 41 | - try { |
|
| 42 | + foreach ($files->getFiles($config->getCacheDirectory()) as $filename) |
|
| 43 | + { |
|
| 44 | + try |
|
| 45 | + { |
|
| 42 | 46 | $files->delete($filename); |
| 43 | - } catch (\Throwable $e) { |
|
| 47 | + } |
|
| 48 | + catch (\Throwable $e) |
|
| 49 | + { |
|
| 44 | 50 | // @codeCoverageIgnoreStart |
| 45 | 51 | $this->sprintf("<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
| 46 | 52 | $files->relativePath($filename, $config->getCacheDirectory()), |
@@ -52,7 +58,8 @@ discard block |
||
| 52 | 58 | // @codeCoverageIgnoreEnd |
| 53 | 59 | } |
| 54 | 60 | |
| 55 | - if ($this->isVerbose()) { |
|
| 61 | + if ($this->isVerbose()) |
|
| 62 | + { |
|
| 56 | 63 | $this->sprintf( |
| 57 | 64 | "<fg=green>[deleted]</fg=green> `%s`\n", |
| 58 | 65 | $files->relativePath($filename, $config->getCacheDirectory()) |