Passed
Push — master ( 6fa9cc...aa75bf )
by Gaetano
03:49
created
Command/ResumeCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         $forcedRefs = array();
100 100
         if ($input->getOption('set-reference') /*&& !$input->getOption('separate-process')*/) {
101 101
             $refResolver = $this->getContainer()->get('ez_migration_bundle.reference_resolver.customreference');
102
-            foreach($input->getOption('set-reference') as $refSpec) {
102
+            foreach ($input->getOption('set-reference') as $refSpec) {
103 103
                 $ref = explode(':', $refSpec, 2);
104 104
                 if (count($ref) < 2 || $ref[0] === '') {
105 105
                     throw new MigrationBundleException("Invalid reference specification: '$refSpec'");
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
         $executed = 0;
112 112
         $failed = 0;
113 113
 
114
-        foreach($suspendedMigrations as $suspendedMigration) {
114
+        foreach ($suspendedMigrations as $suspendedMigration) {
115 115
             $output->writeln("<info>Resuming {$suspendedMigration->name}</info>");
116 116
 
117 117
             try {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
         $time = microtime(true) - $start;
133 133
         $output->writeln("Resumed $executed migrations, failed $failed");
134
-        $output->writeln("Time taken: ".sprintf('%.3f', $time)." secs, memory: ".sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)). ' MB');
134
+        $output->writeln("Time taken: " . sprintf('%.3f', $time) . " secs, memory: " . sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)) . ' MB');
135 135
 
136 136
         if ($failed) {
137 137
             return 2;
Please login to merge, or discard this patch.
Command/MassMigrateCommand.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
         $processes = array();
135 135
         /** @var MigrationDefinition $migrationDefinition */
136
-        foreach($paths as $path => $count) {
136
+        foreach ($paths as $path => $count) {
137 137
             $this->writeln("<info>Queueing processing of: $path ($count migrations)</info>", OutputInterface::VERBOSITY_VERBOSE);
138 138
 
139 139
             $process = $builder
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
         }
181 181
 
182 182
         $missed = $total - $this->migrationsDone[Migration::STATUS_DONE] - $this->migrationsDone[Migration::STATUS_FAILED] - $this->migrationsDone[Migration::STATUS_SKIPPED];
183
-        $this->writeln("\nExecuted ".$this->migrationsDone[Migration::STATUS_DONE].' migrations'.
184
-            ', failed '.$this->migrationsDone[Migration::STATUS_FAILED].
185
-            ', skipped '.$this->migrationsDone[Migration::STATUS_SKIPPED].
183
+        $this->writeln("\nExecuted " . $this->migrationsDone[Migration::STATUS_DONE] . ' migrations' .
184
+            ', failed ' . $this->migrationsDone[Migration::STATUS_FAILED] .
185
+            ', skipped ' . $this->migrationsDone[Migration::STATUS_SKIPPED] .
186 186
             ($missed ? ", missed $missed" : ''));
187 187
 
188 188
         $time = microtime(true) - $start;
189 189
         // since we use subprocesses, we can not measure max memory used
190
-        $this->writeln("<info>Time taken: ".sprintf('%.3f', $time)." secs</info>");
190
+        $this->writeln("<info>Time taken: " . sprintf('%.3f', $time) . " secs</info>");
191 191
 
192 192
         return $subprocessesFailed + $this->migrationsDone[Migration::STATUS_FAILED] + $missed;
193 193
     }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                 $prefix = array($php);
213 213
 
214 214
                 if ($input->getOption('child-process-php-ini-config')) {
215
-                    foreach($input->getOption('child-process-php-ini-config') as $iniSpec) {
215
+                    foreach ($input->getOption('child-process-php-ini-config') as $iniSpec) {
216 216
                         $ini = explode(':', $iniSpec, 2);
217 217
                         if (count($ini) < 2 || $ini[0] === '') {
218 218
                             throw new MigrationBundleException("Invalid php ini specification: '$iniSpec'");
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         foreach ($toExecute as  $name => $migrationDefinition) {
242 242
             // let's skip migrations that we know are invalid - user was warned and he decided to proceed anyway
243 243
             if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) {
244
-                $this->writeln("<comment>Skipping migration (invalid definition?) Path: ".$migrationDefinition->path."</comment>", self::$VERBOSITY_CHILD);
244
+                $this->writeln("<comment>Skipping migration (invalid definition?) Path: " . $migrationDefinition->path . "</comment>", self::$VERBOSITY_CHILD);
245 245
                 $skipped++;
246 246
                 continue;
247 247
             }
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
                     $this->executeMigrationInProcess($migrationDefinition, $force, $migrationService, $input);
282 282
 
283 283
                     $executed++;
284
-                } catch(\Exception $e) {
284
+                } catch (\Exception $e) {
285 285
                     $failed++;
286 286
 
287 287
                     $errorMessage = $e->getMessage();
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      * @param string $buffer
315 315
      * @param null|\Symfony\Component\Process\Process $process
316 316
      */
317
-    public function onChildProcessOutput($type, $buffer, $process=null)
317
+    public function onChildProcessOutput($type, $buffer, $process = null)
318 318
     {
319 319
         $lines = explode("\n", trim($buffer));
320 320
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
             // we tag the output with the id of the child process
334 334
             if (trim($line) !== '') {
335
-                $msg = '[' . ($process ? $process->getPid() : ''). '] ' . trim($line);
335
+                $msg = '[' . ($process ? $process->getPid() : '') . '] ' . trim($line);
336 336
                 if ($type == 'err') {
337 337
                     $this->writeErrorln($msg, OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW);
338 338
                 } else {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 
367 367
         // filter away all migrations except 'to do' ones
368 368
         $toExecute = array();
369
-        foreach($migrationDefinitions as $name => $migrationDefinition) {
369
+        foreach ($migrationDefinitions as $name => $migrationDefinition) {
370 370
             if (!isset($migrations[$name]) || (($migration = $migrations[$name]) && in_array($migration->status, $allowedStatuses))) {
371 371
                 $toExecute[$name] = $isChild ? $migrationService->parseMigrationDefinition($migrationDefinition) : $migrationDefinition;
372 372
             }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     {
409 409
         $output->writeln('Found ' . count($toExecute) . ' migrations in ' . count($paths) . ' directories');
410 410
         $output->writeln('In the same directories, migrations previously executed: ' . $this->migrationsAlreadyDone[Migration::STATUS_DONE] .
411
-            ', failed: ' . $this->migrationsAlreadyDone[Migration::STATUS_FAILED] . ', skipped: '. $this->migrationsAlreadyDone[Migration::STATUS_SKIPPED]);
411
+            ', failed: ' . $this->migrationsAlreadyDone[Migration::STATUS_FAILED] . ', skipped: ' . $this->migrationsAlreadyDone[Migration::STATUS_SKIPPED]);
412 412
         if ($this->migrationsAlreadyDone[Migration::STATUS_STARTED]) {
413 413
             $output->writeln('<info>In the same directories, migrations currently executing: ' . $this->migrationsAlreadyDone[Migration::STATUS_STARTED] . '</info>');
414 414
         }
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
     protected function groupMigrationsByPath($toExecute)
422 422
     {
423 423
         $paths = array();
424
-        foreach($toExecute as $name => $migrationDefinition) {
424
+        foreach ($toExecute as $name => $migrationDefinition) {
425 425
             $path = dirname($migrationDefinition->path);
426 426
             if (!isset($paths[$path])) {
427 427
                 $paths[$path] = 1;
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
             $builderArgs[] = '--separate-process';
499 499
         }
500 500
         if ($input->getOption('set-reference')) {
501
-            foreach($input->getOption('set-reference') as $refSpec) {
501
+            foreach ($input->getOption('set-reference') as $refSpec) {
502 502
                 $builderArgs[] = '--set-reference=' . $refSpec;
503 503
             }
504 504
         }
505 505
         if ($input->getOption('child-process-php-ini-config')) {
506
-            foreach($input->getOption('child-process-php-ini-config') as $iniSpec) {
506
+            foreach ($input->getOption('child-process-php-ini-config') as $iniSpec) {
507 507
                 $builderArgs[] = '--child-process-php-ini-config=' . $iniSpec;
508 508
             }
509 509
         }
Please login to merge, or discard this patch.
Command/MigrateCommand.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                 $prefix = array($php);
125 125
 
126 126
                 if ($input->getOption('child-process-php-ini-config')) {
127
-                    foreach($input->getOption('child-process-php-ini-config') as $iniSpec) {
127
+                    foreach ($input->getOption('child-process-php-ini-config') as $iniSpec) {
128 128
                         $ini = explode(':', $iniSpec, 2);
129 129
                         if (count($ini) < 2 || $ini[0] === '') {
130 130
                             throw new MigrationBundleException("Invalid php ini specification: '$iniSpec'");
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
         if ($input->getOption('set-reference') && !$input->getOption('separate-process')) {
152 152
             $refResolver = $this->getContainer()->get('ez_migration_bundle.reference_resolver.customreference');
153
-            foreach($input->getOption('set-reference') as $refSpec) {
153
+            foreach ($input->getOption('set-reference') as $refSpec) {
154 154
                 $ref = explode(':', $refSpec, 2);
155 155
                 if (count($ref) < 2 || $ref[0] === '') {
156 156
                     throw new MigrationBundleException("Invalid reference specification: '$refSpec'");
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
         $time = microtime(true) - $start;
251 251
         if ($input->getOption('separate-process')) {
252 252
             // in case of using subprocesses, we can not measure max memory used
253
-            $this->writeln("<info>Time taken: ".sprintf('%.3f', $time)." secs</info>");
253
+            $this->writeln("<info>Time taken: " . sprintf('%.3f', $time) . " secs</info>");
254 254
         } else {
255
-            $this->writeln("<info>Time taken: ".sprintf('%.3f', $time)." secs, memory: ".sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)). ' MB</info>');
255
+            $this->writeln("<info>Time taken: " . sprintf('%.3f', $time) . " secs, memory: " . sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)) . ' MB</info>');
256 256
         }
257 257
 
258 258
         return $failed;
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
             $builderArgs[] = '--no-debug';
485 485
         }
486 486
         if ($input->getOption('siteaccess')) {
487
-            $builderArgs[] = '--siteaccess='.$input->getOption('siteaccess');
487
+            $builderArgs[] = '--siteaccess=' . $input->getOption('siteaccess');
488 488
         }
489 489
         switch ($this->verbosity) {
490 490
             case OutputInterface::VERBOSITY_VERBOSE:
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             $builderArgs[] = '--no-transactions';
517 517
         }
518 518
         if ($input->getOption('set-reference')) {
519
-            foreach($input->getOption('set-reference') as $refSpec) {
519
+            foreach ($input->getOption('set-reference') as $refSpec) {
520 520
                 $builderArgs[] = '--set-reference=' . $refSpec;
521 521
             }
522 522
         }
Please login to merge, or discard this patch.
Core/ReferenceResolver/ExpressionResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,12 +45,12 @@
 block discarded – undo
45 45
         return array(
46 46
             new ExpressionFunction(
47 47
                 'resolve',
48
-                function ($str) {
48
+                function($str) {
49 49
                     /// @todo we could implement this via eg a static class var which holds a pointer to $this->referenceResolver
50 50
                     //return sprintf('(is_string(%1$s) ? FakerResolver::resolveExpressionLanguageReference(%1$s) : %1$s)', $str);
51 51
                     return "throw new MigrationBundleException('The \'resolve\' expression language operator can not be compiled, only evaluated'";
52 52
                 },
53
-                function ($arguments, $str) use ($resolver) {
53
+                function($arguments, $str) use ($resolver) {
54 54
                     if (!is_string($str)) {
55 55
                         return $str;
56 56
                     }
Please login to merge, or discard this patch.
Core/ReferenceResolver/ChainResolver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@
 block discarded – undo
132 132
         $refs = array();
133 133
 
134 134
         foreach ($this->resolvers as $resolver) {
135
-            if (! $resolver instanceof EnumerableReferenceResolverInterface) {
135
+            if (!$resolver instanceof EnumerableReferenceResolverInterface) {
136 136
                 // Disabled - we now allow chaining enumerable and non-enumerable sets
137 137
                 //throw new MigrationBundleException("Could not enumerate references because of chained resolver of type: " . get_class($resolver));
138 138
                 continue;
Please login to merge, or discard this patch.
Core/Executor/ReferenceExecutor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             throw new MigrationBundleException("Invalid step definition: file '$fileName' for saving references already exists");
164 164
         }
165 165
 
166
-        if (! $this->referenceResolver instanceof EnumerableReferenceResolverInterface) {
166
+        if (!$this->referenceResolver instanceof EnumerableReferenceResolverInterface) {
167 167
             throw new MigrationBundleException("Can not save references as resolver is not enumerable");
168 168
         }
169 169
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         $value = $this->dumpVar($this->referenceResolver->resolveReference($dsl['identifier']));
209 209
 
210 210
         if (isset($context['output']) && $context['output'] instanceof OutputInterface) {
211
-            $context['output']->write($label . $value, false, OutputInterface::OUTPUT_RAW|OutputInterface::VERBOSITY_NORMAL);
211
+            $context['output']->write($label . $value, false, OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_NORMAL);
212 212
         } else {
213 213
             echo $label . $value;
214 214
         }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
         $dumper->dump(
232 232
             $cloner->cloneVar($var),
233
-            function ($line, $depth) use (&$output) {
233
+            function($line, $depth) use (&$output) {
234 234
                 // A negative depth means "end of dump"
235 235
                 if ($depth >= 0) {
236 236
                     // Adds a two spaces indentation to the line
Please login to merge, or discard this patch.
Core/Loader/FilesystemRecursive.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,7 @@
 block discarded – undo
61 61
                         }
62 62
                     }
63 63
                 }
64
-            }
65
-            else {
64
+            } else {
66 65
                 throw new MigrationBundleException("Path '$path' is neither a file nor directory");
67 66
             }
68 67
         }
Please login to merge, or discard this patch.
Core/MigrationService.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         }
311 311
 
312 312
         if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) {
313
-            throw new MigrationBundleException("Can not execute " . $this->getEntityName($migrationDefinition). " '{$migrationDefinition->name}': {$migrationDefinition->parsingError}");
313
+            throw new MigrationBundleException("Can not execute " . $this->getEntityName($migrationDefinition) . " '{$migrationDefinition->name}': {$migrationDefinition->parsingError}");
314 314
         }
315 315
 
316 316
         /// @todo add support for setting in $migrationContext a userContentType, userGroupContentType ?
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 
345 345
         try {
346 346
 
347
-            $i = $stepOffset+1;
347
+            $i = $stepOffset + 1;
348 348
             $finalStatus = Migration::STATUS_DONE;
349 349
             $finalMessage = null;
350 350
 
@@ -481,12 +481,12 @@  discard block
 block discarded – undo
481 481
     public function resumeMigration(Migration $migration, $useTransaction = true, array $forcedReferences = array())
482 482
     {
483 483
         if ($migration->status != Migration::STATUS_SUSPENDED) {
484
-            throw new MigrationBundleException("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': it is not in suspended status");
484
+            throw new MigrationBundleException("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': it is not in suspended status");
485 485
         }
486 486
 
487 487
         $migrationDefinitions = $this->getMigrationsDefinitions(array($migration->path));
488 488
         if (!count($migrationDefinitions)) {
489
-            throw new MigrationBundleException("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': its definition is missing");
489
+            throw new MigrationBundleException("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': its definition is missing");
490 490
         }
491 491
 
492 492
         $defs = $migrationDefinitions->getArrayCopy();
@@ -494,24 +494,24 @@  discard block
 block discarded – undo
494 494
 
495 495
         $migrationDefinition = $this->parseMigrationDefinition($migrationDefinition);
496 496
         if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) {
497
-            throw new MigrationBundleException("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': {$migrationDefinition->parsingError}");
497
+            throw new MigrationBundleException("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': {$migrationDefinition->parsingError}");
498 498
         }
499 499
 
500 500
         // restore context
501 501
         $this->contextHandler->restoreCurrentContext($migration->name);
502 502
 
503 503
         if ($forcedReferences) {
504
-            foreach($forcedReferences as $name => $value) {
504
+            foreach ($forcedReferences as $name => $value) {
505 505
                 $this->referenceResolver->addReference($name, $value, true);
506 506
             }
507 507
         }
508 508
 
509 509
         if (!isset($this->migrationContext[$migration->name])) {
510
-            throw new MigrationBundleException("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': the stored context is missing");
510
+            throw new MigrationBundleException("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': the stored context is missing");
511 511
         }
512 512
         $restoredContext = $this->migrationContext[$migration->name];
513
-        if (!is_array($restoredContext) || !isset($restoredContext['context']) || !isset($restoredContext['step'] )) {
514
-            throw new MigrationBundleException("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': the stored context is invalid");
513
+        if (!is_array($restoredContext) || !isset($restoredContext['context']) || !isset($restoredContext['step'])) {
514
+            throw new MigrationBundleException("Can not resume " . $this->getEntityName($migration) . " '{$migration->name}': the stored context is invalid");
515 515
         }
516 516
 
517 517
         // update migration status
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
      * @param bool|null $forceSigchildEnabled
533 533
      * @return array
534 534
      */
535
-    protected function migrationContextFromParameters($defaultLanguageCode = null, $adminLogin = null, $forceSigchildEnabled = null )
535
+    protected function migrationContextFromParameters($defaultLanguageCode = null, $adminLogin = null, $forceSigchildEnabled = null)
536 536
     {
537 537
         $properties = array();
538 538
 
Please login to merge, or discard this patch.
Core/StorageHandler/Database/Migration.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     public function endMigration(APIMigration $migration, $force = false)
207 207
     {
208 208
         if ($migration->status == APIMigration::STATUS_STARTED) {
209
-            throw new MigrationBundleException($this->getEntityName($migration)." '{$migration->name}' can not be ended as its status is 'started'...");
209
+            throw new MigrationBundleException($this->getEntityName($migration) . " '{$migration->name}' can not be ended as its status is 'started'...");
210 210
         }
211 211
 
212 212
         $this->createTableIfNeeded();
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
         if (!is_array($existingMigrationData)) {
234 234
             // commit to release the lock
235 235
             $conn->commit();
236
-            throw new MigrationBundleException($this->getEntityName($migration)." '{$migration->name}' can not be ended as it is not found");
236
+            throw new MigrationBundleException($this->getEntityName($migration) . " '{$migration->name}' can not be ended as it is not found");
237 237
         }
238 238
 
239 239
         if (($existingMigrationData['status'] != APIMigration::STATUS_STARTED) && !$force) {
240 240
             // commit to release the lock
241 241
             $conn->commit();
242
-            throw new MigrationBundleException($this->getEntityName($migration)." '{$migration->name}' can not be ended as it is not executing");
242
+            throw new MigrationBundleException($this->getEntityName($migration) . " '{$migration->name}' can not be ended as it is not executing");
243 243
         }
244 244
 
245 245
         $conn->update(
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         if (!is_array($existingMigrationData)) {
396 396
             // commit immediately, to release the lock and avoid deadlocks
397 397
             $conn->commit();
398
-            throw new MigrationBundleException($this->getEntityName($migration)." '{$migration->name}' can not be resumed as it is not found");
398
+            throw new MigrationBundleException($this->getEntityName($migration) . " '{$migration->name}' can not be resumed as it is not found");
399 399
         }
400 400
 
401 401
         // migration exists
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
         if ($existingMigrationData['status'] != APIMigration::STATUS_SUSPENDED) {
405 405
             // commit to release the lock
406 406
             $conn->commit();
407
-            throw new MigrationBundleException($this->getEntityName($migration)." '{$migration->name}' can not be resumed as it is not suspended");
407
+            throw new MigrationBundleException($this->getEntityName($migration) . " '{$migration->name}' can not be resumed as it is not suspended");
408 408
         }
409 409
 
410 410
         $migration = new APIMigration(
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
         foreach ($schema->toSql($dbPlatform) as $sql) {
467 467
             try {
468 468
                 $this->dbHandler->exec($sql);
469
-            } catch(QueryException $e) {
469
+            } catch (QueryException $e) {
470 470
                 // work around limitations in both Mysql and Doctrine
471 471
                 // @see https://github.com/kaliop-uk/ezmigrationbundle/issues/176
472 472
                 if (strpos($e->getMessage(), '1071 Specified key was too long; max key length is 767 bytes') !== false &&
Please login to merge, or discard this patch.