@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | EnvironmentInterface $env, |
45 | 45 | FinalizerInterface $finalizer, |
46 | 46 | ContainerInterface $container |
47 | - ) { |
|
47 | + ){ |
|
48 | 48 | $this->env = $env; |
49 | 49 | $this->finalizer = $finalizer; |
50 | 50 | $this->container = $container; |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | /** @var Console $console */ |
74 | 74 | $console = $this->container->get(Console::class); |
75 | 75 | |
76 | - try { |
|
76 | + try{ |
|
77 | 77 | $console->start($input ?? new ArgvInput(), $output); |
78 | - } catch (\Throwable $e) { |
|
78 | + }catch (\Throwable $e){ |
|
79 | 79 | $this->handleException($e, $output); |
80 | - } finally { |
|
80 | + }finally{ |
|
81 | 81 | $listener->disable(); |
82 | 82 | $this->finalizer->finalize(false); |
83 | 83 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function handleException(\Throwable $e, OutputInterface $output) |
91 | 91 | { |
92 | - try { |
|
92 | + try{ |
|
93 | 93 | $this->container->get(SnapshotterInterface::class)->register($e); |
94 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
94 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
95 | 95 | // no need to notify when unable to register an exception |
96 | 96 | } |
97 | 97 | |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | */ |
107 | 107 | private function mapVerbosity(OutputInterface $output): int |
108 | 108 | { |
109 | - if ($output->isDebug()) { |
|
109 | + if ($output->isDebug()){ |
|
110 | 110 | return ConsoleHandler::VERBOSITY_DEBUG; |
111 | 111 | } |
112 | 112 | |
113 | - if ($output->isVeryVerbose()) { |
|
113 | + if ($output->isVeryVerbose()){ |
|
114 | 114 | return ConsoleHandler::VERBOSITY_VERBOSE; |
115 | 115 | } |
116 | 116 |
@@ -73,11 +73,16 @@ discard block |
||
73 | 73 | /** @var Console $console */ |
74 | 74 | $console = $this->container->get(Console::class); |
75 | 75 | |
76 | - try { |
|
76 | + try |
|
77 | + { |
|
77 | 78 | $console->start($input ?? new ArgvInput(), $output); |
78 | - } catch (\Throwable $e) { |
|
79 | + } |
|
80 | + catch (\Throwable $e) |
|
81 | + { |
|
79 | 82 | $this->handleException($e, $output); |
80 | - } finally { |
|
83 | + } |
|
84 | + finally |
|
85 | + { |
|
81 | 86 | $listener->disable(); |
82 | 87 | $this->finalizer->finalize(false); |
83 | 88 | } |
@@ -89,9 +94,12 @@ discard block |
||
89 | 94 | */ |
90 | 95 | protected function handleException(\Throwable $e, OutputInterface $output) |
91 | 96 | { |
92 | - try { |
|
97 | + try |
|
98 | + { |
|
93 | 99 | $this->container->get(SnapshotterInterface::class)->register($e); |
94 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
100 | + } |
|
101 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
102 | + { |
|
95 | 103 | // no need to notify when unable to register an exception |
96 | 104 | } |
97 | 105 | |
@@ -106,11 +114,13 @@ discard block |
||
106 | 114 | */ |
107 | 115 | private function mapVerbosity(OutputInterface $output): int |
108 | 116 | { |
109 | - if ($output->isDebug()) { |
|
117 | + if ($output->isDebug()) |
|
118 | + { |
|
110 | 119 | return ConsoleHandler::VERBOSITY_DEBUG; |
111 | 120 | } |
112 | 121 | |
113 | - if ($output->isVeryVerbose()) { |
|
122 | + if ($output->isVeryVerbose()) |
|
123 | + { |
|
114 | 124 | return ConsoleHandler::VERBOSITY_VERBOSE; |
115 | 125 | } |
116 | 126 |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | $this->output->writeln("<info>Detecting schema changes:</info>"); |
41 | 41 | |
42 | 42 | $this->changes = []; |
43 | - foreach ($registry->getIterator() as $e) { |
|
44 | - if ($registry->hasTable($e)) { |
|
43 | + foreach ($registry->getIterator() as $e){ |
|
44 | + if ($registry->hasTable($e)){ |
|
45 | 45 | $table = $registry->getTableSchema($e); |
46 | 46 | |
47 | - if ($table->getComparator()->hasChanges()) { |
|
47 | + if ($table->getComparator()->hasChanges()){ |
|
48 | 48 | $this->changes[] = [ |
49 | 49 | 'database' => $registry->getDatabase($e), |
50 | 50 | 'table' => $registry->getTable($e), |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - if ($this->changes === []) { |
|
57 | + if ($this->changes === []){ |
|
58 | 58 | $this->output->writeln("<fg=yellow>no database changes has been detected</fg=yellow>"); |
59 | 59 | |
60 | 60 | return $registry; |
61 | 61 | } |
62 | 62 | |
63 | - foreach ($this->changes as $change) { |
|
63 | + foreach ($this->changes as $change){ |
|
64 | 64 | $this->output->write(sprintf("• <fg=cyan>%s.%s</fg=cyan>", $change['database'], $change['table'])); |
65 | 65 | $this->describeChanges($change['schema']); |
66 | 66 | } |
@@ -73,22 +73,22 @@ discard block |
||
73 | 73 | */ |
74 | 74 | protected function describeChanges(AbstractTable $table) |
75 | 75 | { |
76 | - if (!$this->output->isVerbose()) { |
|
76 | + if (!$this->output->isVerbose()){ |
|
77 | 77 | $this->output->writeln(sprintf( |
78 | 78 | ": <fg=green>%s</fg=green> change(s) detected", |
79 | 79 | $this->numChanges($table) |
80 | 80 | )); |
81 | 81 | |
82 | 82 | return; |
83 | - } else { |
|
83 | + }else{ |
|
84 | 84 | $this->output->write("\n"); |
85 | 85 | } |
86 | 86 | |
87 | - if (!$table->exists()) { |
|
87 | + if (!$table->exists()){ |
|
88 | 88 | $this->output->writeln(" - create table"); |
89 | 89 | } |
90 | 90 | |
91 | - if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
|
91 | + if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED){ |
|
92 | 92 | $this->output->writeln(" - drop table"); |
93 | 93 | return; |
94 | 94 | } |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function describeColumns(Comparator $cmp) |
107 | 107 | { |
108 | - foreach ($cmp->addedColumns() as $column) { |
|
108 | + foreach ($cmp->addedColumns() as $column){ |
|
109 | 109 | $this->output->writeln(" - add column <fg=yellow>{$column->getName()}</fg=yellow>"); |
110 | 110 | } |
111 | 111 | |
112 | - foreach ($cmp->droppedColumns() as $column) { |
|
112 | + foreach ($cmp->droppedColumns() as $column){ |
|
113 | 113 | $this->output->writeln(" - drop column <fg=yellow>{$column->getName()}</fg=yellow>"); |
114 | 114 | } |
115 | 115 | |
116 | - foreach ($cmp->alteredColumns() as $column) { |
|
116 | + foreach ($cmp->alteredColumns() as $column){ |
|
117 | 117 | $column = $column[0]; |
118 | 118 | $this->output->writeln(" - alter column <fg=yellow>{$column->getName()}</fg=yellow>"); |
119 | 119 | } |
@@ -124,17 +124,17 @@ discard block |
||
124 | 124 | */ |
125 | 125 | protected function describeIndexes(Comparator $cmp) |
126 | 126 | { |
127 | - foreach ($cmp->addedIndexes() as $index) { |
|
127 | + foreach ($cmp->addedIndexes() as $index){ |
|
128 | 128 | $index = join(', ', $index->getColumns()); |
129 | 129 | $this->output->writeln(" - add index on <fg=yellow>[{$index}]</fg=yellow>"); |
130 | 130 | } |
131 | 131 | |
132 | - foreach ($cmp->droppedIndexes() as $index) { |
|
132 | + foreach ($cmp->droppedIndexes() as $index){ |
|
133 | 133 | $index = join(', ', $index->getColumns()); |
134 | 134 | $this->output->writeln(" - drop index on <fg=yellow>[{$index}]</fg=yellow>"); |
135 | 135 | } |
136 | 136 | |
137 | - foreach ($cmp->alteredIndexes() as $index) { |
|
137 | + foreach ($cmp->alteredIndexes() as $index){ |
|
138 | 138 | $index = $index[0]; |
139 | 139 | $index = join(', ', $index->getColumns()); |
140 | 140 | $this->output->writeln(" - alter index on <fg=yellow>[{$index}]</fg=yellow>"); |
@@ -146,17 +146,17 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function describeFKs(Comparator $cmp) |
148 | 148 | { |
149 | - foreach ($cmp->addedForeignKeys() as $fk) { |
|
149 | + foreach ($cmp->addedForeignKeys() as $fk){ |
|
150 | 150 | $fkColumns = join(', ', $fk->getColumns()); |
151 | 151 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fkColumns}</fg=yellow>"); |
152 | 152 | } |
153 | 153 | |
154 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
154 | + foreach ($cmp->droppedForeignKeys() as $fk){ |
|
155 | 155 | $fkColumns = join(', ', $fk->getColumns()); |
156 | 156 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
157 | 157 | } |
158 | 158 | |
159 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
159 | + foreach ($cmp->alteredForeignKeys() as $fk){ |
|
160 | 160 | $fk = $fk[0]; |
161 | 161 | $fkColumns = join(', ', $fk->getColumns()); |
162 | 162 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
@@ -40,11 +40,14 @@ discard block |
||
40 | 40 | $this->output->writeln("<info>Detecting schema changes:</info>"); |
41 | 41 | |
42 | 42 | $this->changes = []; |
43 | - foreach ($registry->getIterator() as $e) { |
|
44 | - if ($registry->hasTable($e)) { |
|
43 | + foreach ($registry->getIterator() as $e) |
|
44 | + { |
|
45 | + if ($registry->hasTable($e)) |
|
46 | + { |
|
45 | 47 | $table = $registry->getTableSchema($e); |
46 | 48 | |
47 | - if ($table->getComparator()->hasChanges()) { |
|
49 | + if ($table->getComparator()->hasChanges()) |
|
50 | + { |
|
48 | 51 | $this->changes[] = [ |
49 | 52 | 'database' => $registry->getDatabase($e), |
50 | 53 | 'table' => $registry->getTable($e), |
@@ -54,13 +57,15 @@ discard block |
||
54 | 57 | } |
55 | 58 | } |
56 | 59 | |
57 | - if ($this->changes === []) { |
|
60 | + if ($this->changes === []) |
|
61 | + { |
|
58 | 62 | $this->output->writeln("<fg=yellow>no database changes has been detected</fg=yellow>"); |
59 | 63 | |
60 | 64 | return $registry; |
61 | 65 | } |
62 | 66 | |
63 | - foreach ($this->changes as $change) { |
|
67 | + foreach ($this->changes as $change) |
|
68 | + { |
|
64 | 69 | $this->output->write(sprintf("• <fg=cyan>%s.%s</fg=cyan>", $change['database'], $change['table'])); |
65 | 70 | $this->describeChanges($change['schema']); |
66 | 71 | } |
@@ -73,22 +78,27 @@ discard block |
||
73 | 78 | */ |
74 | 79 | protected function describeChanges(AbstractTable $table) |
75 | 80 | { |
76 | - if (!$this->output->isVerbose()) { |
|
81 | + if (!$this->output->isVerbose()) |
|
82 | + { |
|
77 | 83 | $this->output->writeln(sprintf( |
78 | 84 | ": <fg=green>%s</fg=green> change(s) detected", |
79 | 85 | $this->numChanges($table) |
80 | 86 | )); |
81 | 87 | |
82 | 88 | return; |
83 | - } else { |
|
89 | + } |
|
90 | + else |
|
91 | + { |
|
84 | 92 | $this->output->write("\n"); |
85 | 93 | } |
86 | 94 | |
87 | - if (!$table->exists()) { |
|
95 | + if (!$table->exists()) |
|
96 | + { |
|
88 | 97 | $this->output->writeln(" - create table"); |
89 | 98 | } |
90 | 99 | |
91 | - if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
|
100 | + if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) |
|
101 | + { |
|
92 | 102 | $this->output->writeln(" - drop table"); |
93 | 103 | return; |
94 | 104 | } |
@@ -105,15 +115,18 @@ discard block |
||
105 | 115 | */ |
106 | 116 | protected function describeColumns(Comparator $cmp) |
107 | 117 | { |
108 | - foreach ($cmp->addedColumns() as $column) { |
|
118 | + foreach ($cmp->addedColumns() as $column) |
|
119 | + { |
|
109 | 120 | $this->output->writeln(" - add column <fg=yellow>{$column->getName()}</fg=yellow>"); |
110 | 121 | } |
111 | 122 | |
112 | - foreach ($cmp->droppedColumns() as $column) { |
|
123 | + foreach ($cmp->droppedColumns() as $column) |
|
124 | + { |
|
113 | 125 | $this->output->writeln(" - drop column <fg=yellow>{$column->getName()}</fg=yellow>"); |
114 | 126 | } |
115 | 127 | |
116 | - foreach ($cmp->alteredColumns() as $column) { |
|
128 | + foreach ($cmp->alteredColumns() as $column) |
|
129 | + { |
|
117 | 130 | $column = $column[0]; |
118 | 131 | $this->output->writeln(" - alter column <fg=yellow>{$column->getName()}</fg=yellow>"); |
119 | 132 | } |
@@ -124,17 +137,20 @@ discard block |
||
124 | 137 | */ |
125 | 138 | protected function describeIndexes(Comparator $cmp) |
126 | 139 | { |
127 | - foreach ($cmp->addedIndexes() as $index) { |
|
140 | + foreach ($cmp->addedIndexes() as $index) |
|
141 | + { |
|
128 | 142 | $index = join(', ', $index->getColumns()); |
129 | 143 | $this->output->writeln(" - add index on <fg=yellow>[{$index}]</fg=yellow>"); |
130 | 144 | } |
131 | 145 | |
132 | - foreach ($cmp->droppedIndexes() as $index) { |
|
146 | + foreach ($cmp->droppedIndexes() as $index) |
|
147 | + { |
|
133 | 148 | $index = join(', ', $index->getColumns()); |
134 | 149 | $this->output->writeln(" - drop index on <fg=yellow>[{$index}]</fg=yellow>"); |
135 | 150 | } |
136 | 151 | |
137 | - foreach ($cmp->alteredIndexes() as $index) { |
|
152 | + foreach ($cmp->alteredIndexes() as $index) |
|
153 | + { |
|
138 | 154 | $index = $index[0]; |
139 | 155 | $index = join(', ', $index->getColumns()); |
140 | 156 | $this->output->writeln(" - alter index on <fg=yellow>[{$index}]</fg=yellow>"); |
@@ -146,17 +162,20 @@ discard block |
||
146 | 162 | */ |
147 | 163 | protected function describeFKs(Comparator $cmp) |
148 | 164 | { |
149 | - foreach ($cmp->addedForeignKeys() as $fk) { |
|
165 | + foreach ($cmp->addedForeignKeys() as $fk) |
|
166 | + { |
|
150 | 167 | $fkColumns = join(', ', $fk->getColumns()); |
151 | 168 | $this->output->writeln(" - add foreign key on <fg=yellow>{$fkColumns}</fg=yellow>"); |
152 | 169 | } |
153 | 170 | |
154 | - foreach ($cmp->droppedForeignKeys() as $fk) { |
|
171 | + foreach ($cmp->droppedForeignKeys() as $fk) |
|
172 | + { |
|
155 | 173 | $fkColumns = join(', ', $fk->getColumns()); |
156 | 174 | $this->output->writeln(" - drop foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
157 | 175 | } |
158 | 176 | |
159 | - foreach ($cmp->alteredForeignKeys() as $fk) { |
|
177 | + foreach ($cmp->alteredForeignKeys() as $fk) |
|
178 | + { |
|
160 | 179 | $fk = $fk[0]; |
161 | 180 | $fkColumns = join(', ', $fk->getColumns()); |
162 | 181 | $this->output->writeln(" - alter foreign key <fg=yellow>{$fkColumns}</fg=yellow>"); |
@@ -40,21 +40,21 @@ discard block |
||
40 | 40 | { |
41 | 41 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
42 | 42 | |
43 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
43 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
44 | 44 | throw new BootException( |
45 | 45 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
46 | 46 | ); |
47 | 47 | } |
48 | 48 | |
49 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
49 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
50 | 50 | throw new BootException( |
51 | 51 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | - if ($parts[1] == 'unix') { |
|
55 | + if ($parts[1] == 'unix'){ |
|
56 | 56 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
57 | - } else { |
|
57 | + }else{ |
|
58 | 58 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
59 | 59 | } |
60 | 60 | |
@@ -69,25 +69,25 @@ discard block |
||
69 | 69 | { |
70 | 70 | $conn = $env->get('RR_RELAY', static::WORKER_DEFAULT); |
71 | 71 | |
72 | - if ($conn === 'pipes' || empty($conn)) { |
|
72 | + if ($conn === 'pipes' || empty($conn)){ |
|
73 | 73 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
74 | 74 | } |
75 | 75 | |
76 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
76 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)){ |
|
77 | 77 | throw new BootException( |
78 | 78 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
79 | 79 | ); |
80 | 80 | } |
81 | 81 | |
82 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
82 | + if (!in_array($parts[1], ['tcp', 'unix'])){ |
|
83 | 83 | throw new BootException( |
84 | 84 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
88 | - if ($parts[1] == 'unix') { |
|
88 | + if ($parts[1] == 'unix'){ |
|
89 | 89 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
90 | - } else { |
|
90 | + }else{ |
|
91 | 91 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
92 | 92 | } |
93 | 93 |
@@ -40,21 +40,26 @@ discard block |
||
40 | 40 | { |
41 | 41 | $conn = $env->get('RR_RPC', static::RPC_DEFAULT); |
42 | 42 | |
43 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
43 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
44 | + { |
|
44 | 45 | throw new BootException( |
45 | 46 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
46 | 47 | ); |
47 | 48 | } |
48 | 49 | |
49 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
50 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
51 | + { |
|
50 | 52 | throw new BootException( |
51 | 53 | "Unable to configure RPC connection, invalid DSN given `{$conn}`." |
52 | 54 | ); |
53 | 55 | } |
54 | 56 | |
55 | - if ($parts[1] == 'unix') { |
|
57 | + if ($parts[1] == 'unix') |
|
58 | + { |
|
56 | 59 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
57 | - } else { |
|
60 | + } |
|
61 | + else |
|
62 | + { |
|
58 | 63 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
59 | 64 | } |
60 | 65 | |
@@ -69,25 +74,31 @@ discard block |
||
69 | 74 | { |
70 | 75 | $conn = $env->get('RR_RELAY', static::WORKER_DEFAULT); |
71 | 76 | |
72 | - if ($conn === 'pipes' || empty($conn)) { |
|
77 | + if ($conn === 'pipes' || empty($conn)) |
|
78 | + { |
|
73 | 79 | return new Worker(new StreamRelay(STDIN, STDOUT)); |
74 | 80 | } |
75 | 81 | |
76 | - if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) { |
|
82 | + if (!preg_match('#^([a-z]+)://([^:]+):?(\d+)?$#i', $conn, $parts)) |
|
83 | + { |
|
77 | 84 | throw new BootException( |
78 | 85 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
79 | 86 | ); |
80 | 87 | } |
81 | 88 | |
82 | - if (!in_array($parts[1], ['tcp', 'unix'])) { |
|
89 | + if (!in_array($parts[1], ['tcp', 'unix'])) |
|
90 | + { |
|
83 | 91 | throw new BootException( |
84 | 92 | "Unable to configure Worker connection, invalid DSN given `{$conn}`." |
85 | 93 | ); |
86 | 94 | } |
87 | 95 | |
88 | - if ($parts[1] == 'unix') { |
|
96 | + if ($parts[1] == 'unix') |
|
97 | + { |
|
89 | 98 | $relay = new SocketRelay($parts[2], null, SocketRelay::SOCK_UNIX); |
90 | - } else { |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
91 | 102 | $relay = new SocketRelay($parts[2], (int)$parts[3], SocketRelay::SOCK_TCP); |
92 | 103 | } |
93 | 104 |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | $generator = new ContextGenerator($views->getContext()); |
34 | 34 | |
35 | 35 | $contexts = $generator->generate(); |
36 | - if (empty($contexts)) { |
|
36 | + if (empty($contexts)){ |
|
37 | 37 | $contexts[] = $views->getContext(); |
38 | 38 | } |
39 | 39 | |
40 | - foreach ($contexts as $context) { |
|
41 | - foreach ($views->getEngines() as $engine) { |
|
42 | - if ($engine instanceof NativeEngine) { |
|
40 | + foreach ($contexts as $context){ |
|
41 | + foreach ($views->getEngines() as $engine){ |
|
42 | + if ($engine instanceof NativeEngine){ |
|
43 | 43 | // no need to compile |
44 | 44 | continue; |
45 | 45 | } |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | $this->describeContext($context) ?? "default" |
64 | 64 | ); |
65 | 65 | |
66 | - foreach ($engine->getLoader()->list() as $path) { |
|
66 | + foreach ($engine->getLoader()->list() as $path){ |
|
67 | 67 | $start = microtime(true); |
68 | - try { |
|
68 | + try{ |
|
69 | 69 | $engine->reset($path, $context); |
70 | 70 | $engine->compile($path, $context); |
71 | 71 | |
72 | - if ($this->isVerbose()) { |
|
72 | + if ($this->isVerbose()){ |
|
73 | 73 | $this->sprintf("<info>•</info> %s", $path); |
74 | 74 | } |
75 | - } catch (\Throwable $e) { |
|
75 | + }catch (\Throwable $e){ |
|
76 | 76 | $this->renderError($path, $e); |
77 | 77 | continue; |
78 | - } finally { |
|
78 | + }finally{ |
|
79 | 79 | $this->renderElapsed($start); |
80 | 80 | } |
81 | 81 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $values = []; |
93 | 93 | |
94 | - foreach ($context->getDependencies() as $dependency) { |
|
94 | + foreach ($context->getDependencies() as $dependency){ |
|
95 | 95 | $values[] = sprintf( |
96 | 96 | "%s%s%s:%s%s%s", |
97 | 97 | Color::LIGHT_WHITE, |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function renderError(string $path, \Throwable $e): void |
125 | 125 | { |
126 | - if (!$this->isVerbose()) { |
|
126 | + if (!$this->isVerbose()){ |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | */ |
141 | 141 | private function renderSuccess(string $lastPath = null): void |
142 | 142 | { |
143 | - if (!$this->isVerbose()) { |
|
143 | + if (!$this->isVerbose()){ |
|
144 | 144 | return; |
145 | 145 | } |
146 | 146 | |
147 | - if ($lastPath === null) { |
|
147 | + if ($lastPath === null){ |
|
148 | 148 | $this->writeln("• no views found"); |
149 | 149 | } |
150 | 150 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function renderElapsed(float $start): void |
158 | 158 | { |
159 | - if (!$this->isVerbose()) { |
|
159 | + if (!$this->isVerbose()){ |
|
160 | 160 | return; |
161 | 161 | } |
162 | 162 |
@@ -33,13 +33,17 @@ discard block |
||
33 | 33 | $generator = new ContextGenerator($views->getContext()); |
34 | 34 | |
35 | 35 | $contexts = $generator->generate(); |
36 | - if (empty($contexts)) { |
|
36 | + if (empty($contexts)) |
|
37 | + { |
|
37 | 38 | $contexts[] = $views->getContext(); |
38 | 39 | } |
39 | 40 | |
40 | - foreach ($contexts as $context) { |
|
41 | - foreach ($views->getEngines() as $engine) { |
|
42 | - if ($engine instanceof NativeEngine) { |
|
41 | + foreach ($contexts as $context) |
|
42 | + { |
|
43 | + foreach ($views->getEngines() as $engine) |
|
44 | + { |
|
45 | + if ($engine instanceof NativeEngine) |
|
46 | + { |
|
43 | 47 | // no need to compile |
44 | 48 | continue; |
45 | 49 | } |
@@ -63,19 +67,26 @@ discard block |
||
63 | 67 | $this->describeContext($context) ?? "default" |
64 | 68 | ); |
65 | 69 | |
66 | - foreach ($engine->getLoader()->list() as $path) { |
|
70 | + foreach ($engine->getLoader()->list() as $path) |
|
71 | + { |
|
67 | 72 | $start = microtime(true); |
68 | - try { |
|
73 | + try |
|
74 | + { |
|
69 | 75 | $engine->reset($path, $context); |
70 | 76 | $engine->compile($path, $context); |
71 | 77 | |
72 | - if ($this->isVerbose()) { |
|
78 | + if ($this->isVerbose()) |
|
79 | + { |
|
73 | 80 | $this->sprintf("<info>•</info> %s", $path); |
74 | 81 | } |
75 | - } catch (\Throwable $e) { |
|
82 | + } |
|
83 | + catch (\Throwable $e) |
|
84 | + { |
|
76 | 85 | $this->renderError($path, $e); |
77 | 86 | continue; |
78 | - } finally { |
|
87 | + } |
|
88 | + finally |
|
89 | + { |
|
79 | 90 | $this->renderElapsed($start); |
80 | 91 | } |
81 | 92 | } |
@@ -91,7 +102,8 @@ discard block |
||
91 | 102 | { |
92 | 103 | $values = []; |
93 | 104 | |
94 | - foreach ($context->getDependencies() as $dependency) { |
|
105 | + foreach ($context->getDependencies() as $dependency) |
|
106 | + { |
|
95 | 107 | $values[] = sprintf( |
96 | 108 | "%s%s%s:%s%s%s", |
97 | 109 | Color::LIGHT_WHITE, |
@@ -123,7 +135,8 @@ discard block |
||
123 | 135 | */ |
124 | 136 | protected function renderError(string $path, \Throwable $e): void |
125 | 137 | { |
126 | - if (!$this->isVerbose()) { |
|
138 | + if (!$this->isVerbose()) |
|
139 | + { |
|
127 | 140 | return; |
128 | 141 | } |
129 | 142 | |
@@ -140,11 +153,13 @@ discard block |
||
140 | 153 | */ |
141 | 154 | private function renderSuccess(string $lastPath = null): void |
142 | 155 | { |
143 | - if (!$this->isVerbose()) { |
|
156 | + if (!$this->isVerbose()) |
|
157 | + { |
|
144 | 158 | return; |
145 | 159 | } |
146 | 160 | |
147 | - if ($lastPath === null) { |
|
161 | + if ($lastPath === null) |
|
162 | + { |
|
148 | 163 | $this->writeln("• no views found"); |
149 | 164 | } |
150 | 165 | |
@@ -156,7 +171,8 @@ discard block |
||
156 | 171 | */ |
157 | 172 | private function renderElapsed(float $start): void |
158 | 173 | { |
159 | - if (!$this->isVerbose()) { |
|
174 | + if (!$this->isVerbose()) |
|
175 | + { |
|
160 | 176 | return; |
161 | 177 | } |
162 | 178 |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function perform(FilesInterface $files) |
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) |
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([ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | FinalizerInterface $finalizer, |
47 | 47 | ContainerInterface $container, |
48 | 48 | FactoryInterface $factory |
49 | - ) { |
|
49 | + ){ |
|
50 | 50 | $this->env = $env; |
51 | 51 | $this->finalizer = $finalizer; |
52 | 52 | $this->container = $container; |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | |
71 | 71 | /** @var Http $http */ |
72 | 72 | $http = $this->container->get(Http::class); |
73 | - while ($request = $client->acceptRequest()) { |
|
74 | - try { |
|
73 | + while ($request = $client->acceptRequest()){ |
|
74 | + try{ |
|
75 | 75 | $client->respond($http->handle($request)); |
76 | - } catch (\Throwable $e) { |
|
76 | + }catch (\Throwable $e){ |
|
77 | 77 | $this->handleException($client, $e); |
78 | - } finally { |
|
78 | + }finally{ |
|
79 | 79 | $this->finalizer->finalize(false); |
80 | 80 | } |
81 | 81 | } |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | { |
90 | 90 | $handler = new HtmlHandler(); |
91 | 91 | |
92 | - try { |
|
92 | + try{ |
|
93 | 93 | /** @var SnapshotInterface $snapshot */ |
94 | 94 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
95 | 95 | error_log($snapshot->getMessage()); |
96 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
96 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
97 | 97 | error_log((string)$e); |
98 | 98 | } |
99 | 99 |
@@ -70,12 +70,18 @@ discard block |
||
70 | 70 | |
71 | 71 | /** @var Http $http */ |
72 | 72 | $http = $this->container->get(Http::class); |
73 | - while ($request = $client->acceptRequest()) { |
|
74 | - try { |
|
73 | + while ($request = $client->acceptRequest()) |
|
74 | + { |
|
75 | + try |
|
76 | + { |
|
75 | 77 | $client->respond($http->handle($request)); |
76 | - } catch (\Throwable $e) { |
|
78 | + } |
|
79 | + catch (\Throwable $e) |
|
80 | + { |
|
77 | 81 | $this->handleException($client, $e); |
78 | - } finally { |
|
82 | + } |
|
83 | + finally |
|
84 | + { |
|
79 | 85 | $this->finalizer->finalize(false); |
80 | 86 | } |
81 | 87 | } |
@@ -89,11 +95,14 @@ discard block |
||
89 | 95 | { |
90 | 96 | $handler = new HtmlHandler(); |
91 | 97 | |
92 | - try { |
|
98 | + try |
|
99 | + { |
|
93 | 100 | /** @var SnapshotInterface $snapshot */ |
94 | 101 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
95 | 102 | error_log($snapshot->getMessage()); |
96 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
103 | + } |
|
104 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
105 | + { |
|
97 | 106 | error_log((string)$e); |
98 | 107 | } |
99 | 108 |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | $http = $this->container->get(Http::class); |
58 | 58 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
59 | 59 | |
60 | - try { |
|
60 | + try{ |
|
61 | 61 | $response = $http->handle($this->initRequest()); |
62 | 62 | $emitter->emit($response); |
63 | - } catch (\Throwable $e) { |
|
63 | + }catch (\Throwable $e){ |
|
64 | 64 | $this->handleException($emitter, $e); |
65 | - } finally { |
|
65 | + }finally{ |
|
66 | 66 | $this->finalizer->finalize(false); |
67 | 67 | } |
68 | 68 | } |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | { |
84 | 84 | $handler = new HtmlHandler(); |
85 | 85 | |
86 | - try { |
|
86 | + try{ |
|
87 | 87 | /** @var SnapshotInterface $snapshot */ |
88 | 88 | $this->container->get(SnapshotterInterface::class)->register($e); |
89 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
89 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
90 | 90 | // nothing to report |
91 | 91 | } |
92 | 92 |
@@ -57,12 +57,17 @@ discard block |
||
57 | 57 | $http = $this->container->get(Http::class); |
58 | 58 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
59 | 59 | |
60 | - try { |
|
60 | + try |
|
61 | + { |
|
61 | 62 | $response = $http->handle($this->initRequest()); |
62 | 63 | $emitter->emit($response); |
63 | - } catch (\Throwable $e) { |
|
64 | + } |
|
65 | + catch (\Throwable $e) |
|
66 | + { |
|
64 | 67 | $this->handleException($emitter, $e); |
65 | - } finally { |
|
68 | + } |
|
69 | + finally |
|
70 | + { |
|
66 | 71 | $this->finalizer->finalize(false); |
67 | 72 | } |
68 | 73 | } |
@@ -83,10 +88,13 @@ discard block |
||
83 | 88 | { |
84 | 89 | $handler = new HtmlHandler(); |
85 | 90 | |
86 | - try { |
|
91 | + try |
|
92 | + { |
|
87 | 93 | /** @var SnapshotInterface $snapshot */ |
88 | 94 | $this->container->get(SnapshotterInterface::class)->register($e); |
89 | - } catch (\Throwable|ContainerExceptionInterface $se) { |
|
95 | + } |
|
96 | + catch (\Throwable|ContainerExceptionInterface $se) |
|
97 | + { |
|
90 | 98 | // nothing to report |
91 | 99 | } |
92 | 100 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | CycleBootloader $cycleBootloader, |
36 | 36 | Registry $registry, |
37 | 37 | MemoryInterface $memory |
38 | - ) { |
|
38 | + ){ |
|
39 | 39 | $this->write("Updating ORM schema... "); |
40 | 40 | |
41 | 41 | $schema = (new Compiler())->compile($registry, $bootloader->getGenerators()); |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | public function getGenerators(): array |
90 | 90 | { |
91 | 91 | $result = []; |
92 | - foreach ($this->generators as $group) { |
|
93 | - foreach ($group as $generator) { |
|
94 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
92 | + foreach ($this->generators as $group){ |
|
93 | + foreach ($group as $generator){ |
|
94 | + if (is_object($generator) && !$generator instanceof Container\Autowire){ |
|
95 | 95 | $result[] = $generator; |
96 | - } else { |
|
96 | + }else{ |
|
97 | 97 | $result[] = $this->container->get($generator); |
98 | 98 | } |
99 | 99 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
110 | 110 | { |
111 | 111 | $schema = $memory->loadData('cycle'); |
112 | - if (is_null($schema)) { |
|
112 | + if (is_null($schema)){ |
|
113 | 113 | return null; |
114 | 114 | } |
115 | 115 |
@@ -89,11 +89,16 @@ discard block |
||
89 | 89 | public function getGenerators(): array |
90 | 90 | { |
91 | 91 | $result = []; |
92 | - foreach ($this->generators as $group) { |
|
93 | - foreach ($group as $generator) { |
|
94 | - if (is_object($generator) && !$generator instanceof Container\Autowire) { |
|
92 | + foreach ($this->generators as $group) |
|
93 | + { |
|
94 | + foreach ($group as $generator) |
|
95 | + { |
|
96 | + if (is_object($generator) && !$generator instanceof Container\Autowire) |
|
97 | + { |
|
95 | 98 | $result[] = $generator; |
96 | - } else { |
|
99 | + } |
|
100 | + else |
|
101 | + { |
|
97 | 102 | $result[] = $this->container->get($generator); |
98 | 103 | } |
99 | 104 | } |
@@ -109,7 +114,8 @@ discard block |
||
109 | 114 | protected function schema(MemoryInterface $memory): ?SchemaInterface |
110 | 115 | { |
111 | 116 | $schema = $memory->loadData('cycle'); |
112 | - if (is_null($schema)) { |
|
117 | + if (is_null($schema)) |
|
118 | + { |
|
113 | 119 | return null; |
114 | 120 | } |
115 | 121 |