@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | if (is_array($sql)) { |
166 | 166 | foreach ($sql as $key => $query) { |
167 | 167 | $this->sql[] = $query; |
168 | - if (! empty($params[$key])) { |
|
168 | + if (!empty($params[$key])) { |
|
169 | 169 | $queryTypes = $types[$key] ?? []; |
170 | 170 | $this->addQueryParams($params[$key], $queryTypes); |
171 | 171 | } |
172 | 172 | } |
173 | 173 | } else { |
174 | 174 | $this->sql[] = $sql; |
175 | - if (! empty($params)) { |
|
175 | + if (!empty($params)) { |
|
176 | 176 | $this->addQueryParams($params, $types); |
177 | 177 | } |
178 | 178 | } |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | { |
203 | 203 | $queries = $this->execute($direction, true); |
204 | 204 | |
205 | - if (! empty($this->params)) { |
|
205 | + if (!empty($this->params)) { |
|
206 | 206 | throw MigrationException::migrationNotConvertibleToSql($this->class); |
207 | 207 | } |
208 | 208 | |
209 | - $this->outputWriter->write("\n-- Version " . $this->version . "\n"); |
|
209 | + $this->outputWriter->write("\n-- Version ".$this->version."\n"); |
|
210 | 210 | |
211 | 211 | $sqlQueries = [$this->version => $queries]; |
212 | 212 | |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | $this->state = self::STATE_PRE; |
260 | 260 | $fromSchema = $this->schemaProvider->createFromSchema(); |
261 | 261 | |
262 | - $this->migration->{'pre' . ucfirst($direction)}($fromSchema); |
|
262 | + $this->migration->{'pre'.ucfirst($direction)}($fromSchema); |
|
263 | 263 | |
264 | 264 | if ($direction === self::DIRECTION_UP) { |
265 | - $this->outputWriter->write("\n" . sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version) . "\n"); |
|
265 | + $this->outputWriter->write("\n".sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version)."\n"); |
|
266 | 266 | } else { |
267 | - $this->outputWriter->write("\n" . sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version) . "\n"); |
|
267 | + $this->outputWriter->write("\n".sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version)."\n"); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | $this->state = self::STATE_EXEC; |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | $this->executeRegisteredSql($dryRun, $timeAllQueries); |
278 | 278 | |
279 | 279 | $this->state = self::STATE_POST; |
280 | - $this->migration->{'post' . ucfirst($direction)}($toSchema); |
|
280 | + $this->migration->{'post'.ucfirst($direction)}($toSchema); |
|
281 | 281 | |
282 | - if (! $dryRun) { |
|
282 | + if (!$dryRun) { |
|
283 | 283 | if ($direction === self::DIRECTION_UP) { |
284 | 284 | $this->markMigrated(); |
285 | 285 | } else { |
@@ -387,13 +387,13 @@ discard block |
||
387 | 387 | |
388 | 388 | private function executeRegisteredSql($dryRun = false, $timeAllQueries = false) |
389 | 389 | { |
390 | - if (! $dryRun) { |
|
391 | - if (! empty($this->sql)) { |
|
390 | + if (!$dryRun) { |
|
391 | + if (!empty($this->sql)) { |
|
392 | 392 | foreach ($this->sql as $key => $query) { |
393 | 393 | $queryStart = microtime(true); |
394 | 394 | |
395 | - if (! isset($this->params[$key])) { |
|
396 | - $this->outputWriter->write(' <comment>-></comment> ' . $query); |
|
395 | + if (!isset($this->params[$key])) { |
|
396 | + $this->outputWriter->write(' <comment>-></comment> '.$query); |
|
397 | 397 | $this->connection->executeQuery($query); |
398 | 398 | } else { |
399 | 399 | $this->outputWriter->write(sprintf(' <comment>-</comment> %s (with parameters)', $query)); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * migrations. |
119 | 119 | */ |
120 | 120 | $migrations = $this->configuration->getMigrations(); |
121 | - if (! isset($migrations[$to]) && $to > 0) { |
|
121 | + if (!isset($migrations[$to]) && $to > 0) { |
|
122 | 122 | throw MigrationException::unknownMigrationVersion($to); |
123 | 123 | } |
124 | 124 | |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | * means we are already at the destination return an empty array() |
134 | 134 | * to signify that there is nothing left to do. |
135 | 135 | */ |
136 | - if ($from === $to && empty($migrationsToExecute) && ! empty($migrations)) { |
|
136 | + if ($from === $to && empty($migrationsToExecute) && !empty($migrations)) { |
|
137 | 137 | return $this->noMigrations(); |
138 | 138 | } |
139 | 139 | |
140 | - if (! $dryRun && $this->migrationsCanExecute($confirm) === false) { |
|
140 | + if (!$dryRun && $this->migrationsCanExecute($confirm) === false) { |
|
141 | 141 | return []; |
142 | 142 | } |
143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | /** |
149 | 149 | * If there are no migrations to execute throw an exception. |
150 | 150 | */ |
151 | - if (empty($migrationsToExecute) && ! $this->noMigrationException) { |
|
151 | + if (empty($migrationsToExecute) && !$this->noMigrationException) { |
|
152 | 152 | throw MigrationException::noMigrationsToExecute(); |
153 | 153 | } elseif (empty($migrationsToExecute)) { |
154 | 154 | return $this->noMigrations(); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public function onMigrationsMigrated(MigrationsEventArgs $args) |
16 | 16 | { |
17 | 17 | $conn = $args->getConnection(); |
18 | - if (! $args->isDryRun() && ! $conn->isAutoCommit()) { |
|
18 | + if (!$args->isDryRun() && !$conn->isAutoCommit()) { |
|
19 | 19 | $conn->commit(); |
20 | 20 | } |
21 | 21 | } |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | $filterExpr = $conn->getConfiguration()->getFilterSchemaAssetsExpression(); |
76 | 76 | |
77 | 77 | //Not using value from options, because filters can be set from config.yml |
78 | - if (! $isDbalOld && $filterExpr) { |
|
78 | + if (!$isDbalOld && $filterExpr) { |
|
79 | 79 | foreach ($toSchema->getTables() as $table) { |
80 | 80 | $tableName = $table->getName(); |
81 | - if (! preg_match($filterExpr, $this->resolveTableName($tableName))) { |
|
81 | + if (!preg_match($filterExpr, $this->resolveTableName($tableName))) { |
|
82 | 82 | $toSchema->dropTable($tableName); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - $up = $this->buildCodeFromSql( |
|
87 | + $up = $this->buildCodeFromSql( |
|
88 | 88 | $configuration, |
89 | 89 | $fromSchema->getMigrateToSql($toSchema, $platform), |
90 | 90 | $input->getOption('formatted'), |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $input->getOption('line-length') |
98 | 98 | ); |
99 | 99 | |
100 | - if (! $up && ! $down) { |
|
100 | + if (!$up && !$down) { |
|
101 | 101 | $output->writeln('No changes detected in your mapping information.'); |
102 | 102 | |
103 | 103 | return; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | if ($formatted) { |
126 | - if (! class_exists('\SqlFormatter')) { |
|
126 | + if (!class_exists('\SqlFormatter')) { |
|
127 | 127 | throw new \InvalidArgumentException( |
128 | - 'The "--formatted" option can only be used if the sql formatter is installed.' . |
|
128 | + 'The "--formatted" option can only be used if the sql formatter is installed.'. |
|
129 | 129 | 'Please run "composer require jdorn/sql-formatter".' |
130 | 130 | ); |
131 | 131 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $code[] = sprintf('$this->addSql(%s);', var_export($query, true)); |
141 | 141 | } |
142 | 142 | |
143 | - if (! empty($code)) { |
|
143 | + if (!empty($code)) { |
|
144 | 144 | array_unshift( |
145 | 145 | $code, |
146 | 146 | sprintf( |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | private function getSchemaProvider() |
159 | 159 | { |
160 | - if (! $this->schemaProvider) { |
|
160 | + if (!$this->schemaProvider) { |
|
161 | 161 | $this->schemaProvider = new OrmSchemaProvider($this->getHelper('entityManager')->getEntityManager()); |
162 | 162 | } |
163 | 163 |
@@ -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; |