@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function perform(FilesInterface $files): void |
28 | 28 | { |
29 | - if (!$this->verifyConfigured()) { |
|
29 | + if (!$this->verifyConfigured()){ |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
33 | - if (empty($this->migrator->getMigrations())) { |
|
33 | + if (empty($this->migrator->getMigrations())){ |
|
34 | 34 | $this->writeln('<comment>No migrations were found.</comment>'); |
35 | 35 | |
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $table = $this->table(['Migration', 'Created at', 'Executed at']); |
40 | - foreach ($this->migrator->getMigrations() as $migration) { |
|
40 | + foreach ($this->migrator->getMigrations() as $migration){ |
|
41 | 41 | $state = $migration->getState(); |
42 | 42 | |
43 | 43 | $table->addRow([ |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $state->getTimeCreated()->format('Y-m-d H:i:s'), |
46 | 46 | $state->getStatus() == State::STATUS_PENDING |
47 | 47 | ? self::PENDING |
48 | - : '<info>' . $state->getTimeExecuted()->format('Y-m-d H:i:s') . '</info>' |
|
48 | + : '<info>'.$state->getTimeExecuted()->format('Y-m-d H:i:s').'</info>' |
|
49 | 49 | ]); |
50 | 50 | } |
51 | 51 |
@@ -26,18 +26,21 @@ |
||
26 | 26 | */ |
27 | 27 | public function perform(FilesInterface $files): void |
28 | 28 | { |
29 | - if (!$this->verifyConfigured()) { |
|
29 | + if (!$this->verifyConfigured()) |
|
30 | + { |
|
30 | 31 | return; |
31 | 32 | } |
32 | 33 | |
33 | - if (empty($this->migrator->getMigrations())) { |
|
34 | + if (empty($this->migrator->getMigrations())) |
|
35 | + { |
|
34 | 36 | $this->writeln('<comment>No migrations were found.</comment>'); |
35 | 37 | |
36 | 38 | return; |
37 | 39 | } |
38 | 40 | |
39 | 41 | $table = $this->table(['Migration', 'Created at', 'Executed at']); |
40 | - foreach ($this->migrator->getMigrations() as $migration) { |
|
42 | + foreach ($this->migrator->getMigrations() as $migration) |
|
43 | + { |
|
41 | 44 | $state = $migration->getState(); |
42 | 45 | |
43 | 46 | $table->addRow([ |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected function verifyConfigured(): bool |
43 | 43 | { |
44 | - if (!$this->migrator->isConfigured()) { |
|
44 | + if (!$this->migrator->isConfigured()){ |
|
45 | 45 | $this->writeln( |
46 | 46 | "<fg=red>Migrations are not configured yet, run '<info>migrate:init</info>' first.</fg=red>" |
47 | 47 | ); |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | */ |
60 | 60 | protected function verifyEnvironment(): bool |
61 | 61 | { |
62 | - if ($this->option('force') || $this->config->isSafe()) { |
|
62 | + if ($this->option('force') || $this->config->isSafe()){ |
|
63 | 63 | //Safe to run |
64 | 64 | return true; |
65 | 65 | } |
66 | 66 | |
67 | 67 | $this->writeln('<fg=red>Confirmation is required to run migrations!</fg=red>'); |
68 | 68 | |
69 | - if (!$this->askConfirmation()) { |
|
69 | + if (!$this->askConfirmation()){ |
|
70 | 70 | $this->writeln('<comment>Cancelling operation...</comment>'); |
71 | 71 | |
72 | 72 | return false; |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected function verifyConfigured(): bool |
43 | 43 | { |
44 | - if (!$this->migrator->isConfigured()) { |
|
44 | + if (!$this->migrator->isConfigured()) |
|
45 | + { |
|
45 | 46 | $this->writeln( |
46 | 47 | "<fg=red>Migrations are not configured yet, run '<info>migrate:init</info>' first.</fg=red>" |
47 | 48 | ); |
@@ -59,14 +60,16 @@ discard block |
||
59 | 60 | */ |
60 | 61 | protected function verifyEnvironment(): bool |
61 | 62 | { |
62 | - if ($this->option('force') || $this->config->isSafe()) { |
|
63 | + if ($this->option('force') || $this->config->isSafe()) |
|
64 | + { |
|
63 | 65 | //Safe to run |
64 | 66 | return true; |
65 | 67 | } |
66 | 68 | |
67 | 69 | $this->writeln('<fg=red>Confirmation is required to run migrations!</fg=red>'); |
68 | 70 | |
69 | - if (!$this->askConfirmation()) { |
|
71 | + if (!$this->askConfirmation()) |
|
72 | + { |
|
70 | 73 | $this->writeln('<comment>Cancelling operation...</comment>'); |
71 | 74 | |
72 | 75 | return false; |
@@ -26,20 +26,20 @@ discard block |
||
26 | 26 | public function perform(FilesInterface $files, DirectoriesInterface $directories): void |
27 | 27 | { |
28 | 28 | $cacheDirectory = $directories->get('cache'); |
29 | - if (!$files->exists($cacheDirectory)) { |
|
29 | + if (!$files->exists($cacheDirectory)){ |
|
30 | 30 | $this->writeln('Cache directory is missing, no cache to be cleaned.'); |
31 | 31 | |
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | - if ($this->isVerbose()) { |
|
35 | + if ($this->isVerbose()){ |
|
36 | 36 | $this->writeln('<info>Cleaning application cache:</info>'); |
37 | 37 | } |
38 | 38 | |
39 | - foreach ($files->getFiles($cacheDirectory) as $filename) { |
|
40 | - try { |
|
39 | + foreach ($files->getFiles($cacheDirectory) as $filename){ |
|
40 | + try{ |
|
41 | 41 | $files->delete($filename); |
42 | - } catch (\Throwable $e) { |
|
42 | + }catch (\Throwable $e){ |
|
43 | 43 | // @codeCoverageIgnoreStart |
44 | 44 | $this->sprintf( |
45 | 45 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | // @codeCoverageIgnoreEnd |
52 | 52 | } |
53 | 53 | |
54 | - if ($this->isVerbose()) { |
|
54 | + if ($this->isVerbose()){ |
|
55 | 55 | $this->sprintf( |
56 | 56 | "<fg=green>[deleted]</fg=green> `%s`\n", |
57 | 57 | $files->relativePath($filename, $cacheDirectory) |
@@ -26,20 +26,26 @@ discard block |
||
26 | 26 | public function perform(FilesInterface $files, DirectoriesInterface $directories): void |
27 | 27 | { |
28 | 28 | $cacheDirectory = $directories->get('cache'); |
29 | - if (!$files->exists($cacheDirectory)) { |
|
29 | + if (!$files->exists($cacheDirectory)) |
|
30 | + { |
|
30 | 31 | $this->writeln('Cache directory is missing, no cache to be cleaned.'); |
31 | 32 | |
32 | 33 | return; |
33 | 34 | } |
34 | 35 | |
35 | - if ($this->isVerbose()) { |
|
36 | + if ($this->isVerbose()) |
|
37 | + { |
|
36 | 38 | $this->writeln('<info>Cleaning application cache:</info>'); |
37 | 39 | } |
38 | 40 | |
39 | - foreach ($files->getFiles($cacheDirectory) as $filename) { |
|
40 | - try { |
|
41 | + foreach ($files->getFiles($cacheDirectory) as $filename) |
|
42 | + { |
|
43 | + try |
|
44 | + { |
|
41 | 45 | $files->delete($filename); |
42 | - } catch (\Throwable $e) { |
|
46 | + } |
|
47 | + catch (\Throwable $e) |
|
48 | + { |
|
43 | 49 | // @codeCoverageIgnoreStart |
44 | 50 | $this->sprintf( |
45 | 51 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
@@ -51,7 +57,8 @@ discard block |
||
51 | 57 | // @codeCoverageIgnoreEnd |
52 | 58 | } |
53 | 59 | |
54 | - if ($this->isVerbose()) { |
|
60 | + if ($this->isVerbose()) |
|
61 | + { |
|
55 | 62 | $this->sprintf( |
56 | 63 | "<fg=green>[deleted]</fg=green> `%s`\n", |
57 | 64 | $files->relativePath($filename, $cacheDirectory) |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | FilesInterface $files, |
55 | 55 | DirectoriesInterface $directories |
56 | 56 | ): void { |
57 | - switch ($this->argument('type')) { |
|
57 | + switch ($this->argument('type')){ |
|
58 | 58 | case 'replace': |
59 | 59 | case 'follow': |
60 | - if ($this->isDirectory()) { |
|
60 | + if ($this->isDirectory()){ |
|
61 | 61 | $this->sprintf( |
62 | 62 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
63 | 63 | $this->getSource($files, $directories), |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->getMergeMode(), |
71 | 71 | $this->getFileMode() |
72 | 72 | ); |
73 | - } else { |
|
73 | + }else{ |
|
74 | 74 | $this->sprintf( |
75 | 75 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
76 | 76 | $this->getSource($files, $directories), |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | private function getSource(FilesInterface $files, DirectoriesInterface $directories): ?string |
112 | 112 | { |
113 | - if (!$this->isDirectory()) { |
|
113 | + if (!$this->isDirectory()){ |
|
114 | 114 | return $files->normalizePath($this->argument('source')); |
115 | 115 | } |
116 | 116 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
126 | 126 | { |
127 | 127 | $target = $this->argument('target'); |
128 | - foreach ($directories->getAll() as $alias => $value) { |
|
128 | + foreach ($directories->getAll() as $alias => $value){ |
|
129 | 129 | $target = str_replace("@{$alias}", $value, $target); |
130 | 130 | } |
131 | 131 | |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | */ |
138 | 138 | private function isDirectory(): bool |
139 | 139 | { |
140 | - if ($this->argument('type') == 'ensure') { |
|
140 | + if ($this->argument('type') == 'ensure'){ |
|
141 | 141 | return true; |
142 | 142 | } |
143 | 143 | |
144 | - if (strpos($this->argument('source'), '*') !== false) { |
|
144 | + if (strpos($this->argument('source'), '*') !== false){ |
|
145 | 145 | return true; |
146 | 146 | } |
147 | 147 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | private function getMergeMode(): string |
155 | 155 | { |
156 | - switch ($this->argument('type')) { |
|
156 | + switch ($this->argument('type')){ |
|
157 | 157 | case 'follow': |
158 | 158 | return PublisherInterface::FOLLOW; |
159 | 159 | case 'replace': |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | private function getFileMode(): int |
170 | 170 | { |
171 | - switch ($this->argument('mode')) { |
|
171 | + switch ($this->argument('mode')){ |
|
172 | 172 | case 'readonly': |
173 | 173 | return FilesInterface::READONLY; |
174 | 174 | case 'runtime': |
@@ -54,10 +54,12 @@ discard block |
||
54 | 54 | FilesInterface $files, |
55 | 55 | DirectoriesInterface $directories |
56 | 56 | ): void { |
57 | - switch ($this->argument('type')) { |
|
57 | + switch ($this->argument('type')) |
|
58 | + { |
|
58 | 59 | case 'replace': |
59 | 60 | case 'follow': |
60 | - if ($this->isDirectory()) { |
|
61 | + if ($this->isDirectory()) |
|
62 | + { |
|
61 | 63 | $this->sprintf( |
62 | 64 | '<fg=cyan>•</fg=cyan> publish directory <comment>%s</comment> to <comment>%s</comment>', |
63 | 65 | $this->getSource($files, $directories), |
@@ -70,7 +72,9 @@ discard block |
||
70 | 72 | $this->getMergeMode(), |
71 | 73 | $this->getFileMode() |
72 | 74 | ); |
73 | - } else { |
|
75 | + } |
|
76 | + else |
|
77 | + { |
|
74 | 78 | $this->sprintf( |
75 | 79 | '<fg=cyan>•</fg=cyan> publish file <comment>%s</comment> to <comment>%s</comment>', |
76 | 80 | $this->getSource($files, $directories), |
@@ -110,7 +114,8 @@ discard block |
||
110 | 114 | */ |
111 | 115 | private function getSource(FilesInterface $files, DirectoriesInterface $directories): ?string |
112 | 116 | { |
113 | - if (!$this->isDirectory()) { |
|
117 | + if (!$this->isDirectory()) |
|
118 | + { |
|
114 | 119 | return $files->normalizePath($this->argument('source')); |
115 | 120 | } |
116 | 121 | |
@@ -125,7 +130,8 @@ discard block |
||
125 | 130 | private function getTarget(FilesInterface $files, DirectoriesInterface $directories): ?string |
126 | 131 | { |
127 | 132 | $target = $this->argument('target'); |
128 | - foreach ($directories->getAll() as $alias => $value) { |
|
133 | + foreach ($directories->getAll() as $alias => $value) |
|
134 | + { |
|
129 | 135 | $target = str_replace("@{$alias}", $value, $target); |
130 | 136 | } |
131 | 137 | |
@@ -137,11 +143,13 @@ discard block |
||
137 | 143 | */ |
138 | 144 | private function isDirectory(): bool |
139 | 145 | { |
140 | - if ($this->argument('type') == 'ensure') { |
|
146 | + if ($this->argument('type') == 'ensure') |
|
147 | + { |
|
141 | 148 | return true; |
142 | 149 | } |
143 | 150 | |
144 | - if (strpos($this->argument('source'), '*') !== false) { |
|
151 | + if (strpos($this->argument('source'), '*') !== false) |
|
152 | + { |
|
145 | 153 | return true; |
146 | 154 | } |
147 | 155 | |
@@ -153,7 +161,8 @@ discard block |
||
153 | 161 | */ |
154 | 162 | private function getMergeMode(): string |
155 | 163 | { |
156 | - switch ($this->argument('type')) { |
|
164 | + switch ($this->argument('type')) |
|
165 | + { |
|
157 | 166 | case 'follow': |
158 | 167 | return PublisherInterface::FOLLOW; |
159 | 168 | case 'replace': |
@@ -168,7 +177,8 @@ discard block |
||
168 | 177 | */ |
169 | 178 | private function getFileMode(): int |
170 | 179 | { |
171 | - switch ($this->argument('mode')) { |
|
180 | + switch ($this->argument('mode')) |
|
181 | + { |
|
172 | 182 | case 'readonly': |
173 | 183 | return FilesInterface::READONLY; |
174 | 184 | case 'runtime': |
@@ -27,20 +27,20 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function perform(ViewsConfig $config, FilesInterface $files): void |
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( |
46 | 46 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // @codeCoverageIgnoreEnd |
54 | 54 | } |
55 | 55 | |
56 | - if ($this->isVerbose()) { |
|
56 | + if ($this->isVerbose()){ |
|
57 | 57 | $this->sprintf( |
58 | 58 | "<fg=green>[deleted]</fg=green> `%s`\n", |
59 | 59 | $files->relativePath($filename, $config->getCacheDirectory()) |
@@ -27,20 +27,26 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function perform(ViewsConfig $config, FilesInterface $files): void |
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( |
46 | 52 | "<fg=red>[errored]</fg=red> `%s`: <fg=red>%s</fg=red>\n", |
@@ -53,7 +59,8 @@ discard block |
||
53 | 59 | // @codeCoverageIgnoreEnd |
54 | 60 | } |
55 | 61 | |
56 | - if ($this->isVerbose()) { |
|
62 | + if ($this->isVerbose()) |
|
63 | + { |
|
57 | 64 | $this->sprintf( |
58 | 65 | "<fg=green>[deleted]</fg=green> `%s`\n", |
59 | 66 | $files->relativePath($filename, $config->getCacheDirectory()) |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function perform(TranslatorConfig $config, CatalogueManager $manager): void |
41 | 41 | { |
42 | - if (!$config->hasDumper($this->option('dumper'))) { |
|
42 | + if (!$config->hasDumper($this->option('dumper'))) |
|
43 | + { |
|
43 | 44 | $this->writeln("<fg=red>Undefined dumper '{$this->option('dumper')}'.</fg=red>"); |
44 | 45 | |
45 | 46 | return; |
@@ -51,7 +52,8 @@ discard block |
||
51 | 52 | $manager->get($this->argument('locale')) |
52 | 53 | ); |
53 | 54 | |
54 | - if ($this->isVerbose() && !empty($mc->getDomains())) { |
|
55 | + if ($this->isVerbose() && !empty($mc->getDomains())) |
|
56 | + { |
|
55 | 57 | $this->sprintf( |
56 | 58 | "<info>Exporting domain(s):</info> %s\n", |
57 | 59 | join(',', $mc->getDomains()) |
@@ -86,10 +88,14 @@ discard block |
||
86 | 88 | $catalogue->getData() |
87 | 89 | ); |
88 | 90 | |
89 | - if ($this->option('fallback')) { |
|
90 | - foreach ($manager->get($config->getFallbackLocale())->getData() as $domain => $messages) { |
|
91 | - foreach ($messages as $id => $message) { |
|
92 | - if (!$messageCatalogue->defines($id, $domain)) { |
|
91 | + if ($this->option('fallback')) |
|
92 | + { |
|
93 | + foreach ($manager->get($config->getFallbackLocale())->getData() as $domain => $messages) |
|
94 | + { |
|
95 | + foreach ($messages as $id => $message) |
|
96 | + { |
|
97 | + if (!$messageCatalogue->defines($id, $domain)) |
|
98 | + { |
|
93 | 99 | $messageCatalogue->set($id, $message, $domain); |
94 | 100 | } |
95 | 101 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | ['locale', InputArgument::REQUIRED, 'Locale to be dumped'], |
28 | 28 | ['path', InputArgument::REQUIRED, 'Export path'] |
29 | 29 | ]; |
30 | - protected const OPTIONS = [ |
|
30 | + protected const OPTIONS = [ |
|
31 | 31 | ['dumper', 'd', InputOption::VALUE_OPTIONAL, 'Dumper name', 'php'], |
32 | 32 | ['fallback', 'f', InputOption::VALUE_NONE, 'Merge messages from fallback catalogue'], |
33 | 33 | ]; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function perform(TranslatorConfig $config, CatalogueManager $manager): void |
40 | 40 | { |
41 | - if (!$config->hasDumper($this->option('dumper'))) { |
|
41 | + if (!$config->hasDumper($this->option('dumper'))){ |
|
42 | 42 | $this->writeln("<fg=red>Undefined dumper '{$this->option('dumper')}'.</fg=red>"); |
43 | 43 | |
44 | 44 | return; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $manager->get($this->argument('locale')) |
51 | 51 | ); |
52 | 52 | |
53 | - if ($this->isVerbose() && !empty($mc->getDomains())) { |
|
53 | + if ($this->isVerbose() && !empty($mc->getDomains())){ |
|
54 | 54 | $this->sprintf( |
55 | 55 | "<info>Exporting domain(s):</info> %s\n", |
56 | 56 | join(',', $mc->getDomains()) |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | 'xliff_version' => '2.0' // forcing default version for xliff dumper only |
66 | 66 | ]); |
67 | 67 | |
68 | - $this->writeln('Export successfully completed using <info>' . get_class($dumper) . '</info>'); |
|
69 | - $this->writeln('Output: <comment>' . realpath($this->argument('path')) . '</comment>'); |
|
68 | + $this->writeln('Export successfully completed using <info>'.get_class($dumper).'</info>'); |
|
69 | + $this->writeln('Output: <comment>'.realpath($this->argument('path')).'</comment>'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | $catalogue->getData() |
86 | 86 | ); |
87 | 87 | |
88 | - if ($this->option('fallback')) { |
|
89 | - foreach ($manager->get($config->getFallbackLocale())->getData() as $domain => $messages) { |
|
90 | - foreach ($messages as $id => $message) { |
|
91 | - if (!$messageCatalogue->defines($id, $domain)) { |
|
88 | + if ($this->option('fallback')){ |
|
89 | + foreach ($manager->get($config->getFallbackLocale())->getData() as $domain => $messages){ |
|
90 | + foreach ($messages as $id => $message){ |
|
91 | + if (!$messageCatalogue->defines($id, $domain)){ |
|
92 | 92 | $messageCatalogue->set($id, $message, $domain); |
93 | 93 | } |
94 | 94 | } |
@@ -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 |