@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | Migrator $migrator, |
57 | 57 | Console $console |
58 | 58 | ): void { |
59 | - if (!$this->verifyConfigured()) { |
|
59 | + if (!$this->verifyConfigured()){ |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | - foreach ($migrator->getMigrations() as $migration) { |
|
64 | - if ($migration->getState()->getStatus() !== State::STATUS_EXECUTED) { |
|
63 | + foreach ($migrator->getMigrations() as $migration){ |
|
64 | + if ($migration->getState()->getStatus() !== State::STATUS_EXECUTED){ |
|
65 | 65 | $this->writeln('<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>'); |
66 | 66 | return; |
67 | 67 | } |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | |
77 | 77 | $memory->saveData('cycle', $schema); |
78 | 78 | |
79 | - if ($show->hasChanges()) { |
|
79 | + if ($show->hasChanges()){ |
|
80 | 80 | (new Compiler())->compile($registry, [$migrations]); |
81 | 81 | |
82 | - if ($this->option('run')) { |
|
82 | + if ($this->option('run')){ |
|
83 | 83 | $console->run('migrate', [], $this->output); |
84 | 84 | } |
85 | 85 | } |
@@ -56,12 +56,15 @@ discard block |
||
56 | 56 | Migrator $migrator, |
57 | 57 | Console $console |
58 | 58 | ): void { |
59 | - if (!$this->verifyConfigured()) { |
|
59 | + if (!$this->verifyConfigured()) |
|
60 | + { |
|
60 | 61 | return; |
61 | 62 | } |
62 | 63 | |
63 | - foreach ($migrator->getMigrations() as $migration) { |
|
64 | - if ($migration->getState()->getStatus() !== State::STATUS_EXECUTED) { |
|
64 | + foreach ($migrator->getMigrations() as $migration) |
|
65 | + { |
|
66 | + if ($migration->getState()->getStatus() !== State::STATUS_EXECUTED) |
|
67 | + { |
|
65 | 68 | $this->writeln('<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>'); |
66 | 69 | return; |
67 | 70 | } |
@@ -76,10 +79,12 @@ discard block |
||
76 | 79 | |
77 | 80 | $memory->saveData('cycle', $schema); |
78 | 81 | |
79 | - if ($show->hasChanges()) { |
|
82 | + if ($show->hasChanges()) |
|
83 | + { |
|
80 | 84 | (new Compiler())->compile($registry, [$migrations]); |
81 | 85 | |
82 | - if ($this->option('run')) { |
|
86 | + if ($this->option('run')) |
|
87 | + { |
|
83 | 88 | $console->run('migrate', [], $this->output); |
84 | 89 | } |
85 | 90 | } |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | $this->output->writeln('<info>Detecting schema changes:</info>'); |
42 | 42 | |
43 | 43 | $this->changes = []; |
44 | - foreach ($registry->getIterator() as $e) { |
|
45 | - if ($registry->hasTable($e)) { |
|
44 | + foreach ($registry->getIterator() as $e){ |
|
45 | + if ($registry->hasTable($e)){ |
|
46 | 46 | $table = $registry->getTableSchema($e); |
47 | 47 | |
48 | - if ($table->getComparator()->hasChanges()) { |
|
48 | + if ($table->getComparator()->hasChanges()){ |
|
49 | 49 | $this->changes[] = [ |
50 | 50 | 'database' => $registry->getDatabase($e), |
51 | 51 | 'table' => $registry->getTable($e), |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | - if ($this->changes === []) { |
|
58 | + if ($this->changes === []){ |
|
59 | 59 | $this->output->writeln('<fg=yellow>no database changes has been detected</fg=yellow>'); |
60 | 60 | |
61 | 61 | return $registry; |
62 | 62 | } |
63 | 63 | |
64 | - foreach ($this->changes as $change) { |
|
64 | + foreach ($this->changes as $change){ |
|
65 | 65 | $this->output->write(sprintf('• <fg=cyan>%s.%s</fg=cyan>', $change['database'], $change['table'])); |
66 | 66 | $this->describeChanges($change['schema']); |
67 | 67 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | protected function describeChanges(AbstractTable $table): void |
84 | 84 | { |
85 | - if (!$this->output->isVerbose()) { |
|
85 | + if (!$this->output->isVerbose()){ |
|
86 | 86 | $this->output->writeln(sprintf( |
87 | 87 | ': <fg=green>%s</fg=green> change(s) detected', |
88 | 88 | $this->numChanges($table) |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | $this->output->write("\n"); |
94 | 94 | |
95 | 95 | |
96 | - if (!$table->exists()) { |
|
96 | + if (!$table->exists()){ |
|
97 | 97 | $this->output->writeln(' - create table'); |
98 | 98 | } |
99 | 99 | |
100 | - if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
|
100 | + if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED){ |
|
101 | 101 | $this->output->writeln(' - drop table'); |
102 | 102 | return; |
103 | 103 | } |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function describeColumns(Comparator $cmp): void |
116 | 116 | { |
117 | - foreach ($cmp->addedColumns() as $column) { |
|
117 | + foreach ($cmp->addedColumns() as $column){ |
|
118 | 118 | $this->output->writeln(" - add column <fg=yellow>{$column->getName()}</fg=yellow>"); |
119 | 119 | } |
120 | 120 | |
121 | - foreach ($cmp->droppedColumns() as $column) { |
|
121 | + foreach ($cmp->droppedColumns() as $column){ |
|
122 | 122 | $this->output->writeln(" - drop column <fg=yellow>{$column->getName()}</fg=yellow>"); |
123 | 123 | } |
124 | 124 | |
125 | - foreach ($cmp->alteredColumns() as $column) { |
|
125 | + foreach ($cmp->alteredColumns() as $column){ |
|
126 | 126 | $column = $column[0]; |
127 | 127 | $this->output->writeln(" - alter column <fg=yellow>{$column->getName()}</fg=yellow>"); |
128 | 128 | } |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function describeIndexes(Comparator $cmp): void |
135 | 135 | { |
136 | - foreach ($cmp->addedIndexes() as $index) { |
|
136 | + foreach ($cmp->addedIndexes() as $index){ |
|
137 | 137 | $index = join(', ', $index->getColumns()); |
138 | 138 | $this->output->writeln(" - add index on <fg=yellow>[{$index}]</fg=yellow>"); |
139 | 139 | } |
140 | 140 | |
141 | - foreach ($cmp->droppedIndexes() as $index) { |
|
141 | + foreach ($cmp->droppedIndexes() as $index){ |
|
142 | 142 | $index = join(', ', $index->getColumns()); |
143 | 143 | $this->output->writeln(" - drop index on <fg=yellow>[{$index}]</fg=yellow>"); |
144 | 144 | } |
145 | 145 | |
146 | - foreach ($cmp->alteredIndexes() as $index) { |
|
146 | + foreach ($cmp->alteredIndexes() as $index){ |
|
147 | 147 | $index = $index[0]; |
148 | 148 | $index = join(', ', $index->getColumns()); |
149 | 149 | $this->output->writeln(" - alter index on <fg=yellow>[{$index}]</fg=yellow>"); |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function describeFKs(Comparator $cmp): void |
157 | 157 | { |
158 | - foreach ($cmp->addedForeignKeys() as $fk) { |
|
158 | + foreach ($cmp->addedForeignKeys() as $fk){ |
|
159 | 159 | $fkColumns = join(', ', $fk->getColumns()); |
160 | 160 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fkColumns}</fg=yellow>"); |
161 | 161 | } |
162 | 162 | |
163 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
163 | + foreach ($cmp->droppedForeignKeys() as $fk){ |
|
164 | 164 | $fkColumns = join(', ', $fk->getColumns()); |
165 | 165 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
166 | 166 | } |
167 | 167 | |
168 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
168 | + foreach ($cmp->alteredForeignKeys() as $fk){ |
|
169 | 169 | $fk = $fk[0]; |
170 | 170 | $fkColumns = join(', ', $fk->getColumns()); |
171 | 171 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
@@ -41,11 +41,14 @@ discard block |
||
41 | 41 | $this->output->writeln('<info>Detecting schema changes:</info>'); |
42 | 42 | |
43 | 43 | $this->changes = []; |
44 | - foreach ($registry->getIterator() as $e) { |
|
45 | - if ($registry->hasTable($e)) { |
|
44 | + foreach ($registry->getIterator() as $e) |
|
45 | + { |
|
46 | + if ($registry->hasTable($e)) |
|
47 | + { |
|
46 | 48 | $table = $registry->getTableSchema($e); |
47 | 49 | |
48 | - if ($table->getComparator()->hasChanges()) { |
|
50 | + if ($table->getComparator()->hasChanges()) |
|
51 | + { |
|
49 | 52 | $this->changes[] = [ |
50 | 53 | 'database' => $registry->getDatabase($e), |
51 | 54 | 'table' => $registry->getTable($e), |
@@ -55,13 +58,15 @@ discard block |
||
55 | 58 | } |
56 | 59 | } |
57 | 60 | |
58 | - if ($this->changes === []) { |
|
61 | + if ($this->changes === []) |
|
62 | + { |
|
59 | 63 | $this->output->writeln('<fg=yellow>no database changes has been detected</fg=yellow>'); |
60 | 64 | |
61 | 65 | return $registry; |
62 | 66 | } |
63 | 67 | |
64 | - foreach ($this->changes as $change) { |
|
68 | + foreach ($this->changes as $change) |
|
69 | + { |
|
65 | 70 | $this->output->write(sprintf('• <fg=cyan>%s.%s</fg=cyan>', $change['database'], $change['table'])); |
66 | 71 | $this->describeChanges($change['schema']); |
67 | 72 | } |
@@ -82,7 +87,8 @@ discard block |
||
82 | 87 | */ |
83 | 88 | protected function describeChanges(AbstractTable $table): void |
84 | 89 | { |
85 | - if (!$this->output->isVerbose()) { |
|
90 | + if (!$this->output->isVerbose()) |
|
91 | + { |
|
86 | 92 | $this->output->writeln(sprintf( |
87 | 93 | ': <fg=green>%s</fg=green> change(s) detected', |
88 | 94 | $this->numChanges($table) |
@@ -93,11 +99,13 @@ discard block |
||
93 | 99 | $this->output->write("\n"); |
94 | 100 | |
95 | 101 | |
96 | - if (!$table->exists()) { |
|
102 | + if (!$table->exists()) |
|
103 | + { |
|
97 | 104 | $this->output->writeln(' - create table'); |
98 | 105 | } |
99 | 106 | |
100 | - if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
|
107 | + if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) |
|
108 | + { |
|
101 | 109 | $this->output->writeln(' - drop table'); |
102 | 110 | return; |
103 | 111 | } |
@@ -114,15 +122,18 @@ discard block |
||
114 | 122 | */ |
115 | 123 | protected function describeColumns(Comparator $cmp): void |
116 | 124 | { |
117 | - foreach ($cmp->addedColumns() as $column) { |
|
125 | + foreach ($cmp->addedColumns() as $column) |
|
126 | + { |
|
118 | 127 | $this->output->writeln(" - add column <fg=yellow>{$column->getName()}</fg=yellow>"); |
119 | 128 | } |
120 | 129 | |
121 | - foreach ($cmp->droppedColumns() as $column) { |
|
130 | + foreach ($cmp->droppedColumns() as $column) |
|
131 | + { |
|
122 | 132 | $this->output->writeln(" - drop column <fg=yellow>{$column->getName()}</fg=yellow>"); |
123 | 133 | } |
124 | 134 | |
125 | - foreach ($cmp->alteredColumns() as $column) { |
|
135 | + foreach ($cmp->alteredColumns() as $column) |
|
136 | + { |
|
126 | 137 | $column = $column[0]; |
127 | 138 | $this->output->writeln(" - alter column <fg=yellow>{$column->getName()}</fg=yellow>"); |
128 | 139 | } |
@@ -133,17 +144,20 @@ discard block |
||
133 | 144 | */ |
134 | 145 | protected function describeIndexes(Comparator $cmp): void |
135 | 146 | { |
136 | - foreach ($cmp->addedIndexes() as $index) { |
|
147 | + foreach ($cmp->addedIndexes() as $index) |
|
148 | + { |
|
137 | 149 | $index = join(', ', $index->getColumns()); |
138 | 150 | $this->output->writeln(" - add index on <fg=yellow>[{$index}]</fg=yellow>"); |
139 | 151 | } |
140 | 152 | |
141 | - foreach ($cmp->droppedIndexes() as $index) { |
|
153 | + foreach ($cmp->droppedIndexes() as $index) |
|
154 | + { |
|
142 | 155 | $index = join(', ', $index->getColumns()); |
143 | 156 | $this->output->writeln(" - drop index on <fg=yellow>[{$index}]</fg=yellow>"); |
144 | 157 | } |
145 | 158 | |
146 | - foreach ($cmp->alteredIndexes() as $index) { |
|
159 | + foreach ($cmp->alteredIndexes() as $index) |
|
160 | + { |
|
147 | 161 | $index = $index[0]; |
148 | 162 | $index = join(', ', $index->getColumns()); |
149 | 163 | $this->output->writeln(" - alter index on <fg=yellow>[{$index}]</fg=yellow>"); |
@@ -155,17 +169,20 @@ discard block |
||
155 | 169 | */ |
156 | 170 | protected function describeFKs(Comparator $cmp): void |
157 | 171 | { |
158 | - foreach ($cmp->addedForeignKeys() as $fk) { |
|
172 | + foreach ($cmp->addedForeignKeys() as $fk) |
|
173 | + { |
|
159 | 174 | $fkColumns = join(', ', $fk->getColumns()); |
160 | 175 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fkColumns}</fg=yellow>"); |
161 | 176 | } |
162 | 177 | |
163 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
178 | + foreach ($cmp->droppedForeignKeys() as $fk) |
|
179 | + { |
|
164 | 180 | $fkColumns = join(', ', $fk->getColumns()); |
165 | 181 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
166 | 182 | } |
167 | 183 | |
168 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
184 | + foreach ($cmp->alteredForeignKeys() as $fk) |
|
185 | + { |
|
169 | 186 | $fk = $fk[0]; |
170 | 187 | $fkColumns = join(', ', $fk->getColumns()); |
171 | 188 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | $generator = new ContextGenerator($views->getContext()); |
35 | 35 | |
36 | 36 | $contexts = $generator->generate(); |
37 | - if (empty($contexts)) { |
|
37 | + if (empty($contexts)){ |
|
38 | 38 | $contexts[] = $views->getContext(); |
39 | 39 | } |
40 | 40 | |
41 | - foreach ($contexts as $context) { |
|
42 | - foreach ($views->getEngines() as $engine) { |
|
43 | - if ($engine instanceof NativeEngine) { |
|
41 | + foreach ($contexts as $context){ |
|
42 | + foreach ($views->getEngines() as $engine){ |
|
43 | + if ($engine instanceof NativeEngine){ |
|
44 | 44 | // no need to compile |
45 | 45 | continue; |
46 | 46 | } |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | $this->describeContext($context) ?? 'default' |
65 | 65 | ); |
66 | 66 | |
67 | - foreach ($engine->getLoader()->list() as $path) { |
|
67 | + foreach ($engine->getLoader()->list() as $path){ |
|
68 | 68 | $start = microtime(true); |
69 | - try { |
|
69 | + try{ |
|
70 | 70 | $engine->reset($path, $context); |
71 | 71 | $engine->compile($path, $context); |
72 | 72 | |
73 | - if ($this->isVerbose()) { |
|
73 | + if ($this->isVerbose()){ |
|
74 | 74 | $this->sprintf('<info>•</info> %s', $path); |
75 | 75 | } |
76 | - } catch (\Throwable $e) { |
|
76 | + }catch (\Throwable $e){ |
|
77 | 77 | $this->renderError($path, $e); |
78 | 78 | continue; |
79 | - } finally { |
|
79 | + }finally{ |
|
80 | 80 | $this->renderElapsed($start); |
81 | 81 | } |
82 | 82 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function renderError(string $path, \Throwable $e): void |
92 | 92 | { |
93 | - if (!$this->isVerbose()) { |
|
93 | + if (!$this->isVerbose()){ |
|
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | { |
111 | 111 | $values = []; |
112 | 112 | |
113 | - foreach ($context->getDependencies() as $dependency) { |
|
113 | + foreach ($context->getDependencies() as $dependency){ |
|
114 | 114 | $values[] = sprintf( |
115 | 115 | '%s%s%s:%s%s%s', |
116 | 116 | Color::LIGHT_WHITE, |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | */ |
142 | 142 | private function renderSuccess(string $lastPath = null): void |
143 | 143 | { |
144 | - if (!$this->isVerbose()) { |
|
144 | + if (!$this->isVerbose()){ |
|
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | - if ($lastPath === null) { |
|
148 | + if ($lastPath === null){ |
|
149 | 149 | $this->writeln('• no views found'); |
150 | 150 | } |
151 | 151 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | private function renderElapsed(float $start): void |
159 | 159 | { |
160 | - if (!$this->isVerbose()) { |
|
160 | + if (!$this->isVerbose()){ |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 |
@@ -34,13 +34,17 @@ discard block |
||
34 | 34 | $generator = new ContextGenerator($views->getContext()); |
35 | 35 | |
36 | 36 | $contexts = $generator->generate(); |
37 | - if (empty($contexts)) { |
|
37 | + if (empty($contexts)) |
|
38 | + { |
|
38 | 39 | $contexts[] = $views->getContext(); |
39 | 40 | } |
40 | 41 | |
41 | - foreach ($contexts as $context) { |
|
42 | - foreach ($views->getEngines() as $engine) { |
|
43 | - if ($engine instanceof NativeEngine) { |
|
42 | + foreach ($contexts as $context) |
|
43 | + { |
|
44 | + foreach ($views->getEngines() as $engine) |
|
45 | + { |
|
46 | + if ($engine instanceof NativeEngine) |
|
47 | + { |
|
44 | 48 | // no need to compile |
45 | 49 | continue; |
46 | 50 | } |
@@ -64,19 +68,26 @@ discard block |
||
64 | 68 | $this->describeContext($context) ?? 'default' |
65 | 69 | ); |
66 | 70 | |
67 | - foreach ($engine->getLoader()->list() as $path) { |
|
71 | + foreach ($engine->getLoader()->list() as $path) |
|
72 | + { |
|
68 | 73 | $start = microtime(true); |
69 | - try { |
|
74 | + try |
|
75 | + { |
|
70 | 76 | $engine->reset($path, $context); |
71 | 77 | $engine->compile($path, $context); |
72 | 78 | |
73 | - if ($this->isVerbose()) { |
|
79 | + if ($this->isVerbose()) |
|
80 | + { |
|
74 | 81 | $this->sprintf('<info>•</info> %s', $path); |
75 | 82 | } |
76 | - } catch (\Throwable $e) { |
|
83 | + } |
|
84 | + catch (\Throwable $e) |
|
85 | + { |
|
77 | 86 | $this->renderError($path, $e); |
78 | 87 | continue; |
79 | - } finally { |
|
88 | + } |
|
89 | + finally |
|
90 | + { |
|
80 | 91 | $this->renderElapsed($start); |
81 | 92 | } |
82 | 93 | } |
@@ -90,7 +101,8 @@ discard block |
||
90 | 101 | */ |
91 | 102 | protected function renderError(string $path, \Throwable $e): void |
92 | 103 | { |
93 | - if (!$this->isVerbose()) { |
|
104 | + if (!$this->isVerbose()) |
|
105 | + { |
|
94 | 106 | return; |
95 | 107 | } |
96 | 108 | |
@@ -110,7 +122,8 @@ discard block |
||
110 | 122 | { |
111 | 123 | $values = []; |
112 | 124 | |
113 | - foreach ($context->getDependencies() as $dependency) { |
|
125 | + foreach ($context->getDependencies() as $dependency) |
|
126 | + { |
|
114 | 127 | $values[] = sprintf( |
115 | 128 | '%s%s%s:%s%s%s', |
116 | 129 | Color::LIGHT_WHITE, |
@@ -141,11 +154,13 @@ discard block |
||
141 | 154 | */ |
142 | 155 | private function renderSuccess(string $lastPath = null): void |
143 | 156 | { |
144 | - if (!$this->isVerbose()) { |
|
157 | + if (!$this->isVerbose()) |
|
158 | + { |
|
145 | 159 | return; |
146 | 160 | } |
147 | 161 | |
148 | - if ($lastPath === null) { |
|
162 | + if ($lastPath === null) |
|
163 | + { |
|
149 | 164 | $this->writeln('• no views found'); |
150 | 165 | } |
151 | 166 | |
@@ -157,7 +172,8 @@ discard block |
||
157 | 172 | */ |
158 | 173 | private function renderElapsed(float $start): void |
159 | 174 | { |
160 | - if (!$this->isVerbose()) { |
|
175 | + if (!$this->isVerbose()) |
|
176 | + { |
|
161 | 177 | return; |
162 | 178 | } |
163 | 179 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function perform(Console $console): void |
29 | 29 | { |
30 | - if (!$this->verifyEnvironment()) { |
|
30 | + if (!$this->verifyEnvironment()){ |
|
31 | 31 | //Making sure we can safely migrate in this environment |
32 | 32 | return; |
33 | 33 | } |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | $rollback = ['--force' => true]; |
36 | 36 | $migrate = ['--force' => true]; |
37 | 37 | |
38 | - if ($this->option('all')) { |
|
38 | + if ($this->option('all')){ |
|
39 | 39 | $rollback['--all'] = true; |
40 | - } else { |
|
40 | + }else{ |
|
41 | 41 | $migrate['--one'] = true; |
42 | 42 | } |
43 | 43 |
@@ -27,7 +27,8 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function perform(Console $console): void |
29 | 29 | { |
30 | - if (!$this->verifyEnvironment()) { |
|
30 | + if (!$this->verifyEnvironment()) |
|
31 | + { |
|
31 | 32 | //Making sure we can safely migrate in this environment |
32 | 33 | return; |
33 | 34 | } |
@@ -35,9 +36,12 @@ discard block |
||
35 | 36 | $rollback = ['--force' => true]; |
36 | 37 | $migrate = ['--force' => true]; |
37 | 38 | |
38 | - if ($this->option('all')) { |
|
39 | + if ($this->option('all')) |
|
40 | + { |
|
39 | 41 | $rollback['--all'] = true; |
40 | - } else { |
|
42 | + } |
|
43 | + else |
|
44 | + { |
|
41 | 45 | $migrate['--one'] = true; |
42 | 46 | } |
43 | 47 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | { |
26 | 26 | $services = $locator->getServices(); |
27 | 27 | |
28 | - if ($services === []) { |
|
28 | + if ($services === []){ |
|
29 | 29 | $this->writeln('<comment>No GRPC services were found.</comment>'); |
30 | 30 | return; |
31 | 31 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | 'File:', |
37 | 37 | ]); |
38 | 38 | |
39 | - foreach ($services as $interface => $instance) { |
|
39 | + foreach ($services as $interface => $instance){ |
|
40 | 40 | $grid->addRow([ |
41 | 41 | $interface::NAME, |
42 | 42 | get_class($instance), |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | { |
26 | 26 | $services = $locator->getServices(); |
27 | 27 | |
28 | - if ($services === []) { |
|
28 | + if ($services === []) |
|
29 | + { |
|
29 | 30 | $this->writeln('<comment>No GRPC services were found.</comment>'); |
30 | 31 | return; |
31 | 32 | } |
@@ -36,7 +37,8 @@ discard block |
||
36 | 37 | 'File:', |
37 | 38 | ]); |
38 | 39 | |
39 | - foreach ($services as $interface => $instance) { |
|
40 | + foreach ($services as $interface => $instance) |
|
41 | + { |
|
40 | 42 | $grid->addRow([ |
41 | 43 | $interface::NAME, |
42 | 44 | get_class($instance), |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs): void |
41 | 41 | { |
42 | 42 | $protoFile = $this->argument('proto'); |
43 | - if (!file_exists($protoFile)) { |
|
43 | + if (!file_exists($protoFile)){ |
|
44 | 44 | $this->sprintf('<error>File `%s` not found.</error>', $protoFile); |
45 | 45 | return; |
46 | 46 | } |
@@ -53,19 +53,19 @@ discard block |
||
53 | 53 | |
54 | 54 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
55 | 55 | |
56 | - try { |
|
56 | + try{ |
|
57 | 57 | $result = $compiler->compile($protoFile); |
58 | - } catch (\Throwable $e) { |
|
58 | + }catch (\Throwable $e){ |
|
59 | 59 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | - if ($result === []) { |
|
63 | + if ($result === []){ |
|
64 | 64 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
65 | 65 | return; |
66 | 66 | } |
67 | 67 | |
68 | - foreach ($result as $file) { |
|
68 | + foreach ($result as $file){ |
|
69 | 69 | $this->sprintf( |
70 | 70 | "<fg=green>•</fg=green> %s%s%s\n", |
71 | 71 | Color::LIGHT_WHITE, |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | protected function getPath(KernelInterface $kernel): string |
85 | 85 | { |
86 | 86 | $path = $this->argument('namespace'); |
87 | - if ($path !== 'auto') { |
|
87 | + if ($path !== 'auto'){ |
|
88 | 88 | return $path; |
89 | 89 | } |
90 | 90 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | protected function getNamespace(KernelInterface $kernel): string |
103 | 103 | { |
104 | 104 | $namespace = $this->argument('namespace'); |
105 | - if ($namespace !== 'auto') { |
|
105 | + if ($namespace !== 'auto'){ |
|
106 | 106 | return $namespace; |
107 | 107 | } |
108 | 108 |
@@ -40,7 +40,8 @@ discard block |
||
40 | 40 | public function perform(KernelInterface $kernel, FilesInterface $files, DirectoriesInterface $dirs): void |
41 | 41 | { |
42 | 42 | $protoFile = $this->argument('proto'); |
43 | - if (!file_exists($protoFile)) { |
|
43 | + if (!file_exists($protoFile)) |
|
44 | + { |
|
44 | 45 | $this->sprintf('<error>File `%s` not found.</error>', $protoFile); |
45 | 46 | return; |
46 | 47 | } |
@@ -53,19 +54,24 @@ discard block |
||
53 | 54 | |
54 | 55 | $this->sprintf("<info>Compiling <fg=cyan>`%s`</fg=cyan>:</info>\n", $protoFile); |
55 | 56 | |
56 | - try { |
|
57 | + try |
|
58 | + { |
|
57 | 59 | $result = $compiler->compile($protoFile); |
58 | - } catch (\Throwable $e) { |
|
60 | + } |
|
61 | + catch (\Throwable $e) |
|
62 | + { |
|
59 | 63 | $this->sprintf("<error>Error:</error> <fg=red>%s</fg=red>\n", $e->getMessage()); |
60 | 64 | return; |
61 | 65 | } |
62 | 66 | |
63 | - if ($result === []) { |
|
67 | + if ($result === []) |
|
68 | + { |
|
64 | 69 | $this->sprintf("<info>No files were generated.</info>\n", $protoFile); |
65 | 70 | return; |
66 | 71 | } |
67 | 72 | |
68 | - foreach ($result as $file) { |
|
73 | + foreach ($result as $file) |
|
74 | + { |
|
69 | 75 | $this->sprintf( |
70 | 76 | "<fg=green>•</fg=green> %s%s%s\n", |
71 | 77 | Color::LIGHT_WHITE, |
@@ -84,7 +90,8 @@ discard block |
||
84 | 90 | protected function getPath(KernelInterface $kernel): string |
85 | 91 | { |
86 | 92 | $path = $this->argument('namespace'); |
87 | - if ($path !== 'auto') { |
|
93 | + if ($path !== 'auto') |
|
94 | + { |
|
88 | 95 | return $path; |
89 | 96 | } |
90 | 97 | |
@@ -102,7 +109,8 @@ discard block |
||
102 | 109 | protected function getNamespace(KernelInterface $kernel): string |
103 | 110 | { |
104 | 111 | $namespace = $this->argument('namespace'); |
105 | - if ($namespace !== 'auto') { |
|
112 | + if ($namespace !== 'auto') |
|
113 | + { |
|
106 | 114 | return $namespace; |
107 | 115 | } |
108 | 116 |
@@ -55,21 +55,21 @@ |
||
55 | 55 | $this->sprintf("<info>New encryption key:</info> <fg=cyan>%s</fg=cyan>\n", $key); |
56 | 56 | |
57 | 57 | $file = $this->option('mount'); |
58 | - if ($file === null) { |
|
58 | + if ($file === null){ |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | - if (!$files->exists($file)) { |
|
62 | + if (!$files->exists($file)){ |
|
63 | 63 | $this->sprintf('<error>Unable to find `%s`</error>', $file); |
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | 67 | $content = $files->read($file); |
68 | 68 | |
69 | - try { |
|
69 | + try{ |
|
70 | 70 | $content = str_replace($this->option('placeholder'), $key, $content); |
71 | 71 | $content = str_replace($enc->getKey(), $key, $content); |
72 | - } catch (\Throwable $e) { |
|
72 | + }catch (\Throwable $e){ |
|
73 | 73 | // current keys is not set |
74 | 74 | } |
75 | 75 |
@@ -55,21 +55,26 @@ |
||
55 | 55 | $this->sprintf("<info>New encryption key:</info> <fg=cyan>%s</fg=cyan>\n", $key); |
56 | 56 | |
57 | 57 | $file = $this->option('mount'); |
58 | - if ($file === null) { |
|
58 | + if ($file === null) |
|
59 | + { |
|
59 | 60 | return; |
60 | 61 | } |
61 | 62 | |
62 | - if (!$files->exists($file)) { |
|
63 | + if (!$files->exists($file)) |
|
64 | + { |
|
63 | 65 | $this->sprintf('<error>Unable to find `%s`</error>', $file); |
64 | 66 | return; |
65 | 67 | } |
66 | 68 | |
67 | 69 | $content = $files->read($file); |
68 | 70 | |
69 | - try { |
|
71 | + try |
|
72 | + { |
|
70 | 73 | $content = str_replace($this->option('placeholder'), $key, $content); |
71 | 74 | $content = str_replace($enc->getKey(), $key, $content); |
72 | - } catch (\Throwable $e) { |
|
75 | + } |
|
76 | + catch (\Throwable $e) |
|
77 | + { |
|
73 | 78 | // current keys is not set |
74 | 79 | } |
75 | 80 |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | $http = $this->container->get(Http::class); |
59 | 59 | $emitter = $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 | - } finally { |
|
66 | + }finally{ |
|
67 | 67 | $this->finalizer->finalize(false); |
68 | 68 | } |
69 | 69 | } |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | { |
85 | 85 | $handler = new HtmlHandler(); |
86 | 86 | |
87 | - try { |
|
87 | + try{ |
|
88 | 88 | /** @var SnapshotInterface $snapshot */ |
89 | 89 | $this->container->get(SnapshotterInterface::class)->register($e); |
90 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
90 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
91 | 91 | // nothing to report |
92 | 92 | } |
93 | 93 |
@@ -58,12 +58,17 @@ discard block |
||
58 | 58 | $http = $this->container->get(Http::class); |
59 | 59 | $emitter = $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 | - } finally { |
|
69 | + } |
|
70 | + finally |
|
71 | + { |
|
67 | 72 | $this->finalizer->finalize(false); |
68 | 73 | } |
69 | 74 | } |
@@ -84,10 +89,13 @@ discard block |
||
84 | 89 | { |
85 | 90 | $handler = new HtmlHandler(); |
86 | 91 | |
87 | - try { |
|
92 | + try |
|
93 | + { |
|
88 | 94 | /** @var SnapshotInterface $snapshot */ |
89 | 95 | $this->container->get(SnapshotterInterface::class)->register($e); |
90 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
96 | + } |
|
97 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
98 | + { |
|
91 | 99 | // nothing to report |
92 | 100 | } |
93 | 101 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | FinalizerInterface $finalizer, |
48 | 48 | ContainerInterface $container, |
49 | 49 | FactoryInterface $factory |
50 | - ) { |
|
50 | + ){ |
|
51 | 51 | $this->env = $env; |
52 | 52 | $this->finalizer = $finalizer; |
53 | 53 | $this->container = $container; |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | |
72 | 72 | /** @var Http $http */ |
73 | 73 | $http = $this->container->get(Http::class); |
74 | - while ($request = $client->acceptRequest()) { |
|
75 | - try { |
|
74 | + while ($request = $client->acceptRequest()){ |
|
75 | + try{ |
|
76 | 76 | $client->respond($http->handle($request)); |
77 | - } catch (\Throwable $e) { |
|
77 | + }catch (\Throwable $e){ |
|
78 | 78 | $this->handleException($client, $e); |
79 | - } finally { |
|
79 | + }finally{ |
|
80 | 80 | $this->finalizer->finalize(false); |
81 | 81 | } |
82 | 82 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | { |
91 | 91 | $handler = new HtmlHandler(); |
92 | 92 | |
93 | - try { |
|
93 | + try{ |
|
94 | 94 | /** @var SnapshotInterface $snapshot */ |
95 | 95 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
96 | 96 | error_log($snapshot->getMessage()); |
97 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
97 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
98 | 98 | error_log((string)$e); |
99 | 99 | } |
100 | 100 |
@@ -71,12 +71,18 @@ discard block |
||
71 | 71 | |
72 | 72 | /** @var Http $http */ |
73 | 73 | $http = $this->container->get(Http::class); |
74 | - while ($request = $client->acceptRequest()) { |
|
75 | - try { |
|
74 | + while ($request = $client->acceptRequest()) |
|
75 | + { |
|
76 | + try |
|
77 | + { |
|
76 | 78 | $client->respond($http->handle($request)); |
77 | - } catch (\Throwable $e) { |
|
79 | + } |
|
80 | + catch (\Throwable $e) |
|
81 | + { |
|
78 | 82 | $this->handleException($client, $e); |
79 | - } finally { |
|
83 | + } |
|
84 | + finally |
|
85 | + { |
|
80 | 86 | $this->finalizer->finalize(false); |
81 | 87 | } |
82 | 88 | } |
@@ -90,11 +96,14 @@ discard block |
||
90 | 96 | { |
91 | 97 | $handler = new HtmlHandler(); |
92 | 98 | |
93 | - try { |
|
99 | + try |
|
100 | + { |
|
94 | 101 | /** @var SnapshotInterface $snapshot */ |
95 | 102 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
96 | 103 | error_log($snapshot->getMessage()); |
97 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
104 | + } |
|
105 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
106 | + { |
|
98 | 107 | error_log((string)$e); |
99 | 108 | } |
100 | 109 |