@@ -32,7 +32,8 @@ discard block |
||
32 | 32 | public function setUp() |
33 | 33 | { |
34 | 34 | exec('protoc 2>&1', $out); |
35 | - if (strpos(join("\n", $out), '--php_out') === false) { |
|
35 | + if (strpos(join("\n", $out), '--php_out') === false) |
|
36 | + { |
|
36 | 37 | $this->markTestSkipped('Protoc binary is missing'); |
37 | 38 | } |
38 | 39 | |
@@ -51,11 +52,13 @@ discard block |
||
51 | 52 | |
52 | 53 | $fs = new Files(); |
53 | 54 | |
54 | - if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) { |
|
55 | + if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) |
|
56 | + { |
|
55 | 57 | $fs->deleteDirectory($this->app->dir('app') . 'src/Service'); |
56 | 58 | } |
57 | 59 | |
58 | - if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) { |
|
60 | + if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) |
|
61 | + { |
|
59 | 62 | $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata'); |
60 | 63 | } |
61 | 64 | } |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | public function setUp() |
34 | 34 | { |
35 | 35 | exec('protoc 2>&1', $out); |
36 | - if (strpos(join("\n", $out), '--php_out') === false) { |
|
36 | + if (strpos(join("\n", $out), '--php_out') === false){ |
|
37 | 37 | $this->markTestSkipped('Protoc binary is missing'); |
38 | 38 | } |
39 | 39 | |
40 | 40 | parent::setUp(); |
41 | 41 | |
42 | 42 | $fs = new Files(); |
43 | - $this->proto = $fs->normalizePath($this->app->dir('app') . 'proto/service.proto'); |
|
43 | + $this->proto = $fs->normalizePath($this->app->dir('app').'proto/service.proto'); |
|
44 | 44 | |
45 | 45 | // protoc can't figure relative paths |
46 | 46 | $this->proto = str_replace('Framework/../', '', $this->proto); |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | |
53 | 53 | $fs = new Files(); |
54 | 54 | |
55 | - if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) { |
|
56 | - $fs->deleteDirectory($this->app->dir('app') . 'src/Service'); |
|
55 | + if ($fs->isDirectory($this->app->dir('app').'src/Service')){ |
|
56 | + $fs->deleteDirectory($this->app->dir('app').'src/Service'); |
|
57 | 57 | } |
58 | 58 | |
59 | - if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) { |
|
60 | - $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata'); |
|
59 | + if ($fs->isDirectory($this->app->dir('app').'src/GPBMetadata')){ |
|
60 | + $fs->deleteDirectory($this->app->dir('app').'src/GPBMetadata'); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | 'proto' => $this->proto |
86 | 86 | ]); |
87 | 87 | |
88 | - $this->assertFileExists($this->app->dir('app') . 'src/Service/EchoInterface.php'); |
|
89 | - $this->assertFileExists($this->app->dir('app') . 'src/Service/Sub/Message.php'); |
|
90 | - $this->assertFileExists($this->app->dir('app') . 'src/GPBMetadata/Service.php'); |
|
88 | + $this->assertFileExists($this->app->dir('app').'src/Service/EchoInterface.php'); |
|
89 | + $this->assertFileExists($this->app->dir('app').'src/Service/Sub/Message.php'); |
|
90 | + $this->assertFileExists($this->app->dir('app').'src/GPBMetadata/Service.php'); |
|
91 | 91 | } |
92 | 92 | } |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | |
59 | 59 | $output = trim(join("\n", $output), "\n ,"); |
60 | 60 | |
61 | - if ($output !== '') { |
|
61 | + if ($output !== ''){ |
|
62 | 62 | $this->files->deleteDirectory($tmpDir); |
63 | 63 | throw new CompileException($output); |
64 | 64 | } |
65 | 65 | |
66 | 66 | // copying files (using relative path and namespace) |
67 | 67 | $result = []; |
68 | - foreach ($this->files->getFiles($tmpDir) as $file) { |
|
68 | + foreach ($this->files->getFiles($tmpDir) as $file){ |
|
69 | 69 | $result[] = $this->copy($tmpDir, $file); |
70 | 70 | } |
71 | 71 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | private function copy(string $tmpDir, string $file): string |
83 | 83 | { |
84 | 84 | $source = ltrim($this->files->relativePath($file, $tmpDir), '\\/'); |
85 | - if (strpos($source, $this->baseNamespace) === 0) { |
|
85 | + if (strpos($source, $this->baseNamespace) === 0){ |
|
86 | 86 | $source = ltrim(substr($source, strlen($this->baseNamespace)), '\\/'); |
87 | 87 | } |
88 | 88 | |
89 | - $target = $this->files->normalizePath($this->basePath . '/' . $source); |
|
89 | + $target = $this->files->normalizePath($this->basePath.'/'.$source); |
|
90 | 90 | |
91 | 91 | $this->files->ensureDirectory(dirname($target)); |
92 | 92 | $this->files->copy($file, $target); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function tmpDir(): string |
101 | 101 | { |
102 | - $directory = sys_get_temp_dir() . '/' . spl_object_hash($this); |
|
102 | + $directory = sys_get_temp_dir().'/'.spl_object_hash($this); |
|
103 | 103 | $this->files->ensureDirectory($directory); |
104 | 104 | |
105 | 105 | return $this->files->normalizePath($directory, true); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | private function getProtoFiles(string $protoFile): array |
115 | 115 | { |
116 | - return array_filter($this->files->getFiles(dirname($protoFile)), function ($file) { |
|
116 | + return array_filter($this->files->getFiles(dirname($protoFile)), function ($file){ |
|
117 | 117 | return strpos($file, '.proto') !== false; |
118 | 118 | }); |
119 | 119 | } |
@@ -58,14 +58,16 @@ discard block |
||
58 | 58 | |
59 | 59 | $output = trim(join("\n", $output), "\n ,"); |
60 | 60 | |
61 | - if ($output !== '') { |
|
61 | + if ($output !== '') |
|
62 | + { |
|
62 | 63 | $this->files->deleteDirectory($tmpDir); |
63 | 64 | throw new CompileException($output); |
64 | 65 | } |
65 | 66 | |
66 | 67 | // copying files (using relative path and namespace) |
67 | 68 | $result = []; |
68 | - foreach ($this->files->getFiles($tmpDir) as $file) { |
|
69 | + foreach ($this->files->getFiles($tmpDir) as $file) |
|
70 | + { |
|
69 | 71 | $result[] = $this->copy($tmpDir, $file); |
70 | 72 | } |
71 | 73 | |
@@ -82,7 +84,8 @@ discard block |
||
82 | 84 | private function copy(string $tmpDir, string $file): string |
83 | 85 | { |
84 | 86 | $source = ltrim($this->files->relativePath($file, $tmpDir), '\\/'); |
85 | - if (strpos($source, $this->baseNamespace) === 0) { |
|
87 | + if (strpos($source, $this->baseNamespace) === 0) |
|
88 | + { |
|
86 | 89 | $source = ltrim(substr($source, strlen($this->baseNamespace)), '\\/'); |
87 | 90 | } |
88 | 91 | |
@@ -113,7 +116,8 @@ discard block |
||
113 | 116 | */ |
114 | 117 | private function getProtoFiles(string $protoFile): array |
115 | 118 | { |
116 | - return array_filter($this->files->getFiles(dirname($protoFile)), function ($file) { |
|
119 | + return array_filter($this->files->getFiles(dirname($protoFile)), function ($file) |
|
120 | + { |
|
117 | 121 | return strpos($file, '.proto') !== false; |
118 | 122 | }); |
119 | 123 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | use Spiral\Debug\Dumper; |
11 | 11 | |
12 | -if (!function_exists('bind')) { |
|
12 | +if (!function_exists('bind')){ |
|
13 | 13 | /** |
14 | 14 | * Shortcut to container Autowire definition. |
15 | 15 | * |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
30 | -if (!function_exists('dumprr')) { |
|
30 | +if (!function_exists('dumprr')){ |
|
31 | 31 | /** |
32 | 32 | * Dumprr is similar to Dump function but always redirect output to STDERR. |
33 | 33 | * |
@@ -9,7 +9,8 @@ discard block |
||
9 | 9 | |
10 | 10 | use Spiral\Debug\Dumper; |
11 | 11 | |
12 | -if (!function_exists('bind')) { |
|
12 | +if (!function_exists('bind')) |
|
13 | +{ |
|
13 | 14 | /** |
14 | 15 | * Shortcut to container Autowire definition. |
15 | 16 | * |
@@ -27,7 +28,8 @@ discard block |
||
27 | 28 | } |
28 | 29 | } |
29 | 30 | |
30 | -if (!function_exists('dumprr')) { |
|
31 | +if (!function_exists('dumprr')) |
|
32 | +{ |
|
31 | 33 | /** |
32 | 34 | * Dumprr is similar to Dump function but always redirect output to STDERR. |
33 | 35 | * |
@@ -41,7 +41,8 @@ |
||
41 | 41 | |
42 | 42 | $memory->saveData('cycle', $schema); |
43 | 43 | |
44 | - if ($show->hasChanges()) { |
|
44 | + if ($show->hasChanges()) |
|
45 | + { |
|
45 | 46 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
46 | 47 | } |
47 | 48 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | CycleBootloader $cycleBootloader, |
38 | 38 | Registry $registry, |
39 | 39 | MemoryInterface $memory |
40 | - ) { |
|
40 | + ){ |
|
41 | 41 | $show = new ShowChanges($this->output); |
42 | 42 | |
43 | 43 | $schema = (new Compiler())->compile( |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $memory->saveData('cycle', $schema); |
49 | 49 | |
50 | - if ($show->hasChanges()) { |
|
50 | + if ($show->hasChanges()){ |
|
51 | 51 | $this->writeln("\n<info>ORM Schema has been synchronized</info>"); |
52 | 52 | } |
53 | 53 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | string $clientFilename = null, |
27 | 27 | string $clientMediaType = null |
28 | 28 | ): UploadedFileInterface { |
29 | - if ($size === null) { |
|
29 | + if ($size === null){ |
|
30 | 30 | $size = $stream->getSize(); |
31 | 31 | } |
32 | 32 |
@@ -26,7 +26,8 @@ |
||
26 | 26 | string $clientFilename = null, |
27 | 27 | string $clientMediaType = null |
28 | 28 | ): UploadedFileInterface { |
29 | - if ($size === null) { |
|
29 | + if ($size === null) |
|
30 | + { |
|
30 | 31 | $size = $stream->getSize(); |
31 | 32 | } |
32 | 33 |
@@ -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 |
@@ -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 | } |
@@ -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>"); |