@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations); |
| 88 | - if (! empty($executedUnavailableMigrations)) { |
|
| 88 | + if (!empty($executedUnavailableMigrations)) { |
|
| 89 | 89 | $output->writeln(sprintf( |
| 90 | 90 | '<error>WARNING! You have %s previously executed migrations' |
| 91 | 91 | . ' in the database that are not registered migrations.</error>', |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $question = 'Are you sure you wish to continue? (y/n)'; |
| 104 | - if (! $this->canExecute($question, $input, $output)) { |
|
| 104 | + if (!$this->canExecute($question, $input, $output)) { |
|
| 105 | 105 | $output->writeln('<error>Migration cancelled!</error>'); |
| 106 | 106 | |
| 107 | 107 | return 1; |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $cancelled = false; |
| 120 | 120 | $migration->setNoMigrationException($input->getOption('allow-no-migration')); |
| 121 | - $result = $migration->migrate($version, $dryRun, $timeAllqueries, function () use ($input, $output, &$cancelled) { |
|
| 121 | + $result = $migration->migrate($version, $dryRun, $timeAllqueries, function() use ($input, $output, &$cancelled) { |
|
| 122 | 122 | $question = 'WARNING! You are about to execute a database migration' |
| 123 | 123 | . ' that could result in schema changes and data lost.' |
| 124 | 124 | . ' Are you sure you wish to continue? (y/n)'; |
| 125 | 125 | $canContinue = $this->canExecute($question, $input, $output); |
| 126 | - $cancelled = ! $canContinue; |
|
| 126 | + $cancelled = !$canContinue; |
|
| 127 | 127 | |
| 128 | 128 | return $canContinue; |
| 129 | 129 | }); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | private function canExecute($question, InputInterface $input, OutputInterface $output) |
| 153 | 153 | { |
| 154 | - if ($input->isInteractive() && ! $this->askConfirmation($question, $input, $output)) { |
|
| 154 | + if ($input->isInteractive() && !$this->askConfirmation($question, $input, $output)) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | $replacements = [ |
| 98 | 98 | $configuration->getMigrationsNamespace(), |
| 99 | 99 | $version, |
| 100 | - $up ? ' ' . implode("\n ", explode("\n", $up)) : null, |
|
| 101 | - $down ? ' ' . implode("\n ", explode("\n", $down)) : null, |
|
| 100 | + $up ? ' '.implode("\n ", explode("\n", $up)) : null, |
|
| 101 | + $down ? ' '.implode("\n ", explode("\n", $down)) : null, |
|
| 102 | 102 | ]; |
| 103 | 103 | |
| 104 | 104 | $code = str_replace($placeHolders, $replacements, $this->getTemplate()); |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | $directoryHelper = new MigrationDirectoryHelper($configuration); |
| 108 | 108 | $dir = $directoryHelper->getMigrationDirectory(); |
| 109 | - $path = $dir . '/Version' . $version . '.php'; |
|
| 109 | + $path = $dir.'/Version'.$version.'.php'; |
|
| 110 | 110 | |
| 111 | 111 | file_put_contents($path, $code); |
| 112 | 112 | |
| 113 | 113 | $editorCmd = $input->getOption('editor-cmd'); |
| 114 | 114 | |
| 115 | 115 | if ($editorCmd) { |
| 116 | - proc_open($editorCmd . ' ' . escapeshellarg($path), [], $pipes); |
|
| 116 | + proc_open($editorCmd.' '.escapeshellarg($path), [], $pipes); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | return $path; |
@@ -127,16 +127,16 @@ discard block |
||
| 127 | 127 | return; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if (! is_file($customTemplate) || ! is_readable($customTemplate)) { |
|
| 130 | + if (!is_file($customTemplate) || !is_readable($customTemplate)) { |
|
| 131 | 131 | throw new \InvalidArgumentException( |
| 132 | - 'The specified template "' . $customTemplate . '" cannot be found or is not readable.' |
|
| 132 | + 'The specified template "'.$customTemplate.'" cannot be found or is not readable.' |
|
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | $content = file_get_contents($customTemplate); |
| 137 | 137 | |
| 138 | 138 | if ($content === false) { |
| 139 | - throw new \InvalidArgumentException('The specified template "' . $customTemplate . '" could not be read.'); |
|
| 139 | + throw new \InvalidArgumentException('The specified template "'.$customTemplate.'" could not be read.'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $output->writeln(sprintf('Using custom migration template "<info>%s</info>"', $customTemplate)); |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | $output->writeln("\n <info>==</info> Configuration\n"); |
| 43 | 43 | foreach ($infos->getMigrationsInfos() as $name => $value) { |
| 44 | 44 | if ($name === 'New Migrations') { |
| 45 | - $value = $value > 0 ? '<question>' . $value . '</question>' : 0; |
|
| 45 | + $value = $value > 0 ? '<question>'.$value.'</question>' : 0; |
|
| 46 | 46 | } |
| 47 | 47 | if ($name === 'Executed Unavailable Migrations') { |
| 48 | - $value = $value > 0 ? '<error>' . $value . '</error>' : 0; |
|
| 48 | + $value = $value > 0 ? '<error>'.$value.'</error>' : 0; |
|
| 49 | 49 | } |
| 50 | 50 | $this->writeStatusInfosLineAligned($output, $name, $value); |
| 51 | 51 | } |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | if (count($infos->getExecutedUnavailableMigrations())) { |
| 63 | 63 | $output->writeln("\n <info>==</info> Previously Executed Unavailable Migration Versions\n"); |
| 64 | 64 | foreach ($infos->getExecutedUnavailableMigrations() as $executedUnavailableMigration) { |
| 65 | - $output->writeln(' <comment>>></comment> ' . $configuration->getDateTime($executedUnavailableMigration) . |
|
| 66 | - ' (<comment>' . $executedUnavailableMigration . '</comment>)'); |
|
| 65 | + $output->writeln(' <comment>>></comment> '.$configuration->getDateTime($executedUnavailableMigration). |
|
| 66 | + ' (<comment>'.$executedUnavailableMigration.'</comment>)'); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | private function writeStatusInfosLineAligned(OutputInterface $output, $title, $value) |
| 73 | 73 | { |
| 74 | - $output->writeln(' <comment>>></comment> ' . $title . ': ' . str_repeat(' ', 50 - strlen($title)) . $value); |
|
| 74 | + $output->writeln(' <comment>>></comment> '.$title.': '.str_repeat(' ', 50 - strlen($title)).$value); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | private function showVersions($migrations, Configuration $configuration, OutputInterface $output) |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | $status = $isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>'; |
| 84 | 84 | |
| 85 | 85 | $migrationDescription = $version->getMigration()->getDescription() |
| 86 | - ? str_repeat(' ', 5) . $version->getMigration()->getDescription() |
|
| 86 | + ? str_repeat(' ', 5).$version->getMigration()->getDescription() |
|
| 87 | 87 | : ''; |
| 88 | 88 | |
| 89 | 89 | $formattedVersion = $configuration->getDateTime($version->getVersion()); |
| 90 | 90 | |
| 91 | - $output->writeln(' <comment>>></comment> ' . $formattedVersion . |
|
| 92 | - ' (<comment>' . $version->getVersion() . '</comment>)' . |
|
| 93 | - str_repeat(' ', max(1, 49 - strlen($formattedVersion) - strlen($version->getVersion()))) . |
|
| 94 | - $status . $migrationDescription); |
|
| 91 | + $output->writeln(' <comment>>></comment> '.$formattedVersion. |
|
| 92 | + ' (<comment>'.$version->getVersion().'</comment>)'. |
|
| 93 | + str_repeat(' ', max(1, 49 - strlen($formattedVersion) - strlen($version->getVersion()))). |
|
| 94 | + $status.$migrationDescription); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -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; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * instead of any other one. |
| 41 | 41 | */ |
| 42 | 42 | if ($input->getOption('configuration')) { |
| 43 | - $outputWriter->write('Loading configuration from command option: ' . $input->getOption('configuration')); |
|
| 43 | + $outputWriter->write('Loading configuration from command option: '.$input->getOption('configuration')); |
|
| 44 | 44 | |
| 45 | 45 | return $this->loadConfig($input->getOption('configuration'), $outputWriter); |
| 46 | 46 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | ]; |
| 67 | 67 | foreach ($defaultConfig as $config) { |
| 68 | 68 | if ($this->configExists($config)) { |
| 69 | - $outputWriter->write('Loading configuration from file: ' . $config); |
|
| 69 | + $outputWriter->write('Loading configuration from file: '.$config); |
|
| 70 | 70 | |
| 71 | 71 | return $this->loadConfig($config, $outputWriter); |
| 72 | 72 | } |
@@ -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 | } |