@@ -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); |
@@ -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 | |
@@ -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 |
@@ -145,7 +145,9 @@ discard block |
||
| 145 | 145 | // q: when getting a query via QueryType, should we always inject offset/limit? |
| 146 | 146 | $query->limit = $limit != 0 ? $limit : $this->queryLimit; |
| 147 | 147 | $query->offset = $offset; |
| 148 | - if (isset($query->performCount)) $query->performCount = false; |
|
| 148 | + if (isset($query->performCount)) { |
|
| 149 | + $query->performCount = false; |
|
| 150 | + } |
|
| 149 | 151 | if (!empty($sort)) { |
| 150 | 152 | $query->sortClauses = $this->getSortClauses($sort); |
| 151 | 153 | } else { |
@@ -271,7 +273,9 @@ discard block |
||
| 271 | 273 | { |
| 272 | 274 | $query = new Query(); |
| 273 | 275 | $query->limit = $this->queryLimit; |
| 274 | - if (isset($query->performCount)) $query->performCount = false; |
|
| 276 | + if (isset($query->performCount)) { |
|
| 277 | + $query->performCount = false; |
|
| 278 | + } |
|
| 275 | 279 | $query->filter = new Query\Criterion\ParentLocationId($parentLocationIds); |
| 276 | 280 | $results = $this->getSearchService()->findContent($query); |
| 277 | 281 | |
@@ -311,7 +315,9 @@ discard block |
||
| 311 | 315 | { |
| 312 | 316 | $query = new Query(); |
| 313 | 317 | $query->limit = $this->queryLimit; |
| 314 | - if (isset($query->performCount)) $query->performCount = false; |
|
| 318 | + if (isset($query->performCount)) { |
|
| 319 | + $query->performCount = false; |
|
| 320 | + } |
|
| 315 | 321 | $query->filter = new Query\Criterion\ContentTypeIdentifier($contentTypeIdentifiers); |
| 316 | 322 | // sort objects by depth, lower to higher, so that deleting them has less chances of failure |
| 317 | 323 | // NB: we only do this in eZP versions that allow depth sorting on content queries |
@@ -339,7 +345,9 @@ discard block |
||
| 339 | 345 | { |
| 340 | 346 | $query = new Query(); |
| 341 | 347 | $query->limit = $this->queryLimit; |
| 342 | - if (isset($query->performCount)) $query->performCount = false; |
|
| 348 | + if (isset($query->performCount)) { |
|
| 349 | + $query->performCount = false; |
|
| 350 | + } |
|
| 343 | 351 | $query->filter = new Query\Criterion\ContentTypeId($contentTypeIds); |
| 344 | 352 | // sort objects by depth, lower to higher, so that deleting them has less chances of failure |
| 345 | 353 | // NB: we only do this in eZP versions that allow depth sorting on content queries |