@@ -94,9 +94,9 @@ |
||
94 | 94 | */ |
95 | 95 | private function getAuthContext(): AuthContextInterface |
96 | 96 | { |
97 | - try { |
|
97 | + try{ |
|
98 | 98 | return $this->container->get(AuthContextInterface::class); |
99 | - } catch (NotFoundExceptionInterface $e) { |
|
99 | + }catch (NotFoundExceptionInterface $e){ |
|
100 | 100 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
101 | 101 | } |
102 | 102 | } |
@@ -94,9 +94,12 @@ |
||
94 | 94 | */ |
95 | 95 | private function getAuthContext(): AuthContextInterface |
96 | 96 | { |
97 | - try { |
|
97 | + try |
|
98 | + { |
|
98 | 99 | return $this->container->get(AuthContextInterface::class); |
99 | - } catch (NotFoundExceptionInterface $e) { |
|
100 | + } |
|
101 | + catch (NotFoundExceptionInterface $e) |
|
102 | + { |
|
100 | 103 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
101 | 104 | } |
102 | 105 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function load(string $id): ?TokenInterface |
48 | 48 | { |
49 | - if (strpos($id, ':') === false) { |
|
49 | + if (strpos($id, ':') === false){ |
|
50 | 50 | return null; |
51 | 51 | } |
52 | 52 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** @var Token $token */ |
56 | 56 | $token = $this->orm->getRepository(Token::class)->findByPK($pk); |
57 | 57 | |
58 | - if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))) { |
|
58 | + if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))){ |
|
59 | 59 | // hijacked or deleted |
60 | 60 | return null; |
61 | 61 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $token->setSecretValue($hash); |
64 | 64 | |
65 | 65 | $expiresAt = $token->getExpiresAt(); |
66 | - if ($expiresAt !== null && $expiresAt < new DateTimeImmutable()) { |
|
66 | + if ($expiresAt !== null && $expiresAt < new DateTimeImmutable()){ |
|
67 | 67 | $this->delete($token); |
68 | 68 | return null; |
69 | 69 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function create(array $payload, DateTimeInterface $expiresAt = null): TokenInterface |
78 | 78 | { |
79 | - try { |
|
79 | + try{ |
|
80 | 80 | $token = new Token( |
81 | 81 | $this->issueID(), |
82 | 82 | $this->randomHash(128), |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $this->em->run(); |
90 | 90 | |
91 | 91 | return $token; |
92 | - } catch (Throwable $e) { |
|
92 | + }catch (Throwable $e){ |
|
93 | 93 | throw new TokenStorageException('Unable to create token', $e->getCode(), $e); |
94 | 94 | } |
95 | 95 | } |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function delete(TokenInterface $token): void |
101 | 101 | { |
102 | - try { |
|
102 | + try{ |
|
103 | 103 | $this->em->delete($token); |
104 | 104 | $this->em->run(); |
105 | - } catch (Throwable $e) { |
|
105 | + }catch (Throwable $e){ |
|
106 | 106 | throw new TokenStorageException('Unable to delete token', $e->getCode(), $e); |
107 | 107 | } |
108 | 108 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | ->select() |
123 | 123 | ->from($this->orm->getSource(Token::class)->getTable()); |
124 | 124 | |
125 | - while ((clone $query)->where('id', $id)->count('id') !== 0) { |
|
125 | + while ((clone $query)->where('id', $id)->count('id') !== 0){ |
|
126 | 126 | $id = $this->randomHash(64); |
127 | 127 | } |
128 | 128 |
@@ -46,7 +46,8 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function load(string $id): ?TokenInterface |
48 | 48 | { |
49 | - if (strpos($id, ':') === false) { |
|
49 | + if (strpos($id, ':') === false) |
|
50 | + { |
|
50 | 51 | return null; |
51 | 52 | } |
52 | 53 | |
@@ -55,7 +56,8 @@ discard block |
||
55 | 56 | /** @var Token $token */ |
56 | 57 | $token = $this->orm->getRepository(Token::class)->findByPK($pk); |
57 | 58 | |
58 | - if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))) { |
|
59 | + if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))) |
|
60 | + { |
|
59 | 61 | // hijacked or deleted |
60 | 62 | return null; |
61 | 63 | } |
@@ -63,7 +65,8 @@ discard block |
||
63 | 65 | $token->setSecretValue($hash); |
64 | 66 | |
65 | 67 | $expiresAt = $token->getExpiresAt(); |
66 | - if ($expiresAt !== null && $expiresAt < new DateTimeImmutable()) { |
|
68 | + if ($expiresAt !== null && $expiresAt < new DateTimeImmutable()) |
|
69 | + { |
|
67 | 70 | $this->delete($token); |
68 | 71 | return null; |
69 | 72 | } |
@@ -76,7 +79,8 @@ discard block |
||
76 | 79 | */ |
77 | 80 | public function create(array $payload, DateTimeInterface $expiresAt = null): TokenInterface |
78 | 81 | { |
79 | - try { |
|
82 | + try |
|
83 | + { |
|
80 | 84 | $token = new Token( |
81 | 85 | $this->issueID(), |
82 | 86 | $this->randomHash(128), |
@@ -89,7 +93,9 @@ discard block |
||
89 | 93 | $this->em->run(); |
90 | 94 | |
91 | 95 | return $token; |
92 | - } catch (Throwable $e) { |
|
96 | + } |
|
97 | + catch (Throwable $e) |
|
98 | + { |
|
93 | 99 | throw new TokenStorageException('Unable to create token', $e->getCode(), $e); |
94 | 100 | } |
95 | 101 | } |
@@ -99,10 +105,13 @@ discard block |
||
99 | 105 | */ |
100 | 106 | public function delete(TokenInterface $token): void |
101 | 107 | { |
102 | - try { |
|
108 | + try |
|
109 | + { |
|
103 | 110 | $this->em->delete($token); |
104 | 111 | $this->em->run(); |
105 | - } catch (Throwable $e) { |
|
112 | + } |
|
113 | + catch (Throwable $e) |
|
114 | + { |
|
106 | 115 | throw new TokenStorageException('Unable to delete token', $e->getCode(), $e); |
107 | 116 | } |
108 | 117 | } |
@@ -122,7 +131,8 @@ discard block |
||
122 | 131 | ->select() |
123 | 132 | ->from($this->orm->getSource(Token::class)->getTable()); |
124 | 133 | |
125 | - while ((clone $query)->where('id', $id)->count('id') !== 0) { |
|
134 | + while ((clone $query)->where('id', $id)->count('id') !== 0) |
|
135 | + { |
|
126 | 136 | $id = $this->randomHash(64); |
127 | 137 | } |
128 | 138 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | array $payload, |
52 | 52 | DateTimeInterface $createdAt, |
53 | 53 | DateTimeInterface $expiresAt = null |
54 | - ) { |
|
54 | + ){ |
|
55 | 55 | $this->id = $id; |
56 | 56 | |
57 | 57 | $this->secretValue = $secretValue; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function getPayload(): array |
110 | 110 | { |
111 | - if (is_resource($this->payload)) { |
|
111 | + if (is_resource($this->payload)){ |
|
112 | 112 | // postgres |
113 | 113 | return json_decode(stream_get_contents($this->payload), true); |
114 | 114 | } |
@@ -108,7 +108,8 @@ |
||
108 | 108 | */ |
109 | 109 | public function getPayload(): array |
110 | 110 | { |
111 | - if (is_resource($this->payload)) { |
|
111 | + if (is_resource($this->payload)) |
|
112 | + { |
|
112 | 113 | // postgres |
113 | 114 | return json_decode(stream_get_contents($this->payload), true); |
114 | 115 | } |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function load(string $id): ?TokenInterface |
45 | 45 | { |
46 | - try { |
|
46 | + try{ |
|
47 | 47 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
48 | - if ($tokenData === null) { |
|
48 | + if ($tokenData === null){ |
|
49 | 49 | return null; |
50 | 50 | } |
51 | 51 | |
52 | 52 | $token = Token::unpack($tokenData); |
53 | - } catch (Throwable $e) { |
|
53 | + }catch (Throwable $e){ |
|
54 | 54 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
55 | 55 | } |
56 | 56 | |
57 | - if (!hash_equals($token->getID(), $id)) { |
|
57 | + if (!hash_equals($token->getID(), $id)){ |
|
58 | 58 | return null; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $expiresAt = $token->getExpiresAt(); |
62 | - if ($expiresAt !== null && $expiresAt < new DateTimeImmutable()) { |
|
62 | + if ($expiresAt !== null && $expiresAt < new DateTimeImmutable()){ |
|
63 | 63 | $this->delete($token); |
64 | 64 | return null; |
65 | 65 | } |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function create(array $payload, DateTimeInterface $expiresAt = null): TokenInterface |
74 | 74 | { |
75 | - try { |
|
75 | + try{ |
|
76 | 76 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
77 | 77 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
78 | 78 | |
79 | 79 | return $token; |
80 | - } catch (Throwable $e) { |
|
80 | + }catch (Throwable $e){ |
|
81 | 81 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
82 | 82 | } |
83 | 83 | } |
@@ -43,23 +43,29 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function load(string $id): ?TokenInterface |
45 | 45 | { |
46 | - try { |
|
46 | + try |
|
47 | + { |
|
47 | 48 | $tokenData = $this->session->getSection(self::SESSION_SECTION)->get('token'); |
48 | - if ($tokenData === null) { |
|
49 | + if ($tokenData === null) |
|
50 | + { |
|
49 | 51 | return null; |
50 | 52 | } |
51 | 53 | |
52 | 54 | $token = Token::unpack($tokenData); |
53 | - } catch (Throwable $e) { |
|
55 | + } |
|
56 | + catch (Throwable $e) |
|
57 | + { |
|
54 | 58 | throw new TokenStorageException('Unable to load session token', $e->getCode(), $e); |
55 | 59 | } |
56 | 60 | |
57 | - if (!hash_equals($token->getID(), $id)) { |
|
61 | + if (!hash_equals($token->getID(), $id)) |
|
62 | + { |
|
58 | 63 | return null; |
59 | 64 | } |
60 | 65 | |
61 | 66 | $expiresAt = $token->getExpiresAt(); |
62 | - if ($expiresAt !== null && $expiresAt < new DateTimeImmutable()) { |
|
67 | + if ($expiresAt !== null && $expiresAt < new DateTimeImmutable()) |
|
68 | + { |
|
63 | 69 | $this->delete($token); |
64 | 70 | return null; |
65 | 71 | } |
@@ -72,12 +78,15 @@ discard block |
||
72 | 78 | */ |
73 | 79 | public function create(array $payload, DateTimeInterface $expiresAt = null): TokenInterface |
74 | 80 | { |
75 | - try { |
|
81 | + try |
|
82 | + { |
|
76 | 83 | $token = new Token($this->randomHash(128), $payload, $expiresAt); |
77 | 84 | $this->session->getSection(self::SESSION_SECTION)->set('token', $token->pack()); |
78 | 85 | |
79 | 86 | return $token; |
80 | - } catch (Throwable $e) { |
|
87 | + } |
|
88 | + catch (Throwable $e) |
|
89 | + { |
|
81 | 90 | throw new TokenStorageException('Unable to create session token', $e->getCode(), $e); |
82 | 91 | } |
83 | 92 | } |
@@ -87,7 +87,7 @@ |
||
87 | 87 | public static function unpack(array $data): Token |
88 | 88 | { |
89 | 89 | $expiresAt = null; |
90 | - if ($data['expiresAt'] !== null) { |
|
90 | + if ($data['expiresAt'] !== null){ |
|
91 | 91 | $expiresAt = (new DateTimeImmutable())->setTimestamp($data['expiresAt']); |
92 | 92 | } |
93 | 93 |
@@ -87,7 +87,8 @@ |
||
87 | 87 | public static function unpack(array $data): Token |
88 | 88 | { |
89 | 89 | $expiresAt = null; |
90 | - if ($data['expiresAt'] !== null) { |
|
90 | + if ($data['expiresAt'] !== null) |
|
91 | + { |
|
91 | 92 | $expiresAt = (new DateTimeImmutable())->setTimestamp($data['expiresAt']); |
92 | 93 | } |
93 | 94 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $database = $dbal->database($this->option('database')); |
45 | 45 | $schema = $database->table($this->argument('table'))->getSchema(); |
46 | 46 | |
47 | - if (!$schema->exists()) { |
|
47 | + if (!$schema->exists()){ |
|
48 | 48 | throw new DBALException( |
49 | 49 | "Table {$database->getName()}.{$this->argument('table')} does not exists." |
50 | 50 | ); |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | |
59 | 59 | $this->describeColumns($schema); |
60 | 60 | |
61 | - if (!empty($indexes = $schema->getIndexes())) { |
|
61 | + if (!empty($indexes = $schema->getIndexes())){ |
|
62 | 62 | $this->describeIndexes($database, $indexes); |
63 | 63 | } |
64 | 64 | |
65 | - if (!empty($foreignKeys = $schema->getForeignKeys())) { |
|
65 | + if (!empty($foreignKeys = $schema->getForeignKeys())){ |
|
66 | 66 | $this->describeForeignKeys($database, $foreignKeys); |
67 | 67 | } |
68 | 68 | |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | ] |
85 | 85 | ); |
86 | 86 | |
87 | - foreach ($schema->getColumns() as $column) { |
|
87 | + foreach ($schema->getColumns() as $column){ |
|
88 | 88 | $name = $column->getName(); |
89 | 89 | |
90 | - if (in_array($column->getName(), $schema->getPrimaryKeys(), true)) { |
|
90 | + if (in_array($column->getName(), $schema->getPrimaryKeys(), true)){ |
|
91 | 91 | $name = "<fg=magenta>{$name}</fg=magenta>"; |
92 | 92 | } |
93 | 93 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ); |
121 | 121 | |
122 | 122 | $indexesTable = $this->table(['Name:', 'Type:', 'Columns:']); |
123 | - foreach ($indexes as $index) { |
|
123 | + foreach ($indexes as $index){ |
|
124 | 124 | $indexesTable->addRow( |
125 | 125 | [ |
126 | 126 | $index->getName(), |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | ] |
156 | 156 | ); |
157 | 157 | |
158 | - foreach ($foreignKeys as $reference) { |
|
158 | + foreach ($foreignKeys as $reference){ |
|
159 | 159 | $foreignTable->addRow( |
160 | 160 | [ |
161 | 161 | $reference->getName(), |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | { |
181 | 181 | $defaultValue = $column->getDefaultValue(); |
182 | 182 | |
183 | - if ($defaultValue instanceof FragmentInterface) { |
|
183 | + if ($defaultValue instanceof FragmentInterface){ |
|
184 | 184 | $value = $driver->getQueryCompiler()->compile(new QueryParameters(), '', $defaultValue); |
185 | 185 | |
186 | 186 | return "<info>{$value}</info>"; |
187 | 187 | } |
188 | 188 | |
189 | - if ($defaultValue instanceof \DateTimeInterface) { |
|
189 | + if ($defaultValue instanceof \DateTimeInterface){ |
|
190 | 190 | $defaultValue = $defaultValue->format('c'); |
191 | 191 | } |
192 | 192 | |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | |
204 | 204 | $abstractType = $column->getAbstractType(); |
205 | 205 | |
206 | - if ($column->getSize()) { |
|
206 | + if ($column->getSize()){ |
|
207 | 207 | $type .= " ({$column->getSize()})"; |
208 | 208 | } |
209 | 209 | |
210 | - if ($abstractType === 'decimal') { |
|
210 | + if ($abstractType === 'decimal'){ |
|
211 | 211 | $type .= " ({$column->getPrecision()}, {$column->getScale()})"; |
212 | 212 | } |
213 | 213 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | { |
223 | 223 | $abstractType = $column->getAbstractType(); |
224 | 224 | |
225 | - if (in_array($abstractType, ['primary', 'bigPrimary'])) { |
|
225 | + if (in_array($abstractType, ['primary', 'bigPrimary'])){ |
|
226 | 226 | $abstractType = "<fg=magenta>{$abstractType}</fg=magenta>"; |
227 | 227 | } |
228 | 228 |
@@ -44,7 +44,8 @@ discard block |
||
44 | 44 | $database = $dbal->database($this->option('database')); |
45 | 45 | $schema = $database->table($this->argument('table'))->getSchema(); |
46 | 46 | |
47 | - if (!$schema->exists()) { |
|
47 | + if (!$schema->exists()) |
|
48 | + { |
|
48 | 49 | throw new DBALException( |
49 | 50 | "Table {$database->getName()}.{$this->argument('table')} does not exists." |
50 | 51 | ); |
@@ -58,11 +59,13 @@ discard block |
||
58 | 59 | |
59 | 60 | $this->describeColumns($schema); |
60 | 61 | |
61 | - if (!empty($indexes = $schema->getIndexes())) { |
|
62 | + if (!empty($indexes = $schema->getIndexes())) |
|
63 | + { |
|
62 | 64 | $this->describeIndexes($database, $indexes); |
63 | 65 | } |
64 | 66 | |
65 | - if (!empty($foreignKeys = $schema->getForeignKeys())) { |
|
67 | + if (!empty($foreignKeys = $schema->getForeignKeys())) |
|
68 | + { |
|
66 | 69 | $this->describeForeignKeys($database, $foreignKeys); |
67 | 70 | } |
68 | 71 | |
@@ -84,10 +87,12 @@ discard block |
||
84 | 87 | ] |
85 | 88 | ); |
86 | 89 | |
87 | - foreach ($schema->getColumns() as $column) { |
|
90 | + foreach ($schema->getColumns() as $column) |
|
91 | + { |
|
88 | 92 | $name = $column->getName(); |
89 | 93 | |
90 | - if (in_array($column->getName(), $schema->getPrimaryKeys(), true)) { |
|
94 | + if (in_array($column->getName(), $schema->getPrimaryKeys(), true)) |
|
95 | + { |
|
91 | 96 | $name = "<fg=magenta>{$name}</fg=magenta>"; |
92 | 97 | } |
93 | 98 | |
@@ -120,7 +125,8 @@ discard block |
||
120 | 125 | ); |
121 | 126 | |
122 | 127 | $indexesTable = $this->table(['Name:', 'Type:', 'Columns:']); |
123 | - foreach ($indexes as $index) { |
|
128 | + foreach ($indexes as $index) |
|
129 | + { |
|
124 | 130 | $indexesTable->addRow( |
125 | 131 | [ |
126 | 132 | $index->getName(), |
@@ -155,7 +161,8 @@ discard block |
||
155 | 161 | ] |
156 | 162 | ); |
157 | 163 | |
158 | - foreach ($foreignKeys as $reference) { |
|
164 | + foreach ($foreignKeys as $reference) |
|
165 | + { |
|
159 | 166 | $foreignTable->addRow( |
160 | 167 | [ |
161 | 168 | $reference->getName(), |
@@ -180,13 +187,15 @@ discard block |
||
180 | 187 | { |
181 | 188 | $defaultValue = $column->getDefaultValue(); |
182 | 189 | |
183 | - if ($defaultValue instanceof FragmentInterface) { |
|
190 | + if ($defaultValue instanceof FragmentInterface) |
|
191 | + { |
|
184 | 192 | $value = $driver->getQueryCompiler()->compile(new QueryParameters(), '', $defaultValue); |
185 | 193 | |
186 | 194 | return "<info>{$value}</info>"; |
187 | 195 | } |
188 | 196 | |
189 | - if ($defaultValue instanceof \DateTimeInterface) { |
|
197 | + if ($defaultValue instanceof \DateTimeInterface) |
|
198 | + { |
|
190 | 199 | $defaultValue = $defaultValue->format('c'); |
191 | 200 | } |
192 | 201 | |
@@ -203,11 +212,13 @@ discard block |
||
203 | 212 | |
204 | 213 | $abstractType = $column->getAbstractType(); |
205 | 214 | |
206 | - if ($column->getSize()) { |
|
215 | + if ($column->getSize()) |
|
216 | + { |
|
207 | 217 | $type .= " ({$column->getSize()})"; |
208 | 218 | } |
209 | 219 | |
210 | - if ($abstractType === 'decimal') { |
|
220 | + if ($abstractType === 'decimal') |
|
221 | + { |
|
211 | 222 | $type .= " ({$column->getPrecision()}, {$column->getScale()})"; |
212 | 223 | } |
213 | 224 | |
@@ -222,7 +233,8 @@ discard block |
||
222 | 233 | { |
223 | 234 | $abstractType = $column->getAbstractType(); |
224 | 235 | |
225 | - if (in_array($abstractType, ['primary', 'bigPrimary'])) { |
|
236 | + if (in_array($abstractType, ['primary', 'bigPrimary'])) |
|
237 | + { |
|
226 | 238 | $abstractType = "<fg=magenta>{$abstractType}</fg=magenta>"; |
227 | 239 | } |
228 | 240 |
@@ -43,7 +43,7 @@ |
||
43 | 43 | |
44 | 44 | if (!$schema->exists()) { |
45 | 45 | throw new DBALException( |
46 | - "Table {$database->getName()}.{$this->argument('table')} does not exists." |
|
46 | + "table {$database->getName()}.{$this->argument('table')} does not exists." |
|
47 | 47 | ); |
48 | 48 | } |
49 | 49 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function perform(Console $console): void |
29 | 29 | { |
30 | - if (!$this->verifyEnvironment()) { |
|
30 | + if (!$this->verifyEnvironment()){ |
|
31 | 31 | //Making sure we can safely migrate in this environment |
32 | 32 | return; |
33 | 33 | } |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | $rollback = ['--force' => true]; |
36 | 36 | $migrate = ['--force' => true]; |
37 | 37 | |
38 | - if ($this->option('all')) { |
|
38 | + if ($this->option('all')){ |
|
39 | 39 | $rollback['--all'] = true; |
40 | - } else { |
|
40 | + }else{ |
|
41 | 41 | $migrate['--one'] = true; |
42 | 42 | } |
43 | 43 |
@@ -27,7 +27,8 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function perform(Console $console): void |
29 | 29 | { |
30 | - if (!$this->verifyEnvironment()) { |
|
30 | + if (!$this->verifyEnvironment()) |
|
31 | + { |
|
31 | 32 | //Making sure we can safely migrate in this environment |
32 | 33 | return; |
33 | 34 | } |
@@ -35,9 +36,12 @@ discard block |
||
35 | 36 | $rollback = ['--force' => true]; |
36 | 37 | $migrate = ['--force' => true]; |
37 | 38 | |
38 | - if ($this->option('all')) { |
|
39 | + if ($this->option('all')) |
|
40 | + { |
|
39 | 41 | $rollback['--all'] = true; |
40 | - } else { |
|
42 | + } |
|
43 | + else |
|
44 | + { |
|
41 | 45 | $migrate['--one'] = true; |
42 | 46 | } |
43 | 47 |
@@ -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; |
@@ -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 |