@@ -46,7 +46,7 @@ |
||
| 46 | 46 | if (is_string($key) && is_string($value)) { |
| 47 | 47 | return array('identifier' => $key, 'attribute' => $value); |
| 48 | 48 | } |
| 49 | - if (!is_array($value) || !isset($value['identifier']) || ! isset($value['attribute'])) { |
|
| 49 | + if (!is_array($value) || !isset($value['identifier']) || !isset($value['attribute'])) { |
|
| 50 | 50 | throw new InvalidStepDefinitionException("Invalid reference definition for reference number $key"); |
| 51 | 51 | } |
| 52 | 52 | return $value; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | // q2: why not just check for Countable interface instead of AbstractCollection? Or at least allow ArrayIterators and ObjectIterators |
| 38 | 38 | if (is_array($results) || $results instanceof AbstractCollection) { |
| 39 | 39 | $expectedResultsCount = $this->expectedResultsCount($step); |
| 40 | - switch($expectedResultsCount) { |
|
| 40 | + switch ($expectedResultsCount) { |
|
| 41 | 41 | case self::$EXPECT_UNSPECIFIED: |
| 42 | 42 | case self::$EXPECT_ANY: |
| 43 | 43 | break; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | protected function expectedResultsType($step) |
| 64 | 64 | { |
| 65 | - switch($this->expectedResultsCount($step)) { |
|
| 65 | + switch ($this->expectedResultsCount($step)) { |
|
| 66 | 66 | case 1: |
| 67 | 67 | return self::$RESULT_TYPE_SINGLE; |
| 68 | 68 | case 0: |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | // BC |
| 106 | 106 | if (isset($step->dsl['references_type'])) { |
| 107 | - switch($step->dsl['references_type']) { |
|
| 107 | + switch ($step->dsl['references_type']) { |
|
| 108 | 108 | case 'array': |
| 109 | 109 | return self::$EXPECT_ANY; |
| 110 | 110 | case 'scalar': |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function hasNonScalarReferences($referencesDefinition) |
| 132 | 132 | { |
| 133 | - foreach($referencesDefinition as $key => $referenceDefinition) { |
|
| 133 | + foreach ($referencesDefinition as $key => $referenceDefinition) { |
|
| 134 | 134 | $referenceDefinition = $this->parseReferenceDefinition($key, $referenceDefinition); |
| 135 | 135 | if (!$this->isScalarReference($referenceDefinition)) |
| 136 | 136 | { |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | protected function sortPolicyLimitationsDefinitions(array &$limitations) |
| 445 | 445 | { |
| 446 | 446 | usort($limitations, function($l1, $l2) { |
| 447 | - if (($iComp = strcmp($l1['identifier'], $l2['identifier'])) != 0 ) { |
|
| 447 | + if (($iComp = strcmp($l1['identifier'], $l2['identifier'])) != 0) { |
|
| 448 | 448 | return $iComp; |
| 449 | 449 | } |
| 450 | 450 | if (is_int($l1['values']) || is_float($l1['values'])) { |
@@ -473,10 +473,10 @@ discard block |
||
| 473 | 473 | return $this->compareArraysForSorting($p1['limitations'], $p2['limitations']); |
| 474 | 474 | $p1LimIds = array(); |
| 475 | 475 | $p2LimIds = array(); |
| 476 | - foreach($p1['limitations'] as $lim) { |
|
| 476 | + foreach ($p1['limitations'] as $lim) { |
|
| 477 | 477 | $p1LimIds = $lim['identifier']; |
| 478 | 478 | } |
| 479 | - foreach($p2['limitations'] as $lim) { |
|
| 479 | + foreach ($p2['limitations'] as $lim) { |
|
| 480 | 480 | $p2LimIds = $lim['identifier']; |
| 481 | 481 | } |
| 482 | 482 | /// @todo if limitations identifier are the same, sort by lim. values... |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | foreach ($dsl['references'] as $key => $reference) { |
| 170 | 170 | // BC |
| 171 | - if (is_array($reference) && isset($reference['json_path']) && !isset($reference['attribute'] )) { |
|
| 171 | + if (is_array($reference) && isset($reference['json_path']) && !isset($reference['attribute'])) { |
|
| 172 | 172 | $reference['attribute'] = $reference['json_path']; |
| 173 | 173 | } |
| 174 | 174 | $reference = $this->parseReferenceDefinition($key, $reference); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | $migrationService = $this->migrationService; |
| 199 | 199 | $executors = $migrationService->listExecutors(); |
| 200 | - foreach($executors as $key => $name) { |
|
| 200 | + foreach ($executors as $key => $name) { |
|
| 201 | 201 | $executor = $migrationService->getExecutor($name); |
| 202 | 202 | if (!$executor instanceof MigrationGeneratorInterface) { |
| 203 | 203 | unset($executors[$key]); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | $multivalued = ($this->expectedResultsType($step) == self::$RESULT_TYPE_MULTIPLE); |
| 218 | 218 | |
| 219 | - if ($item instanceof AbstractCollection || is_array($item)) { |
|
| 219 | + if ($item instanceof AbstractCollection || is_array($item)) { |
|
| 220 | 220 | $items = $item; |
| 221 | 221 | } else { |
| 222 | 222 | $items = array($item); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | // allow setting *some* refs even when we have 0 or N matches |
| 262 | 262 | foreach ($referencesDefinition as $key => $reference) { |
| 263 | 263 | $reference = $this->parseReferenceDefinition($key, $reference); |
| 264 | - switch($reference['attribute']) { |
|
| 264 | + switch ($reference['attribute']) { |
|
| 265 | 265 | |
| 266 | 266 | case 'count': |
| 267 | 267 | $value = count($entity); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $processes = array(); |
| 134 | 134 | /** @var MigrationDefinition $migrationDefinition */ |
| 135 | - foreach($paths as $path => $count) { |
|
| 135 | + foreach ($paths as $path => $count) { |
|
| 136 | 136 | $this->writeln("<info>Queueing processing of: $path ($count migrations)</info>", OutputInterface::VERBOSITY_VERBOSE); |
| 137 | 137 | |
| 138 | 138 | $process = $builder |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $missed = $total - $this->migrationsDone[Migration::STATUS_DONE] - $this->migrationsDone[Migration::STATUS_FAILED] - $this->migrationsDone[Migration::STATUS_SKIPPED]; |
| 182 | - $this->writeln("\nExecuted ".$this->migrationsDone[Migration::STATUS_DONE].' migrations'. |
|
| 183 | - ', failed '.$this->migrationsDone[Migration::STATUS_FAILED]. |
|
| 184 | - ', skipped '.$this->migrationsDone[Migration::STATUS_SKIPPED]. |
|
| 182 | + $this->writeln("\nExecuted " . $this->migrationsDone[Migration::STATUS_DONE] . ' migrations' . |
|
| 183 | + ', failed ' . $this->migrationsDone[Migration::STATUS_FAILED] . |
|
| 184 | + ', skipped ' . $this->migrationsDone[Migration::STATUS_SKIPPED] . |
|
| 185 | 185 | ($missed ? ", missed $missed" : '')); |
| 186 | 186 | |
| 187 | 187 | $time = microtime(true) - $start; |
| 188 | 188 | // since we use subprocesses, we can not measure max memory used |
| 189 | - $this->writeln("<info>Time taken: ".sprintf('%.3f', $time)." secs</info>"); |
|
| 189 | + $this->writeln("<info>Time taken: " . sprintf('%.3f', $time) . " secs</info>"); |
|
| 190 | 190 | |
| 191 | 191 | return $subprocessesFailed + $this->migrationsDone[Migration::STATUS_FAILED] + $missed; |
| 192 | 192 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | foreach ($toExecute as $name => $migrationDefinition) { |
| 229 | 229 | // let's skip migrations that we know are invalid - user was warned and he decided to proceed anyway |
| 230 | 230 | if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) { |
| 231 | - $this->writeln("<comment>Skipping migration (invalid definition?) Path: ".$migrationDefinition->path."</comment>", self::VERBOSITY_CHILD); |
|
| 231 | + $this->writeln("<comment>Skipping migration (invalid definition?) Path: " . $migrationDefinition->path . "</comment>", self::VERBOSITY_CHILD); |
|
| 232 | 232 | $skipped++; |
| 233 | 233 | continue; |
| 234 | 234 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $this->executeMigrationInProcess($migrationDefinition, $force, $migrationService, $input); |
| 269 | 269 | |
| 270 | 270 | $executed++; |
| 271 | - } catch(\Exception $e) { |
|
| 271 | + } catch (\Exception $e) { |
|
| 272 | 272 | $failed++; |
| 273 | 273 | |
| 274 | 274 | $errorMessage = $e->getMessage(); |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param string $buffer |
| 302 | 302 | * @param null|\Symfony\Component\Process\Process $process |
| 303 | 303 | */ |
| 304 | - public function onChildProcessOutput($type, $buffer, $process=null) |
|
| 304 | + public function onChildProcessOutput($type, $buffer, $process = null) |
|
| 305 | 305 | { |
| 306 | 306 | $lines = explode("\n", trim($buffer)); |
| 307 | 307 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | // we tag the output with the id of the child process |
| 321 | 321 | if (trim($line) !== '') { |
| 322 | - $msg = '[' . ($process ? $process->getPid() : ''). '] ' . trim($line); |
|
| 322 | + $msg = '[' . ($process ? $process->getPid() : '') . '] ' . trim($line); |
|
| 323 | 323 | if ($type == 'err') { |
| 324 | 324 | $this->writeErrorln($msg, OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW); |
| 325 | 325 | } else { |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | // filter away all migrations except 'to do' ones |
| 355 | 355 | $toExecute = array(); |
| 356 | - foreach($migrationDefinitions as $name => $migrationDefinition) { |
|
| 356 | + foreach ($migrationDefinitions as $name => $migrationDefinition) { |
|
| 357 | 357 | if (!isset($migrations[$name]) || (($migration = $migrations[$name]) && in_array($migration->status, $allowedStatuses))) { |
| 358 | 358 | $toExecute[$name] = $isChild ? $migrationService->parseMigrationDefinition($migrationDefinition) : $migrationDefinition; |
| 359 | 359 | } |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | { |
| 396 | 396 | $output->writeln('Found ' . count($toExecute) . ' migrations in ' . count($paths) . ' directories'); |
| 397 | 397 | $output->writeln('In the same directories, migrations previously executed: ' . $this->migrationsAlreadyDone[Migration::STATUS_DONE] . |
| 398 | - ', failed: ' . $this->migrationsAlreadyDone[Migration::STATUS_FAILED] . ', skipped: '. $this->migrationsAlreadyDone[Migration::STATUS_SKIPPED]); |
|
| 398 | + ', failed: ' . $this->migrationsAlreadyDone[Migration::STATUS_FAILED] . ', skipped: ' . $this->migrationsAlreadyDone[Migration::STATUS_SKIPPED]); |
|
| 399 | 399 | if ($this->migrationsAlreadyDone[Migration::STATUS_STARTED]) { |
| 400 | 400 | $output->writeln('<info>In the same directories, migrations currently executing: ' . $this->migrationsAlreadyDone[Migration::STATUS_STARTED] . '</info>'); |
| 401 | 401 | } |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | protected function groupMigrationsByPath($toExecute) |
| 409 | 409 | { |
| 410 | 410 | $paths = array(); |
| 411 | - foreach($toExecute as $name => $migrationDefinition) { |
|
| 411 | + foreach ($toExecute as $name => $migrationDefinition) { |
|
| 412 | 412 | $path = dirname($migrationDefinition->path); |
| 413 | 413 | if (!isset($paths[$path])) { |
| 414 | 414 | $paths[$path] = 1; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | $builderArgs[] = '--separate-process'; |
| 486 | 486 | } |
| 487 | 487 | if ($input->getOption('set-reference')) { |
| 488 | - foreach($input->getOption('set-reference') as $refSpec) { |
|
| 488 | + foreach ($input->getOption('set-reference') as $refSpec) { |
|
| 489 | 489 | $builderArgs[] = '--set-reference=' . $refSpec; |
| 490 | 490 | } |
| 491 | 491 | } |
@@ -157,7 +157,7 @@ |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | if ($this->output && $this->output->isVeryVerbose()) { |
| 160 | - $out .= sprintf(". <info>Time taken: %.3f secs, memory delta: %d bytes</info>", $stepTime, $stepMemory); |
|
| 160 | + $out .= sprintf(". <info>Time taken: %.3f secs, memory delta: %d bytes</info>", $stepTime, $stepMemory); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $this->echoMessage($out); |
@@ -599,8 +599,9 @@ |
||
| 599 | 599 | */ |
| 600 | 600 | public function getCurrentContext($migrationName) |
| 601 | 601 | { |
| 602 | - if (!isset($this->migrationContext[$migrationName])) |
|
| 603 | - return null; |
|
| 602 | + if (!isset($this->migrationContext[$migrationName])) { |
|
| 603 | + return null; |
|
| 604 | + } |
|
| 604 | 605 | $context = $this->migrationContext[$migrationName]; |
| 605 | 606 | // avoid attempting to store the current outputInterface when saving the context |
| 606 | 607 | if (isset($context['output'])) { |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) { |
| 286 | - throw new \Exception("Can not execute " . $this->getEntityName($migrationDefinition). " '{$migrationDefinition->name}': {$migrationDefinition->parsingError}"); |
|
| 286 | + throw new \Exception("Can not execute " . $this->getEntityName($migrationDefinition) . " '{$migrationDefinition->name}': {$migrationDefinition->parsingError}"); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /// @todo add support for setting in $migrationContext a userContentType, userGroupContentType ? |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | try { |
| 319 | 319 | |
| 320 | - $i = $stepOffset+1; |
|
| 320 | + $i = $stepOffset + 1; |
|
| 321 | 321 | $finalStatus = Migration::STATUS_DONE; |
| 322 | 322 | $finalMessage = null; |
| 323 | 323 | |
@@ -454,12 +454,12 @@ discard block |
||
| 454 | 454 | public function resumeMigration(Migration $migration, $useTransaction = true, array $forcedReferences = array()) |
| 455 | 455 | { |
| 456 | 456 | if ($migration->status != Migration::STATUS_SUSPENDED) { |
| 457 | - throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': it is not in suspended status"); |
|
| 457 | + throw new \Exception("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': it is not in suspended status"); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | $migrationDefinitions = $this->getMigrationsDefinitions(array($migration->path)); |
| 461 | 461 | if (!count($migrationDefinitions)) { |
| 462 | - throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': its definition is missing"); |
|
| 462 | + throw new \Exception("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': its definition is missing"); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | $defs = $migrationDefinitions->getArrayCopy(); |
@@ -467,24 +467,24 @@ discard block |
||
| 467 | 467 | |
| 468 | 468 | $migrationDefinition = $this->parseMigrationDefinition($migrationDefinition); |
| 469 | 469 | if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) { |
| 470 | - throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': {$migrationDefinition->parsingError}"); |
|
| 470 | + throw new \Exception("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': {$migrationDefinition->parsingError}"); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // restore context |
| 474 | 474 | $this->contextHandler->restoreCurrentContext($migration->name); |
| 475 | 475 | |
| 476 | 476 | if ($forcedReferences) { |
| 477 | - foreach($forcedReferences as $name => $value) { |
|
| 477 | + foreach ($forcedReferences as $name => $value) { |
|
| 478 | 478 | $this->referenceResolver->addReference($name, $value, true); |
| 479 | 479 | } |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | if (!isset($this->migrationContext[$migration->name])) { |
| 483 | - throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': the stored context is missing"); |
|
| 483 | + throw new \Exception("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': the stored context is missing"); |
|
| 484 | 484 | } |
| 485 | 485 | $restoredContext = $this->migrationContext[$migration->name]; |
| 486 | - if (!is_array($restoredContext) || !isset($restoredContext['context']) || !isset($restoredContext['step'] )) { |
|
| 487 | - throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': the stored context is invalid"); |
|
| 486 | + if (!is_array($restoredContext) || !isset($restoredContext['context']) || !isset($restoredContext['step'])) { |
|
| 487 | + throw new \Exception("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': the stored context is invalid"); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | // update migration status |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | * @param bool|null $forceSigchildEnabled |
| 506 | 506 | * @return array |
| 507 | 507 | */ |
| 508 | - protected function migrationContextFromParameters($defaultLanguageCode = null, $adminLogin = null, $forceSigchildEnabled = null ) |
|
| 508 | + protected function migrationContextFromParameters($defaultLanguageCode = null, $adminLogin = null, $forceSigchildEnabled = null) |
|
| 509 | 509 | { |
| 510 | 510 | $properties = array(); |
| 511 | 511 | |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | if ($input->getOption('todo')) { |
| 199 | 199 | foreach ($data as $migrationData) { |
| 200 | - $output->writeln("$migrationData", OutputInterface::OUTPUT_RAW|OutputInterface::VERBOSITY_QUIET); |
|
| 200 | + $output->writeln("$migrationData", OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_QUIET); |
|
| 201 | 201 | } |
| 202 | 202 | return 0; |
| 203 | 203 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | protected function sortMigrationIndex(array &$index, $sortBy) |
| 228 | 228 | { |
| 229 | - switch($sortBy) { |
|
| 229 | + switch ($sortBy) { |
|
| 230 | 230 | case 'execution': |
| 231 | 231 | uasort($index, function($m1, $m2) { |
| 232 | 232 | if (isset($m1['migration']) && $m1['migration']->executionDate !== null) { |