@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $this->configuration = $this->getMigrationConfiguration($input, $output); |
| 72 | 72 | |
| 73 | - if (! $input->getOption('add') && ! $input->getOption('delete')) { |
|
| 73 | + if (!$input->getOption('add') && !$input->getOption('delete')) { |
|
| 74 | 74 | throw new \InvalidArgumentException('You must specify whether you want to --add or --delete the specified version.'); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -126,26 +126,26 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | private function mark($version, $all = false) |
| 128 | 128 | { |
| 129 | - if (! $this->configuration->hasVersion($version)) { |
|
| 129 | + if (!$this->configuration->hasVersion($version)) { |
|
| 130 | 130 | throw MigrationException::unknownMigrationVersion($version); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $version = $this->configuration->getVersion($version); |
| 134 | 134 | if ($this->markMigrated && $this->configuration->hasVersionMigrated($version)) { |
| 135 | - if (! $all) { |
|
| 135 | + if (!$all) { |
|
| 136 | 136 | throw new \InvalidArgumentException(sprintf('The version "%s" already exists in the version table.', $version)); |
| 137 | 137 | } |
| 138 | 138 | $marked = true; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if (! $this->markMigrated && ! $this->configuration->hasVersionMigrated($version)) { |
|
| 142 | - if (! $all) { |
|
| 141 | + if (!$this->markMigrated && !$this->configuration->hasVersionMigrated($version)) { |
|
| 142 | + if (!$all) { |
|
| 143 | 143 | throw new \InvalidArgumentException(sprintf('The version "%s" does not exist in the version table.', $version)); |
| 144 | 144 | } |
| 145 | 145 | $marked = false; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if (! isset($marked)) { |
|
| 148 | + if (!isset($marked)) { |
|
| 149 | 149 | if ($this->markMigrated) { |
| 150 | 150 | $version->markMigrated(); |
| 151 | 151 | } else { |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $name = $configuration->getName(); |
| 58 | 58 | $name = $name ? $name : 'Doctrine Database Migrations'; |
| 59 | - $name = str_repeat(' ', 20) . $name . str_repeat(' ', 20); |
|
| 60 | - $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>'); |
|
| 61 | - $output->writeln('<question>' . $name . '</question>'); |
|
| 62 | - $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>'); |
|
| 59 | + $name = str_repeat(' ', 20).$name.str_repeat(' ', 20); |
|
| 60 | + $output->writeln('<question>'.str_repeat(' ', strlen($name)).'</question>'); |
|
| 61 | + $output->writeln('<question>'.$name.'</question>'); |
|
| 62 | + $output->writeln('<question>'.str_repeat(' ', strlen($name)).'</question>'); |
|
| 63 | 63 | $output->writeln(''); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | protected function getMigrationConfiguration(InputInterface $input, OutputInterface $output) |
| 81 | 81 | { |
| 82 | - if (! $this->migrationConfiguration) { |
|
| 82 | + if (!$this->migrationConfiguration) { |
|
| 83 | 83 | if ($this->getHelperSet()->has('configuration') |
| 84 | 84 | && $this->getHelperSet()->get('configuration') instanceof ConfigurationHelperInterface) { |
| 85 | 85 | $configHelper = $this->getHelperSet()->get('configuration'); |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | private function getOutputWriter(OutputInterface $output) |
| 108 | 108 | { |
| 109 | - if (! $this->outputWriter) { |
|
| 110 | - $this->outputWriter = new OutputWriter(function ($message) use ($output) { |
|
| 109 | + if (!$this->outputWriter) { |
|
| 110 | + $this->outputWriter = new OutputWriter(function($message) use ($output) { |
|
| 111 | 111 | return $output->writeln($message); |
| 112 | 112 | }); |
| 113 | 113 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | new ConnectionConfigurationLoader($this->configuration), |
| 134 | 134 | ] |
| 135 | 135 | ); |
| 136 | - $connection = $chainLoader->chosen(); |
|
| 136 | + $connection = $chainLoader->chosen(); |
|
| 137 | 137 | |
| 138 | 138 | if ($connection) { |
| 139 | 139 | return $this->connection = $connection; |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Doctrine\DBAL\Migrations\Tools\Console\Helper; |
| 6 | 6 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $dir = $dir ? $dir : getcwd(); |
| 27 | 27 | $dir = rtrim($dir, '/'); |
| 28 | 28 | |
| 29 | - if (! file_exists($dir)) { |
|
| 29 | + if (!file_exists($dir)) { |
|
| 30 | 30 | throw new \InvalidArgumentException(sprintf('Migrations directory "%s" does not exist.', $dir)); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | private function appendDir($dir) |
| 46 | 46 | { |
| 47 | - return DIRECTORY_SEPARATOR . $dir; |
|
| 47 | + return DIRECTORY_SEPARATOR.$dir; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | private function createDirIfNotExists($dir) |
| 51 | 51 | { |
| 52 | - if (! file_exists($dir)) { |
|
| 52 | + if (!file_exists($dir)) { |
|
| 53 | 53 | mkdir($dir, 0755, true); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | protected function getRealPath($directory) |
| 17 | 17 | { |
| 18 | 18 | $dir = realpath($directory); |
| 19 | - if ($dir === false || ! is_dir($dir)) { |
|
| 19 | + if ($dir === false || !is_dir($dir)) { |
|
| 20 | 20 | throw new \InvalidArgumentException(sprintf( |
| 21 | 21 | 'Cannot load migrations from "%s" because it is not a valid directory', |
| 22 | 22 | $directory |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $version = (string) substr($className, 7); |
| 45 | 45 | if ($version === '0') { |
| 46 | 46 | throw new \InvalidArgumentException(sprintf( |
| 47 | - 'Cannot load a migrations with the name "%s" because it is a reserved number by doctrine migrations' . PHP_EOL . |
|
| 47 | + 'Cannot load a migrations with the name "%s" because it is a reserved number by doctrine migrations'.PHP_EOL. |
|
| 48 | 48 | 'It\'s used to revert all migrations including the first one.', |
| 49 | 49 | $version |
| 50 | 50 | )); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | protected function getFileSortCallback() |
| 64 | 64 | { |
| 65 | - return function ($a, $b) { |
|
| 65 | + return function($a, $b) { |
|
| 66 | 66 | return (basename($a) < basename($b)) ? -1 : 1; |
| 67 | 67 | }; |
| 68 | 68 | } |
@@ -187,10 +187,10 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function validate() |
| 189 | 189 | { |
| 190 | - if (! $this->migrationsNamespace) { |
|
| 190 | + if (!$this->migrationsNamespace) { |
|
| 191 | 191 | throw MigrationException::migrationsNamespaceRequired(); |
| 192 | 192 | } |
| 193 | - if (! $this->migrationsDirectory) { |
|
| 193 | + if (!$this->migrationsDirectory) { |
|
| 194 | 194 | throw MigrationException::migrationsDirectoryRequired(); |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | public function setMigrationsFinder(MigrationFinderInterface $finder) |
| 386 | 386 | { |
| 387 | 387 | if (($this->migrationsAreOrganizedByYear || $this->migrationsAreOrganizedByYearAndMonth) |
| 388 | - && ! ($finder instanceof MigrationDeepFinderInterface)) { |
|
| 388 | + && !($finder instanceof MigrationDeepFinderInterface)) { |
|
| 389 | 389 | throw MigrationException::configurationIncompatibleWithFinder( |
| 390 | 390 | 'organize-migrations', |
| 391 | 391 | $finder |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $this->registerMigrationsFromDirectory($this->getMigrationsDirectory()); |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - if (! isset($this->migrations[$version])) { |
|
| 484 | + if (!isset($this->migrations[$version])) { |
|
| 485 | 485 | throw MigrationException::unknownMigrationVersion($version); |
| 486 | 486 | } |
| 487 | 487 | |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $this->createMigrationTable(); |
| 516 | 516 | |
| 517 | 517 | $version = $this->connection->fetchColumn( |
| 518 | - 'SELECT ' . $this->migrationsColumnName . ' FROM ' . $this->migrationsTableName . ' WHERE ' . $this->migrationsColumnName . ' = ?', |
|
| 518 | + 'SELECT '.$this->migrationsColumnName.' FROM '.$this->migrationsTableName.' WHERE '.$this->migrationsColumnName.' = ?', |
|
| 519 | 519 | [$version->getVersion()] |
| 520 | 520 | ); |
| 521 | 521 | |
@@ -531,13 +531,13 @@ discard block |
||
| 531 | 531 | { |
| 532 | 532 | $this->createMigrationTable(); |
| 533 | 533 | |
| 534 | - if (! $this->migrationTableCreated && $this->isDryRun) { |
|
| 534 | + if (!$this->migrationTableCreated && $this->isDryRun) { |
|
| 535 | 535 | return []; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | $this->connect(); |
| 539 | 539 | |
| 540 | - $ret = $this->connection->fetchAll('SELECT ' . $this->migrationsColumnName . ' FROM ' . $this->migrationsTableName); |
|
| 540 | + $ret = $this->connection->fetchAll('SELECT '.$this->migrationsColumnName.' FROM '.$this->migrationsTableName); |
|
| 541 | 541 | |
| 542 | 542 | return array_map('current', $ret); |
| 543 | 543 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | { |
| 572 | 572 | $this->createMigrationTable(); |
| 573 | 573 | |
| 574 | - if (! $this->migrationTableCreated && $this->isDryRun) { |
|
| 574 | + if (!$this->migrationTableCreated && $this->isDryRun) { |
|
| 575 | 575 | return '0'; |
| 576 | 576 | } |
| 577 | 577 | |
@@ -582,12 +582,12 @@ discard block |
||
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | $where = null; |
| 585 | - if (! empty($this->migrations)) { |
|
| 585 | + if (!empty($this->migrations)) { |
|
| 586 | 586 | $migratedVersions = []; |
| 587 | 587 | foreach ($this->migrations as $migration) { |
| 588 | 588 | $migratedVersions[] = sprintf("'%s'", $migration->getVersion()); |
| 589 | 589 | } |
| 590 | - $where = ' WHERE ' . $this->migrationsColumnName . ' IN (' . implode(', ', $migratedVersions) . ')'; |
|
| 590 | + $where = ' WHERE '.$this->migrationsColumnName.' IN ('.implode(', ', $migratedVersions).')'; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | $sql = sprintf( |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | $versions = array_map('strval', array_keys($this->migrations)); |
| 646 | 646 | array_unshift($versions, '0'); |
| 647 | 647 | $offset = array_search((string) $version, $versions); |
| 648 | - if ($offset === false || ! isset($versions[$offset + $delta])) { |
|
| 648 | + if ($offset === false || !isset($versions[$offset + $delta])) { |
|
| 649 | 649 | // Unknown version or delta out of bounds. |
| 650 | 650 | return null; |
| 651 | 651 | } |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | $this->connect(); |
| 731 | 731 | $this->createMigrationTable(); |
| 732 | 732 | |
| 733 | - $result = $this->connection->fetchColumn('SELECT COUNT(' . $this->migrationsColumnName . ') FROM ' . $this->migrationsTableName); |
|
| 733 | + $result = $this->connection->fetchColumn('SELECT COUNT('.$this->migrationsColumnName.') FROM '.$this->migrationsTableName); |
|
| 734 | 734 | |
| 735 | 735 | return $result !== false ? $result : 0; |
| 736 | 736 | } |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | */ |
| 925 | 925 | private function ensureOrganizeMigrationsIsCompatibleWithFinder() |
| 926 | 926 | { |
| 927 | - if (! ($this->migrationFinder instanceof MigrationDeepFinderInterface)) { |
|
| 927 | + if (!($this->migrationFinder instanceof MigrationDeepFinderInterface)) { |
|
| 928 | 928 | throw MigrationException::configurationIncompatibleWithFinder( |
| 929 | 929 | 'organize-migrations', |
| 930 | 930 | $this->migrationFinder |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | private function shouldExecuteMigration($direction, Version $version, $to, $migrated) |
| 947 | 947 | { |
| 948 | 948 | if ($direction === Version::DIRECTION_DOWN) { |
| 949 | - if (! in_array($version->getVersion(), $migrated)) { |
|
| 949 | + if (!in_array($version->getVersion(), $migrated)) { |
|
| 950 | 950 | return false; |
| 951 | 951 | } |
| 952 | 952 | |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | */ |
| 970 | 970 | private function ensureMigrationClassExists($class) |
| 971 | 971 | { |
| 972 | - if (! class_exists($class)) { |
|
| 972 | + if (!class_exists($class)) { |
|
| 973 | 973 | throw MigrationException::migrationClassNotFound($class, $this->getMigrationsNamespace()); |
| 974 | 974 | } |
| 975 | 975 | } |
@@ -15,13 +15,13 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | protected function doLoad($file) |
| 17 | 17 | { |
| 18 | - if (! class_exists(Yaml::class)) { |
|
| 18 | + if (!class_exists(Yaml::class)) { |
|
| 19 | 19 | throw MigrationException::yamlConfigurationNotAvailable(); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | $config = Yaml::parse(file_get_contents($file)); |
| 23 | 23 | |
| 24 | - if (! is_array($config)) { |
|
| 24 | + if (!is_array($config)) { |
|
| 25 | 25 | throw new \InvalidArgumentException('Not valid configuration.'); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -28,12 +28,12 @@ |
||
| 28 | 28 | return null; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if (! file_exists($this->filename)) { |
|
| 31 | + if (!file_exists($this->filename)) { |
|
| 32 | 32 | return null; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $params = include $this->filename; |
| 36 | - if (! is_array($params)) { |
|
| 36 | + if (!is_array($params)) { |
|
| 37 | 37 | throw new \InvalidArgumentException('The connection file has to return an array with database configuration parameters.'); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -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 | } |
@@ -98,14 +98,14 @@ discard block |
||
| 98 | 98 | throw MigrationException::configurationFileAlreadyLoaded(); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $path = getcwd() . '/' . $file; |
|
| 101 | + $path = getcwd().'/'.$file; |
|
| 102 | 102 | |
| 103 | 103 | if (file_exists($path)) { |
| 104 | 104 | $file = $path; |
| 105 | 105 | } |
| 106 | 106 | $this->file = $file; |
| 107 | 107 | |
| 108 | - if (! file_exists($file)) { |
|
| 108 | + if (!file_exists($file)) { |
|
| 109 | 109 | throw new \InvalidArgumentException('Given config file does not exist'); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | protected function getDirectoryRelativeToFile($file, $input) |
| 117 | 117 | { |
| 118 | - $path = realpath(dirname($file) . '/' . $input); |
|
| 118 | + $path = realpath(dirname($file).'/'.$input); |
|
| 119 | 119 | |
| 120 | 120 | return ($path !== false) ? $path : $input; |
| 121 | 121 | } |