@@ -70,18 +70,18 @@ discard block |
||
| 70 | 70 | protected function buildMap(ReflectionEntity $filter): array |
| 71 | 71 | { |
| 72 | 72 | $schema = $filter->getProperty('schema', true); |
| 73 | - if (empty($schema)) { |
|
| 73 | + if (empty($schema)){ |
|
| 74 | 74 | throw new SchemaException("Filter `{$filter->getName()}` does not define any schema"); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $result = []; |
| 78 | - foreach ($schema as $field => $definition) { |
|
| 78 | + foreach ($schema as $field => $definition){ |
|
| 79 | 79 | $optional = false; |
| 80 | 80 | |
| 81 | 81 | // short definition |
| 82 | - if (is_string($definition)) { |
|
| 82 | + if (is_string($definition)){ |
|
| 83 | 83 | // simple scalar field definition |
| 84 | - if (!class_exists($definition)) { |
|
| 84 | + if (!class_exists($definition)){ |
|
| 85 | 85 | [$source, $origin] = $this->parseDefinition($field, $definition); |
| 86 | 86 | $result[$field] = [ |
| 87 | 87 | FilterProvider::SOURCE => $source, |
@@ -102,25 +102,25 @@ discard block |
||
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if (!is_array($definition) || count($definition) === 0) { |
|
| 105 | + if (!is_array($definition) || count($definition) === 0){ |
|
| 106 | 106 | throw new SchemaException( |
| 107 | 107 | "Invalid schema definition at `{$filter->getName()}`->`{$field}`" |
| 108 | 108 | ); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // complex definition |
| 112 | - if (!empty($definition[self::ORIGIN])) { |
|
| 112 | + if (!empty($definition[self::ORIGIN])){ |
|
| 113 | 113 | $origin = $definition[self::ORIGIN]; |
| 114 | 114 | |
| 115 | 115 | // [class, 'data:something.*'] vs [class, 'data:something'] |
| 116 | 116 | $iterate = strpos($origin, '.*') !== false || !empty($definition[self::ITERATE]); |
| 117 | 117 | $origin = rtrim($origin, '.*'); |
| 118 | - } else { |
|
| 118 | + }else{ |
|
| 119 | 119 | $origin = $field; |
| 120 | 120 | $iterate = true; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if (!empty($definition[self::OPTIONAL]) && $definition[self::OPTIONAL]) { |
|
| 123 | + if (!empty($definition[self::OPTIONAL]) && $definition[self::OPTIONAL]){ |
|
| 124 | 124 | $optional = true; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | FilterProvider::OPTIONAL => $optional, |
| 134 | 134 | ]; |
| 135 | 135 | |
| 136 | - if ($iterate) { |
|
| 136 | + if ($iterate){ |
|
| 137 | 137 | [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin); |
| 138 | 138 | |
| 139 | 139 | $map[FilterProvider::ITERATE_SOURCE] = $source; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | private function parseDefinition(string $field, string $definition): array |
| 161 | 161 | { |
| 162 | - if (strpos($definition, ':') === false) { |
|
| 162 | + if (strpos($definition, ':') === false){ |
|
| 163 | 163 | return ['data', $definition ?? $field]; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -70,18 +70,22 @@ discard block |
||
| 70 | 70 | protected function buildMap(ReflectionEntity $filter): array |
| 71 | 71 | { |
| 72 | 72 | $schema = $filter->getProperty('schema', true); |
| 73 | - if (empty($schema)) { |
|
| 73 | + if (empty($schema)) |
|
| 74 | + { |
|
| 74 | 75 | throw new SchemaException("Filter `{$filter->getName()}` does not define any schema"); |
| 75 | 76 | } |
| 76 | 77 | |
| 77 | 78 | $result = []; |
| 78 | - foreach ($schema as $field => $definition) { |
|
| 79 | + foreach ($schema as $field => $definition) |
|
| 80 | + { |
|
| 79 | 81 | $optional = false; |
| 80 | 82 | |
| 81 | 83 | // short definition |
| 82 | - if (is_string($definition)) { |
|
| 84 | + if (is_string($definition)) |
|
| 85 | + { |
|
| 83 | 86 | // simple scalar field definition |
| 84 | - if (!class_exists($definition)) { |
|
| 87 | + if (!class_exists($definition)) |
|
| 88 | + { |
|
| 85 | 89 | [$source, $origin] = $this->parseDefinition($field, $definition); |
| 86 | 90 | $result[$field] = [ |
| 87 | 91 | FilterProvider::SOURCE => $source, |
@@ -102,25 +106,30 @@ discard block |
||
| 102 | 106 | continue; |
| 103 | 107 | } |
| 104 | 108 | |
| 105 | - if (!is_array($definition) || count($definition) === 0) { |
|
| 109 | + if (!is_array($definition) || count($definition) === 0) |
|
| 110 | + { |
|
| 106 | 111 | throw new SchemaException( |
| 107 | 112 | "Invalid schema definition at `{$filter->getName()}`->`{$field}`" |
| 108 | 113 | ); |
| 109 | 114 | } |
| 110 | 115 | |
| 111 | 116 | // complex definition |
| 112 | - if (!empty($definition[self::ORIGIN])) { |
|
| 117 | + if (!empty($definition[self::ORIGIN])) |
|
| 118 | + { |
|
| 113 | 119 | $origin = $definition[self::ORIGIN]; |
| 114 | 120 | |
| 115 | 121 | // [class, 'data:something.*'] vs [class, 'data:something'] |
| 116 | 122 | $iterate = strpos($origin, '.*') !== false || !empty($definition[self::ITERATE]); |
| 117 | 123 | $origin = rtrim($origin, '.*'); |
| 118 | - } else { |
|
| 124 | + } |
|
| 125 | + else |
|
| 126 | + { |
|
| 119 | 127 | $origin = $field; |
| 120 | 128 | $iterate = true; |
| 121 | 129 | } |
| 122 | 130 | |
| 123 | - if (!empty($definition[self::OPTIONAL]) && $definition[self::OPTIONAL]) { |
|
| 131 | + if (!empty($definition[self::OPTIONAL]) && $definition[self::OPTIONAL]) |
|
| 132 | + { |
|
| 124 | 133 | $optional = true; |
| 125 | 134 | } |
| 126 | 135 | |
@@ -133,7 +142,8 @@ discard block |
||
| 133 | 142 | FilterProvider::OPTIONAL => $optional, |
| 134 | 143 | ]; |
| 135 | 144 | |
| 136 | - if ($iterate) { |
|
| 145 | + if ($iterate) |
|
| 146 | + { |
|
| 137 | 147 | [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin); |
| 138 | 148 | |
| 139 | 149 | $map[FilterProvider::ITERATE_SOURCE] = $source; |
@@ -159,7 +169,8 @@ discard block |
||
| 159 | 169 | */ |
| 160 | 170 | private function parseDefinition(string $field, string $definition): array |
| 161 | 171 | { |
| 162 | - if (strpos($definition, ':') === false) { |
|
| 172 | + if (strpos($definition, ':') === false) |
|
| 173 | + { |
|
| 163 | 174 | return ['data', $definition ?? $field]; |
| 164 | 175 | } |
| 165 | 176 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | FilterProvider::SOURCE => null, |
| 96 | 96 | FilterProvider::ORIGIN => $field, |
| 97 | 97 | FilterProvider::FILTER => $definition, |
| 98 | - FilterProvider::ARRAY => false, |
|
| 98 | + FilterProvider::array => false, |
|
| 99 | 99 | FilterProvider::OPTIONAL => $optional, |
| 100 | 100 | ]; |
| 101 | 101 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | FilterProvider::FILTER => $definition[self::NESTED], |
| 130 | 130 | FilterProvider::SOURCE => null, |
| 131 | 131 | FilterProvider::ORIGIN => $origin, |
| 132 | - FilterProvider::ARRAY => $iterate, |
|
| 132 | + FilterProvider::array => $iterate, |
|
| 133 | 133 | FilterProvider::OPTIONAL => $optional, |
| 134 | 134 | ]; |
| 135 | 135 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public const SOURCE = 'source'; |
| 34 | 34 | public const ORIGIN = 'origin'; |
| 35 | 35 | public const FILTER = 'filter'; |
| 36 | - public const ARRAY = 'array'; |
|
| 36 | + public const array = 'array'; |
|
| 37 | 37 | public const OPTIONAL = 'optional'; |
| 38 | 38 | public const ITERATE_SOURCE = 'iterate_source'; |
| 39 | 39 | public const ITERATE_ORIGIN = 'iterate_origin'; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $nested = $map[self::FILTER]; |
| 106 | - if (empty($map[self::ARRAY])) { |
|
| 106 | + if (empty($map[self::array])) { |
|
| 107 | 107 | // slicing down |
| 108 | 108 | $result[$field] = $this->createFilter($nested, $input->withPrefix($map[self::ORIGIN])); |
| 109 | 109 | continue; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | array $schema, |
| 91 | 91 | ValidatorInterface $validator, |
| 92 | 92 | ErrorMapper $errorMapper |
| 93 | - ) { |
|
| 93 | + ){ |
|
| 94 | 94 | parent::__construct($data, $schema); |
| 95 | 95 | |
| 96 | 96 | $this->mappings = $schema[FilterProvider::MAPPING] ?? []; |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function getErrors(): array |
| 153 | 153 | { |
| 154 | - if ($this->errors === null) { |
|
| 154 | + if ($this->errors === null){ |
|
| 155 | 155 | $this->errors = []; |
| 156 | - foreach ($this->validator->withData($this)->getErrors() as $field => $error) { |
|
| 157 | - if (is_string($error) && Translator::isMessage($error)) { |
|
| 156 | + foreach ($this->validator->withData($this)->getErrors() as $field => $error){ |
|
| 157 | + if (is_string($error) && Translator::isMessage($error)){ |
|
| 158 | 158 | // translate error message |
| 159 | 159 | $error = $this->say($error); |
| 160 | 160 | } |
@@ -195,32 +195,32 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | protected function validateNested(array $errors): array |
| 197 | 197 | { |
| 198 | - foreach ($this->getFields(false) as $index => $value) { |
|
| 199 | - if (isset($errors[$index])) { |
|
| 198 | + foreach ($this->getFields(false) as $index => $value){ |
|
| 199 | + if (isset($errors[$index])){ |
|
| 200 | 200 | //Invalid on parent level |
| 201 | 201 | continue; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if ($value instanceof FilterInterface) { |
|
| 205 | - if ($this->isOptional($index) && !$this->hasBeenPassed($index)) { |
|
| 204 | + if ($value instanceof FilterInterface){ |
|
| 205 | + if ($this->isOptional($index) && !$this->hasBeenPassed($index)){ |
|
| 206 | 206 | continue; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if (!$value->isValid()) { |
|
| 209 | + if (!$value->isValid()){ |
|
| 210 | 210 | $errors[$index] = $value->getErrors(); |
| 211 | 211 | continue; |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | //Array of nested entities for validation |
| 216 | - if (is_iterable($value)) { |
|
| 217 | - foreach ($value as $nIndex => $nValue) { |
|
| 218 | - if ($nValue instanceof FilterInterface) { |
|
| 219 | - if ($this->isOptional($nIndex) && !$this->hasBeenPassed($nIndex)) { |
|
| 216 | + if (is_iterable($value)){ |
|
| 217 | + foreach ($value as $nIndex => $nValue){ |
|
| 218 | + if ($nValue instanceof FilterInterface){ |
|
| 219 | + if ($this->isOptional($nIndex) && !$this->hasBeenPassed($nIndex)){ |
|
| 220 | 220 | continue; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if (!$nValue->isValid()) { |
|
| 223 | + if (!$nValue->isValid()){ |
|
| 224 | 224 | $errors[$index][$nIndex] = $nValue->getErrors(); |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -254,11 +254,11 @@ discard block |
||
| 254 | 254 | { |
| 255 | 255 | $value = $this->getField((string)$field); |
| 256 | 256 | |
| 257 | - if ($value === null) { |
|
| 257 | + if ($value === null){ |
|
| 258 | 258 | return false; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if ($value instanceof FilterInterface) { |
|
| 261 | + if ($value instanceof FilterInterface){ |
|
| 262 | 262 | return $value->getValue() !== []; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -151,10 +151,13 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function getErrors(): array |
| 153 | 153 | { |
| 154 | - if ($this->errors === null) { |
|
| 154 | + if ($this->errors === null) |
|
| 155 | + { |
|
| 155 | 156 | $this->errors = []; |
| 156 | - foreach ($this->validator->withData($this)->getErrors() as $field => $error) { |
|
| 157 | - if (is_string($error) && Translator::isMessage($error)) { |
|
| 157 | + foreach ($this->validator->withData($this)->getErrors() as $field => $error) |
|
| 158 | + { |
|
| 159 | + if (is_string($error) && Translator::isMessage($error)) |
|
| 160 | + { |
|
| 158 | 161 | // translate error message |
| 159 | 162 | $error = $this->say($error); |
| 160 | 163 | } |
@@ -195,32 +198,42 @@ discard block |
||
| 195 | 198 | */ |
| 196 | 199 | protected function validateNested(array $errors): array |
| 197 | 200 | { |
| 198 | - foreach ($this->getFields(false) as $index => $value) { |
|
| 199 | - if (isset($errors[$index])) { |
|
| 201 | + foreach ($this->getFields(false) as $index => $value) |
|
| 202 | + { |
|
| 203 | + if (isset($errors[$index])) |
|
| 204 | + { |
|
| 200 | 205 | //Invalid on parent level |
| 201 | 206 | continue; |
| 202 | 207 | } |
| 203 | 208 | |
| 204 | - if ($value instanceof FilterInterface) { |
|
| 205 | - if ($this->isOptional($index) && !$this->hasBeenPassed($index)) { |
|
| 209 | + if ($value instanceof FilterInterface) |
|
| 210 | + { |
|
| 211 | + if ($this->isOptional($index) && !$this->hasBeenPassed($index)) |
|
| 212 | + { |
|
| 206 | 213 | continue; |
| 207 | 214 | } |
| 208 | 215 | |
| 209 | - if (!$value->isValid()) { |
|
| 216 | + if (!$value->isValid()) |
|
| 217 | + { |
|
| 210 | 218 | $errors[$index] = $value->getErrors(); |
| 211 | 219 | continue; |
| 212 | 220 | } |
| 213 | 221 | } |
| 214 | 222 | |
| 215 | 223 | //Array of nested entities for validation |
| 216 | - if (is_iterable($value)) { |
|
| 217 | - foreach ($value as $nIndex => $nValue) { |
|
| 218 | - if ($nValue instanceof FilterInterface) { |
|
| 219 | - if ($this->isOptional($nIndex) && !$this->hasBeenPassed($nIndex)) { |
|
| 224 | + if (is_iterable($value)) |
|
| 225 | + { |
|
| 226 | + foreach ($value as $nIndex => $nValue) |
|
| 227 | + { |
|
| 228 | + if ($nValue instanceof FilterInterface) |
|
| 229 | + { |
|
| 230 | + if ($this->isOptional($nIndex) && !$this->hasBeenPassed($nIndex)) |
|
| 231 | + { |
|
| 220 | 232 | continue; |
| 221 | 233 | } |
| 222 | 234 | |
| 223 | - if (!$nValue->isValid()) { |
|
| 235 | + if (!$nValue->isValid()) |
|
| 236 | + { |
|
| 224 | 237 | $errors[$index][$nIndex] = $nValue->getErrors(); |
| 225 | 238 | } |
| 226 | 239 | } |
@@ -254,11 +267,13 @@ discard block |
||
| 254 | 267 | { |
| 255 | 268 | $value = $this->getField((string)$field); |
| 256 | 269 | |
| 257 | - if ($value === null) { |
|
| 270 | + if ($value === null) |
|
| 271 | + { |
|
| 258 | 272 | return false; |
| 259 | 273 | } |
| 260 | 274 | |
| 261 | - if ($value instanceof FilterInterface) { |
|
| 275 | + if ($value instanceof FilterInterface) |
|
| 276 | + { |
|
| 262 | 277 | return $value->getValue() !== []; |
| 263 | 278 | } |
| 264 | 279 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function perform(): void |
| 28 | 28 | { |
| 29 | - if (!$this->verifyEnvironment()) { |
|
| 29 | + if (!$this->verifyEnvironment()){ |
|
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $found = false; |
| 36 | 36 | $count = $this->option('one') ? 1 : PHP_INT_MAX; |
| 37 | 37 | |
| 38 | - while ($count > 0 && ($migration = $this->migrator->run())) { |
|
| 38 | + while ($count > 0 && ($migration = $this->migrator->run())){ |
|
| 39 | 39 | $found = true; |
| 40 | 40 | $count--; |
| 41 | 41 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | ); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if (!$found) { |
|
| 48 | + if (!$found){ |
|
| 49 | 49 | $this->writeln('<fg=red>No outstanding migrations were found.</fg=red>'); |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function perform(): void |
| 28 | 28 | { |
| 29 | - if (!$this->verifyEnvironment()) { |
|
| 29 | + if (!$this->verifyEnvironment()) |
|
| 30 | + { |
|
| 30 | 31 | return; |
| 31 | 32 | } |
| 32 | 33 | |
@@ -35,7 +36,8 @@ discard block |
||
| 35 | 36 | $found = false; |
| 36 | 37 | $count = $this->option('one') ? 1 : PHP_INT_MAX; |
| 37 | 38 | |
| 38 | - while ($count > 0 && ($migration = $this->migrator->run())) { |
|
| 39 | + while ($count > 0 && ($migration = $this->migrator->run())) |
|
| 40 | + { |
|
| 39 | 41 | $found = true; |
| 40 | 42 | $count--; |
| 41 | 43 | |
@@ -45,7 +47,8 @@ discard block |
||
| 45 | 47 | ); |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | - if (!$found) { |
|
| 50 | + if (!$found) |
|
| 51 | + { |
|
| 49 | 52 | $this->writeln('<fg=red>No outstanding migrations were found.</fg=red>'); |
| 50 | 53 | } |
| 51 | 54 | } |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $this->migrator->configure(); |
| 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( |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $state->getTimeCreated()->format('Y-m-d H:i:s'), |
| 47 | 47 | $state->getStatus() == State::STATUS_PENDING |
| 48 | 48 | ? self::PENDING |
| 49 | - : '<info>' . $state->getTimeExecuted()->format('Y-m-d H:i:s') . '</info>', |
|
| 49 | + : '<info>'.$state->getTimeExecuted()->format('Y-m-d H:i:s').'</info>', |
|
| 50 | 50 | ] |
| 51 | 51 | ); |
| 52 | 52 | } |
@@ -30,14 +30,16 @@ |
||
| 30 | 30 | { |
| 31 | 31 | $this->migrator->configure(); |
| 32 | 32 | |
| 33 | - if (empty($this->migrator->getMigrations())) { |
|
| 33 | + if (empty($this->migrator->getMigrations())) |
|
| 34 | + { |
|
| 34 | 35 | $this->writeln('<comment>No migrations were found.</comment>'); |
| 35 | 36 | |
| 36 | 37 | return; |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | $table = $this->table(['Migration', 'Created at', 'Executed at']); |
| 40 | - foreach ($this->migrator->getMigrations() as $migration) { |
|
| 41 | + foreach ($this->migrator->getMigrations() as $migration) |
|
| 42 | + { |
|
| 41 | 43 | $state = $migration->getState(); |
| 42 | 44 | |
| 43 | 45 | $table->addRow( |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function perform(): void |
| 28 | 28 | { |
| 29 | - if (!$this->verifyEnvironment()) { |
|
| 29 | + if (!$this->verifyEnvironment()){ |
|
| 30 | 30 | //Making sure we can safely migrate in this environment |
| 31 | 31 | return; |
| 32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | $found = false; |
| 37 | 37 | $count = !$this->option('all') ? 1 : PHP_INT_MAX; |
| 38 | - while ($count > 0 && ($migration = $this->migrator->rollback())) { |
|
| 38 | + while ($count > 0 && ($migration = $this->migrator->rollback())){ |
|
| 39 | 39 | $found = true; |
| 40 | 40 | $count--; |
| 41 | 41 | $this->sprintf( |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (!$found) { |
|
| 47 | + if (!$found){ |
|
| 48 | 48 | $this->writeln('<fg=red>No executed migrations were found.</fg=red>'); |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function perform(): void |
| 28 | 28 | { |
| 29 | - if (!$this->verifyEnvironment()) { |
|
| 29 | + if (!$this->verifyEnvironment()) |
|
| 30 | + { |
|
| 30 | 31 | //Making sure we can safely migrate in this environment |
| 31 | 32 | return; |
| 32 | 33 | } |
@@ -35,7 +36,8 @@ discard block |
||
| 35 | 36 | |
| 36 | 37 | $found = false; |
| 37 | 38 | $count = !$this->option('all') ? 1 : PHP_INT_MAX; |
| 38 | - while ($count > 0 && ($migration = $this->migrator->rollback())) { |
|
| 39 | + while ($count > 0 && ($migration = $this->migrator->rollback())) |
|
| 40 | + { |
|
| 39 | 41 | $found = true; |
| 40 | 42 | $count--; |
| 41 | 43 | $this->sprintf( |
@@ -44,7 +46,8 @@ discard block |
||
| 44 | 46 | ); |
| 45 | 47 | } |
| 46 | 48 | |
| 47 | - if (!$found) { |
|
| 49 | + if (!$found) |
|
| 50 | + { |
|
| 48 | 51 | $this->writeln('<fg=red>No executed migrations were found.</fg=red>'); |
| 49 | 52 | } |
| 50 | 53 | } |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | ): void { |
| 53 | 53 | $migrator->configure(); |
| 54 | 54 | |
| 55 | - foreach ($migrator->getMigrations() as $migration) { |
|
| 56 | - if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED) { |
|
| 55 | + foreach ($migrator->getMigrations() as $migration){ |
|
| 56 | + if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED){ |
|
| 57 | 57 | $this->writeln('<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>'); |
| 58 | 58 | return; |
| 59 | 59 | } |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | ); |
| 68 | 68 | $schemaCompiler->toMemory($memory); |
| 69 | 69 | |
| 70 | - if ($show->hasChanges()) { |
|
| 70 | + if ($show->hasChanges()){ |
|
| 71 | 71 | (new Compiler())->compile($registry, [$migrations]); |
| 72 | 72 | |
| 73 | - if ($this->option('run')) { |
|
| 73 | + if ($this->option('run')){ |
|
| 74 | 74 | $console->run('migrate', [], $this->output); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -52,8 +52,10 @@ discard block |
||
| 52 | 52 | ): void { |
| 53 | 53 | $migrator->configure(); |
| 54 | 54 | |
| 55 | - foreach ($migrator->getMigrations() as $migration) { |
|
| 56 | - if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED) { |
|
| 55 | + foreach ($migrator->getMigrations() as $migration) |
|
| 56 | + { |
|
| 57 | + if ($migration->getState()->getStatus() !== Status::STATUS_EXECUTED) |
|
| 58 | + { |
|
| 57 | 59 | $this->writeln('<fg=red>Outstanding migrations found, run `migrate` first.</fg=red>'); |
| 58 | 60 | return; |
| 59 | 61 | } |
@@ -67,10 +69,12 @@ discard block |
||
| 67 | 69 | ); |
| 68 | 70 | $schemaCompiler->toMemory($memory); |
| 69 | 71 | |
| 70 | - if ($show->hasChanges()) { |
|
| 72 | + if ($show->hasChanges()) |
|
| 73 | + { |
|
| 71 | 74 | (new Compiler())->compile($registry, [$migrations]); |
| 72 | 75 | |
| 73 | - if ($this->option('run')) { |
|
| 76 | + if ($this->option('run')) |
|
| 77 | + { |
|
| 74 | 78 | $console->run('migrate', [], $this->output); |
| 75 | 79 | } |
| 76 | 80 | } |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | private function cleanupMigrations(): void |
| 33 | 33 | { |
| 34 | 34 | $fs = new Files(); |
| 35 | - if ($fs->isDirectory(__DIR__ . '/../app/migrations')) { |
|
| 36 | - $fs->deleteDirectory(__DIR__ . '/../app/migrations'); |
|
| 35 | + if ($fs->isDirectory(__DIR__.'/../app/migrations')){ |
|
| 36 | + $fs->deleteDirectory(__DIR__.'/../app/migrations'); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $fs = new Files(); |
| 47 | 47 | $runtime = $this->app->get(DirectoriesInterface::class)->get('runtime'); |
| 48 | 48 | |
| 49 | - if ($fs->isDirectory($runtime)) { |
|
| 49 | + if ($fs->isDirectory($runtime)){ |
|
| 50 | 50 | $fs->deleteDirectory($runtime); |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -32,7 +32,8 @@ discard block |
||
| 32 | 32 | private function cleanupMigrations(): void |
| 33 | 33 | { |
| 34 | 34 | $fs = new Files(); |
| 35 | - if ($fs->isDirectory(__DIR__ . '/../app/migrations')) { |
|
| 35 | + if ($fs->isDirectory(__DIR__ . '/../app/migrations')) |
|
| 36 | + { |
|
| 36 | 37 | $fs->deleteDirectory(__DIR__ . '/../app/migrations'); |
| 37 | 38 | } |
| 38 | 39 | } |
@@ -46,7 +47,8 @@ discard block |
||
| 46 | 47 | $fs = new Files(); |
| 47 | 48 | $runtime = $this->app->get(DirectoriesInterface::class)->get('runtime'); |
| 48 | 49 | |
| 49 | - if ($fs->isDirectory($runtime)) { |
|
| 50 | + if ($fs->isDirectory($runtime)) |
|
| 51 | + { |
|
| 50 | 52 | $fs->deleteDirectory($runtime); |
| 51 | 53 | } |
| 52 | 54 | } |