@@ -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); |
@@ -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 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $forcedRefs = array(); |
| 98 | 98 | if ($input->getOption('set-reference') /*&& !$input->getOption('separate-process')*/) { |
| 99 | 99 | $refResolver = $this->getContainer()->get('ez_migration_bundle.reference_resolver.customreference'); |
| 100 | - foreach($input->getOption('set-reference') as $refSpec) { |
|
| 100 | + foreach ($input->getOption('set-reference') as $refSpec) { |
|
| 101 | 101 | $ref = explode(':', $refSpec, 2); |
| 102 | 102 | if (count($ref) < 2 || $ref[0] === '') { |
| 103 | 103 | throw new \Exception("Invalid reference specification: '$refSpec'"); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $executed = 0; |
| 110 | 110 | $failed = 0; |
| 111 | 111 | |
| 112 | - foreach($suspendedMigrations as $suspendedMigration) { |
|
| 112 | + foreach ($suspendedMigrations as $suspendedMigration) { |
|
| 113 | 113 | $output->writeln("<info>Resuming {$suspendedMigration->name}</info>"); |
| 114 | 114 | |
| 115 | 115 | try { |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $time = microtime(true) - $start; |
| 131 | 131 | $output->writeln("Resumed $executed migrations, failed $failed"); |
| 132 | - $output->writeln("Time taken: ".sprintf('%.3f', $time)." secs, memory: ".sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)). ' MB'); |
|
| 132 | + $output->writeln("Time taken: " . sprintf('%.3f', $time) . " secs, memory: " . sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)) . ' MB'); |
|
| 133 | 133 | |
| 134 | 134 | if ($failed) { |
| 135 | 135 | return 2; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | throw new \Exception("Invalid step definition: file '$fileName' for saving references already exists"); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if (! $this->referenceResolver instanceof EnumerableReferenceResolverInterface) { |
|
| 163 | + if (!$this->referenceResolver instanceof EnumerableReferenceResolverInterface) { |
|
| 164 | 164 | throw new \Exception("Can not save references as resolver is not enumerable"); |
| 165 | 165 | } |
| 166 | 166 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $value = $this->dumpVar($this->referenceResolver->resolveReference($dsl['identifier'])); |
| 206 | 206 | |
| 207 | 207 | if (isset($context['output']) && $context['output'] instanceof OutputInterface) { |
| 208 | - $context['output']->write($label . $value, false, OutputInterface::OUTPUT_RAW|OutputInterface::VERBOSITY_NORMAL); |
|
| 208 | + $context['output']->write($label . $value, false, OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_NORMAL); |
|
| 209 | 209 | } else { |
| 210 | 210 | echo $label . $value; |
| 211 | 211 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $dumper->dump( |
| 229 | 229 | $cloner->cloneVar($var), |
| 230 | - function ($line, $depth) use (&$output) { |
|
| 230 | + function($line, $depth) use (&$output) { |
|
| 231 | 231 | // A negative depth means "end of dump" |
| 232 | 232 | if ($depth >= 0) { |
| 233 | 233 | // Adds a two spaces indentation to the line |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | protected $ioDecorator; |
| 11 | 11 | protected $ioService; |
| 12 | 12 | |
| 13 | - public function __construct($ioRootDir, UrlDecorator $ioDecorator=null, $ioService=null) |
|
| 13 | + public function __construct($ioRootDir, UrlDecorator $ioDecorator = null, $ioService = null) |
|
| 14 | 14 | { |
| 15 | 15 | $this->ioRootDir = $ioRootDir; |
| 16 | 16 | $this->ioDecorator = $ioDecorator; |
@@ -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 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $prefix = array($php); |
| 212 | 212 | |
| 213 | 213 | if ($input->getOption('child-process-php-ini-config')) { |
| 214 | - foreach($input->getOption('child-process-php-ini-config') as $iniSpec) { |
|
| 214 | + foreach ($input->getOption('child-process-php-ini-config') as $iniSpec) { |
|
| 215 | 215 | $ini = explode(':', $iniSpec, 2); |
| 216 | 216 | if (count($ini) < 2 || $ini[0] === '') { |
| 217 | 217 | throw new \Exception("Invalid php ini specification: '$iniSpec'"); |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | foreach ($toExecute as $name => $migrationDefinition) { |
| 241 | 241 | // let's skip migrations that we know are invalid - user was warned and he decided to proceed anyway |
| 242 | 242 | if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) { |
| 243 | - $this->writeln("<comment>Skipping migration (invalid definition?) Path: ".$migrationDefinition->path."</comment>", self::VERBOSITY_CHILD); |
|
| 243 | + $this->writeln("<comment>Skipping migration (invalid definition?) Path: " . $migrationDefinition->path . "</comment>", self::VERBOSITY_CHILD); |
|
| 244 | 244 | $skipped++; |
| 245 | 245 | continue; |
| 246 | 246 | } |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $this->executeMigrationInProcess($migrationDefinition, $force, $migrationService, $input); |
| 281 | 281 | |
| 282 | 282 | $executed++; |
| 283 | - } catch(\Exception $e) { |
|
| 283 | + } catch (\Exception $e) { |
|
| 284 | 284 | $failed++; |
| 285 | 285 | |
| 286 | 286 | $errorMessage = $e->getMessage(); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | * @param string $buffer |
| 314 | 314 | * @param null|\Symfony\Component\Process\Process $process |
| 315 | 315 | */ |
| 316 | - public function onChildProcessOutput($type, $buffer, $process=null) |
|
| 316 | + public function onChildProcessOutput($type, $buffer, $process = null) |
|
| 317 | 317 | { |
| 318 | 318 | $lines = explode("\n", trim($buffer)); |
| 319 | 319 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | // we tag the output with the id of the child process |
| 333 | 333 | if (trim($line) !== '') { |
| 334 | - $msg = '[' . ($process ? $process->getPid() : ''). '] ' . trim($line); |
|
| 334 | + $msg = '[' . ($process ? $process->getPid() : '') . '] ' . trim($line); |
|
| 335 | 335 | if ($type == 'err') { |
| 336 | 336 | $this->writeErrorln($msg, OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW); |
| 337 | 337 | } else { |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | |
| 366 | 366 | // filter away all migrations except 'to do' ones |
| 367 | 367 | $toExecute = array(); |
| 368 | - foreach($migrationDefinitions as $name => $migrationDefinition) { |
|
| 368 | + foreach ($migrationDefinitions as $name => $migrationDefinition) { |
|
| 369 | 369 | if (!isset($migrations[$name]) || (($migration = $migrations[$name]) && in_array($migration->status, $allowedStatuses))) { |
| 370 | 370 | $toExecute[$name] = $isChild ? $migrationService->parseMigrationDefinition($migrationDefinition) : $migrationDefinition; |
| 371 | 371 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | { |
| 408 | 408 | $output->writeln('Found ' . count($toExecute) . ' migrations in ' . count($paths) . ' directories'); |
| 409 | 409 | $output->writeln('In the same directories, migrations previously executed: ' . $this->migrationsAlreadyDone[Migration::STATUS_DONE] . |
| 410 | - ', failed: ' . $this->migrationsAlreadyDone[Migration::STATUS_FAILED] . ', skipped: '. $this->migrationsAlreadyDone[Migration::STATUS_SKIPPED]); |
|
| 410 | + ', failed: ' . $this->migrationsAlreadyDone[Migration::STATUS_FAILED] . ', skipped: ' . $this->migrationsAlreadyDone[Migration::STATUS_SKIPPED]); |
|
| 411 | 411 | if ($this->migrationsAlreadyDone[Migration::STATUS_STARTED]) { |
| 412 | 412 | $output->writeln('<info>In the same directories, migrations currently executing: ' . $this->migrationsAlreadyDone[Migration::STATUS_STARTED] . '</info>'); |
| 413 | 413 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | protected function groupMigrationsByPath($toExecute) |
| 421 | 421 | { |
| 422 | 422 | $paths = array(); |
| 423 | - foreach($toExecute as $name => $migrationDefinition) { |
|
| 423 | + foreach ($toExecute as $name => $migrationDefinition) { |
|
| 424 | 424 | $path = dirname($migrationDefinition->path); |
| 425 | 425 | if (!isset($paths[$path])) { |
| 426 | 426 | $paths[$path] = 1; |
@@ -497,12 +497,12 @@ discard block |
||
| 497 | 497 | $builderArgs[] = '--separate-process'; |
| 498 | 498 | } |
| 499 | 499 | if ($input->getOption('set-reference')) { |
| 500 | - foreach($input->getOption('set-reference') as $refSpec) { |
|
| 500 | + foreach ($input->getOption('set-reference') as $refSpec) { |
|
| 501 | 501 | $builderArgs[] = '--set-reference=' . $refSpec; |
| 502 | 502 | } |
| 503 | 503 | } |
| 504 | 504 | if ($input->getOption('child-process-php-ini-config')) { |
| 505 | - foreach($input->getOption('child-process-php-ini-config') as $iniSpec) { |
|
| 505 | + foreach ($input->getOption('child-process-php-ini-config') as $iniSpec) { |
|
| 506 | 506 | $builderArgs[] = '--child-process-php-ini-config=' . $iniSpec; |
| 507 | 507 | } |
| 508 | 508 | } |
@@ -94,13 +94,13 @@ |
||
| 94 | 94 | protected function normalizePaths($paths) |
| 95 | 95 | { |
| 96 | 96 | $rootDir = realpath($this->getContainer()->get('kernel')->getRootDir() . '/..') . '/'; |
| 97 | - foreach($paths as $i => $path) { |
|
| 97 | + foreach ($paths as $i => $path) { |
|
| 98 | 98 | if ($path === $rootDir || $path === './') { |
| 99 | 99 | $paths[$i] = './'; |
| 100 | 100 | } else if (strpos($path, './') === 0) { |
| 101 | 101 | $paths[$i] = substr($path, 2); |
| 102 | 102 | // q: should we also call realpath on $path? what if there are symlinks at play? |
| 103 | - } elseif (strpos($path, $rootDir) === 0 ) { |
|
| 103 | + } elseif (strpos($path, $rootDir) === 0) { |
|
| 104 | 104 | $paths[$i] = substr($path, strlen($rootDir)); |
| 105 | 105 | } elseif ($path === '') { |
| 106 | 106 | unset($paths[$i]); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | // which is misleading. We add the following loop to fix that, so that the status command will match more closely |
| 94 | 94 | // the 'migrate' command |
| 95 | 95 | if (count($paths)) { |
| 96 | - foreach($index as $migrationName => $data) { |
|
| 96 | + foreach ($index as $migrationName => $data) { |
|
| 97 | 97 | if (!isset($data['migration'])) { |
| 98 | 98 | $migration = $migrationsService->getMigration($migrationName); |
| 99 | 99 | if ($migration !== null) { |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | if ($input->getOption('todo')) { |
| 233 | 233 | foreach ($data as $migrationData) { |
| 234 | - $output->writeln("$migrationData", OutputInterface::OUTPUT_RAW|OutputInterface::VERBOSITY_QUIET); |
|
| 234 | + $output->writeln("$migrationData", OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_QUIET); |
|
| 235 | 235 | } |
| 236 | 236 | return 0; |
| 237 | 237 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | protected function sortMigrationIndex(array &$index, $sortBy) |
| 262 | 262 | { |
| 263 | - switch($sortBy) { |
|
| 263 | + switch ($sortBy) { |
|
| 264 | 264 | case 'execution': |
| 265 | 265 | uasort($index, function($m1, $m2) { |
| 266 | 266 | if (isset($m1['migration']) && $m1['migration']->executionDate !== null) { |