@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | $replacements = [ |
| 101 | 101 | $configuration->getMigrationsNamespace(), |
| 102 | 102 | $version, |
| 103 | - $up ? " " . implode("\n ", explode("\n", $up)) : null, |
|
| 104 | - $down ? " " . implode("\n ", explode("\n", $down)) : null, |
|
| 103 | + $up ? " ".implode("\n ", explode("\n", $up)) : null, |
|
| 104 | + $down ? " ".implode("\n ", explode("\n", $down)) : null, |
|
| 105 | 105 | ]; |
| 106 | 106 | |
| 107 | 107 | $code = str_replace($placeHolders, $replacements, $this->getTemplate()); |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $directoryHelper = new MigrationDirectoryHelper($configuration); |
| 111 | 111 | $dir = $directoryHelper->getMigrationDirectory(); |
| 112 | - $path = $dir . '/Version' . $version . '.php'; |
|
| 112 | + $path = $dir.'/Version'.$version.'.php'; |
|
| 113 | 113 | |
| 114 | 114 | file_put_contents($path, $code); |
| 115 | 115 | |
| 116 | 116 | if ($editorCmd = $input->getOption('editor-cmd')) { |
| 117 | - proc_open($editorCmd . ' ' . escapeshellarg($path), [], $pipes); |
|
| 117 | + proc_open($editorCmd.' '.escapeshellarg($path), [], $pipes); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $path; |
@@ -128,16 +128,16 @@ discard block |
||
| 128 | 128 | return; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( ! is_file($customTemplate) || ! is_readable($customTemplate)) { |
|
| 131 | + if (!is_file($customTemplate) || !is_readable($customTemplate)) { |
|
| 132 | 132 | throw new \InvalidArgumentException( |
| 133 | - 'The specified template "' . $customTemplate . '" cannot be found or is not readable.' |
|
| 133 | + 'The specified template "'.$customTemplate.'" cannot be found or is not readable.' |
|
| 134 | 134 | ); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $content = file_get_contents($customTemplate); |
| 138 | 138 | |
| 139 | 139 | if ($content === false) { |
| 140 | - throw new \InvalidArgumentException('The specified template "' . $customTemplate . '" could not be read.'); |
|
| 140 | + throw new \InvalidArgumentException('The specified template "'.$customTemplate.'" could not be read.'); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | $output->writeln(sprintf('Using custom migration template "<info>%s</info>"', $customTemplate)); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | protected function setConfiguration(array $config) |
| 47 | 47 | { |
| 48 | 48 | foreach ($config as $configurationKey => $configurationValue) { |
| 49 | - if ( ! isset($this->configurationProperties[$configurationKey])) { |
|
| 49 | + if (!isset($this->configurationProperties[$configurationKey])) { |
|
| 50 | 50 | $msg = sprintf('Migrations configuration key "%s" does not exist.', $configurationKey); |
| 51 | 51 | throw MigrationException::configurationNotValid($msg); |
| 52 | 52 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } elseif (strcasecmp($migrationOrganisation, static::VERSIONS_ORGANIZATION_BY_YEAR_AND_MONTH) == 0) { |
| 81 | 81 | $this->setMigrationsAreOrganizedByYearAndMonth(); |
| 82 | 82 | } else { |
| 83 | - $msg = 'Unknown ' . var_export($migrationOrganisation, true) . ' for configuration "organize_migrations".'; |
|
| 83 | + $msg = 'Unknown '.var_export($migrationOrganisation, true).' for configuration "organize_migrations".'; |
|
| 84 | 84 | throw MigrationException::configurationNotValid($msg); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | if ($this->loaded) { |
| 98 | 98 | throw MigrationException::configurationFileAlreadyLoaded(); |
| 99 | 99 | } |
| 100 | - if (file_exists($path = getcwd() . '/' . $file)) { |
|
| 100 | + if (file_exists($path = getcwd().'/'.$file)) { |
|
| 101 | 101 | $file = $path; |
| 102 | 102 | } |
| 103 | 103 | $this->file = $file; |
| 104 | 104 | |
| 105 | - if ( ! file_exists($file)) { |
|
| 105 | + if (!file_exists($file)) { |
|
| 106 | 106 | throw new \InvalidArgumentException('Given config file does not exist'); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | protected function getDirectoryRelativeToFile($file, $input) |
| 114 | 114 | { |
| 115 | - $path = realpath(dirname($file) . '/' . $input); |
|
| 115 | + $path = realpath(dirname($file).'/'.$input); |
|
| 116 | 116 | |
| 117 | 117 | return ($path !== false) ? $path : $input; |
| 118 | 118 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | $this->configuration = $this->getMigrationConfiguration($input, $output); |
| 77 | 77 | |
| 78 | - if ( ! $input->getOption('add') && ! $input->getOption('delete')) { |
|
| 78 | + if (!$input->getOption('add') && !$input->getOption('delete')) { |
|
| 79 | 79 | throw new \InvalidArgumentException('You must specify whether you want to --add or --delete the specified version.'); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -131,26 +131,26 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | private function mark($version, $all = false) |
| 133 | 133 | { |
| 134 | - if ( ! $this->configuration->hasVersion($version)) { |
|
| 134 | + if (!$this->configuration->hasVersion($version)) { |
|
| 135 | 135 | throw MigrationException::unknownMigrationVersion($version); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $version = $this->configuration->getVersion($version); |
| 139 | 139 | if ($this->markMigrated && $this->configuration->hasVersionMigrated($version)) { |
| 140 | - if ( ! $all) { |
|
| 140 | + if (!$all) { |
|
| 141 | 141 | throw new \InvalidArgumentException(sprintf('The version "%s" already exists in the version table.', $version)); |
| 142 | 142 | } |
| 143 | 143 | $marked = true; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( ! $this->markMigrated && ! $this->configuration->hasVersionMigrated($version)) { |
|
| 147 | - if ( ! $all) { |
|
| 146 | + if (!$this->markMigrated && !$this->configuration->hasVersionMigrated($version)) { |
|
| 147 | + if (!$all) { |
|
| 148 | 148 | throw new \InvalidArgumentException(sprintf('The version "%s" does not exist in the version table.', $version)); |
| 149 | 149 | } |
| 150 | 150 | $marked = false; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( ! isset($marked)) { |
|
| 153 | + if (!isset($marked)) { |
|
| 154 | 154 | if ($this->markMigrated) { |
| 155 | 155 | $version->markMigrated(); |
| 156 | 156 | } else { |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function validate() |
| 195 | 195 | { |
| 196 | - if ( ! $this->migrationsNamespace) { |
|
| 196 | + if (!$this->migrationsNamespace) { |
|
| 197 | 197 | throw MigrationException::migrationsNamespaceRequired(); |
| 198 | 198 | } |
| 199 | - if ( ! $this->migrationsDirectory) { |
|
| 199 | + if (!$this->migrationsDirectory) { |
|
| 200 | 200 | throw MigrationException::migrationsDirectoryRequired(); |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | public function setMigrationsFinder(MigrationFinderInterface $finder) |
| 392 | 392 | { |
| 393 | 393 | if (($this->migrationsAreOrganizedByYear || $this->migrationsAreOrganizedByYearAndMonth) |
| 394 | - && ! ($finder instanceof MigrationDeepFinderInterface)) { |
|
| 394 | + && !($finder instanceof MigrationDeepFinderInterface)) { |
|
| 395 | 395 | throw MigrationException::configurationIncompatibleWithFinder( |
| 396 | 396 | 'organize-migrations', |
| 397 | 397 | $finder |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $this->registerMigrationsFromDirectory($this->getMigrationsDirectory()); |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - if ( ! isset($this->migrations[$version])) { |
|
| 491 | + if (!isset($this->migrations[$version])) { |
|
| 492 | 492 | throw MigrationException::unknownMigrationVersion($version); |
| 493 | 493 | } |
| 494 | 494 | |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | $this->createMigrationTable(); |
| 525 | 525 | |
| 526 | 526 | $version = $this->connection->fetchColumn( |
| 527 | - "SELECT " . $this->migrationsColumnName . " FROM " . $this->migrationsTableName . " WHERE " . $this->migrationsColumnName . " = ?", |
|
| 527 | + "SELECT ".$this->migrationsColumnName." FROM ".$this->migrationsTableName." WHERE ".$this->migrationsColumnName." = ?", |
|
| 528 | 528 | [$version->getVersion()] |
| 529 | 529 | ); |
| 530 | 530 | |
@@ -540,13 +540,13 @@ discard block |
||
| 540 | 540 | { |
| 541 | 541 | $this->createMigrationTable(); |
| 542 | 542 | |
| 543 | - if ( ! $this->migrationTableCreated && $this->isDryRun) { |
|
| 543 | + if (!$this->migrationTableCreated && $this->isDryRun) { |
|
| 544 | 544 | return []; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | $this->connect(); |
| 548 | 548 | |
| 549 | - $ret = $this->connection->fetchAll("SELECT " . $this->migrationsColumnName . " FROM " . $this->migrationsTableName); |
|
| 549 | + $ret = $this->connection->fetchAll("SELECT ".$this->migrationsColumnName." FROM ".$this->migrationsTableName); |
|
| 550 | 550 | |
| 551 | 551 | return array_map('current', $ret); |
| 552 | 552 | } |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | { |
| 581 | 581 | $this->createMigrationTable(); |
| 582 | 582 | |
| 583 | - if ( ! $this->migrationTableCreated && $this->isDryRun) { |
|
| 583 | + if (!$this->migrationTableCreated && $this->isDryRun) { |
|
| 584 | 584 | return '0'; |
| 585 | 585 | } |
| 586 | 586 | |
@@ -591,12 +591,12 @@ discard block |
||
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | $where = null; |
| 594 | - if ( ! empty($this->migrations)) { |
|
| 594 | + if (!empty($this->migrations)) { |
|
| 595 | 595 | $migratedVersions = []; |
| 596 | 596 | foreach ($this->migrations as $migration) { |
| 597 | 597 | $migratedVersions[] = sprintf("'%s'", $migration->getVersion()); |
| 598 | 598 | } |
| 599 | - $where = " WHERE " . $this->migrationsColumnName . " IN (" . implode(', ', $migratedVersions) . ")"; |
|
| 599 | + $where = " WHERE ".$this->migrationsColumnName." IN (".implode(', ', $migratedVersions).")"; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | $sql = sprintf( |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | $versions = array_map('strval', array_keys($this->migrations)); |
| 654 | 654 | array_unshift($versions, '0'); |
| 655 | 655 | $offset = array_search((string) $version, $versions); |
| 656 | - if ($offset === false || ! isset($versions[$offset + $delta])) { |
|
| 656 | + if ($offset === false || !isset($versions[$offset + $delta])) { |
|
| 657 | 657 | // Unknown version or delta out of bounds. |
| 658 | 658 | return null; |
| 659 | 659 | } |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | $this->connect(); |
| 737 | 737 | $this->createMigrationTable(); |
| 738 | 738 | |
| 739 | - $result = $this->connection->fetchColumn("SELECT COUNT(" . $this->migrationsColumnName . ") FROM " . $this->migrationsTableName); |
|
| 739 | + $result = $this->connection->fetchColumn("SELECT COUNT(".$this->migrationsColumnName.") FROM ".$this->migrationsTableName); |
|
| 740 | 740 | |
| 741 | 741 | return $result !== false ? $result : 0; |
| 742 | 742 | } |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | */ |
| 927 | 927 | private function ensureOrganizeMigrationsIsCompatibleWithFinder() |
| 928 | 928 | { |
| 929 | - if ( ! ($this->migrationFinder instanceof MigrationDeepFinderInterface)) { |
|
| 929 | + if (!($this->migrationFinder instanceof MigrationDeepFinderInterface)) { |
|
| 930 | 930 | throw MigrationException::configurationIncompatibleWithFinder( |
| 931 | 931 | 'organize-migrations', |
| 932 | 932 | $this->migrationFinder |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | private function shouldExecuteMigration($direction, Version $version, $to, $migrated) |
| 949 | 949 | { |
| 950 | 950 | if ($direction === Version::DIRECTION_DOWN) { |
| 951 | - if ( ! in_array($version->getVersion(), $migrated)) { |
|
| 951 | + if (!in_array($version->getVersion(), $migrated)) { |
|
| 952 | 952 | return false; |
| 953 | 953 | } |
| 954 | 954 | |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | */ |
| 971 | 971 | private function ensureMigrationClassExists($class) |
| 972 | 972 | { |
| 973 | - if ( ! class_exists($class)) { |
|
| 973 | + if (!class_exists($class)) { |
|
| 974 | 974 | throw MigrationException::migrationClassNotFound($class, $this->getMigrationsNamespace()); |
| 975 | 975 | } |
| 976 | 976 | } |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | protected function doLoad($file) |
| 23 | 23 | { |
| 24 | - if ( ! class_exists(Yaml::class)) { |
|
| 24 | + if (!class_exists(Yaml::class)) { |
|
| 25 | 25 | throw MigrationException::yamlConfigurationNotAvailable(); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | $config = Yaml::parse(file_get_contents($file)); |
| 29 | 29 | |
| 30 | - if ( ! is_array($config)) { |
|
| 30 | + if (!is_array($config)) { |
|
| 31 | 31 | throw new \InvalidArgumentException('Not valid configuration.'); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -170,14 +170,14 @@ discard block |
||
| 170 | 170 | if (is_array($sql)) { |
| 171 | 171 | foreach ($sql as $key => $query) { |
| 172 | 172 | $this->sql[] = $query; |
| 173 | - if ( ! empty($params[$key])) { |
|
| 173 | + if (!empty($params[$key])) { |
|
| 174 | 174 | $queryTypes = $types[$key] ?? []; |
| 175 | 175 | $this->addQueryParams($params[$key], $queryTypes); |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } else { |
| 179 | 179 | $this->sql[] = $sql; |
| 180 | - if ( ! empty($params)) { |
|
| 180 | + if (!empty($params)) { |
|
| 181 | 181 | $this->addQueryParams($params, $types); |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -207,11 +207,11 @@ discard block |
||
| 207 | 207 | { |
| 208 | 208 | $queries = $this->execute($direction, true); |
| 209 | 209 | |
| 210 | - if ( ! empty($this->params)) { |
|
| 210 | + if (!empty($this->params)) { |
|
| 211 | 211 | throw MigrationException::migrationNotConvertibleToSql($this->class); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - $this->outputWriter->write("\n-- Version " . $this->version . "\n"); |
|
| 214 | + $this->outputWriter->write("\n-- Version ".$this->version."\n"); |
|
| 215 | 215 | |
| 216 | 216 | $sqlQueries = [$this->version => $queries]; |
| 217 | 217 | |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | $this->state = self::STATE_PRE; |
| 265 | 265 | $fromSchema = $this->schemaProvider->createFromSchema(); |
| 266 | 266 | |
| 267 | - $this->migration->{'pre' . ucfirst($direction)}($fromSchema); |
|
| 267 | + $this->migration->{'pre'.ucfirst($direction)}($fromSchema); |
|
| 268 | 268 | |
| 269 | 269 | if ($direction === self::DIRECTION_UP) { |
| 270 | - $this->outputWriter->write("\n" . sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version) . "\n"); |
|
| 270 | + $this->outputWriter->write("\n".sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version)."\n"); |
|
| 271 | 271 | } else { |
| 272 | - $this->outputWriter->write("\n" . sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version) . "\n"); |
|
| 272 | + $this->outputWriter->write("\n".sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version)."\n"); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | $this->state = self::STATE_EXEC; |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | $this->executeRegisteredSql($dryRun, $timeAllQueries); |
| 283 | 283 | |
| 284 | 284 | $this->state = self::STATE_POST; |
| 285 | - $this->migration->{'post' . ucfirst($direction)}($toSchema); |
|
| 285 | + $this->migration->{'post'.ucfirst($direction)}($toSchema); |
|
| 286 | 286 | |
| 287 | - if ( ! $dryRun) { |
|
| 287 | + if (!$dryRun) { |
|
| 288 | 288 | if ($direction === self::DIRECTION_UP) { |
| 289 | 289 | $this->markMigrated(); |
| 290 | 290 | } else { |
@@ -392,13 +392,13 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | private function executeRegisteredSql($dryRun = false, $timeAllQueries = false) |
| 394 | 394 | { |
| 395 | - if ( ! $dryRun) { |
|
| 396 | - if ( ! empty($this->sql)) { |
|
| 395 | + if (!$dryRun) { |
|
| 396 | + if (!empty($this->sql)) { |
|
| 397 | 397 | foreach ($this->sql as $key => $query) { |
| 398 | 398 | $queryStart = microtime(true); |
| 399 | 399 | |
| 400 | - if ( ! isset($this->params[$key])) { |
|
| 401 | - $this->outputWriter->write(' <comment>-></comment> ' . $query); |
|
| 400 | + if (!isset($this->params[$key])) { |
|
| 401 | + $this->outputWriter->write(' <comment>-></comment> '.$query); |
|
| 402 | 402 | $this->connection->executeQuery($query); |
| 403 | 403 | } else { |
| 404 | 404 | $this->outputWriter->write(sprintf(' <comment>-></comment> %s (with parameters)', $query)); |