@@ -38,7 +38,7 @@ |
||
38 | 38 | { |
39 | 39 | $config = Yaml::parse(file_get_contents($file)); |
40 | 40 | |
41 | - if ( ! is_array($config)) { |
|
41 | + if (!is_array($config)) { |
|
42 | 42 | throw new \InvalidArgumentException('Not valid configuration.'); |
43 | 43 | } |
44 | 44 |
@@ -34,7 +34,7 @@ |
||
34 | 34 | public function onMigrationsMigrated(MigrationsEventArgs $args) |
35 | 35 | { |
36 | 36 | $conn = $args->getConnection(); |
37 | - if ( ! $args->isDryRun() && ! $conn->isAutoCommit()) { |
|
37 | + if (!$args->isDryRun() && !$conn->isAutoCommit()) { |
|
38 | 38 | $conn->commit(); |
39 | 39 | } |
40 | 40 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * migrations. |
141 | 141 | */ |
142 | 142 | $migrations = $this->configuration->getMigrations(); |
143 | - if ( ! isset($migrations[$to]) && $to > 0) { |
|
143 | + if (!isset($migrations[$to]) && $to > 0) { |
|
144 | 144 | throw MigrationException::unknownMigrationVersion($to); |
145 | 145 | } |
146 | 146 | |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | * means we are already at the destination return an empty array() |
156 | 156 | * to signify that there is nothing left to do. |
157 | 157 | */ |
158 | - if ($from === $to && empty($migrationsToExecute) && ! empty($migrations)) { |
|
158 | + if ($from === $to && empty($migrationsToExecute) && !empty($migrations)) { |
|
159 | 159 | return $this->noMigrations(); |
160 | 160 | } |
161 | 161 | |
162 | - if ( ! $dryRun && false === $this->migrationsCanExecute($confirm)) { |
|
162 | + if (!$dryRun && false === $this->migrationsCanExecute($confirm)) { |
|
163 | 163 | return []; |
164 | 164 | } |
165 | 165 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * If there are no migrations to execute throw an exception. |
172 | 172 | */ |
173 | - if (empty($migrationsToExecute) && ! $this->noMigrationException) { |
|
173 | + if (empty($migrationsToExecute) && !$this->noMigrationException) { |
|
174 | 174 | throw MigrationException::noMigrationsToExecute(); |
175 | 175 | } elseif (empty($migrationsToExecute)) { |
176 | 176 | return $this->noMigrations(); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | public function __construct(\Closure $closure = null) |
35 | 35 | { |
36 | 36 | if ($closure === null) { |
37 | - $closure = function ($message) { |
|
37 | + $closure = function($message) { |
|
38 | 38 | }; |
39 | 39 | } |
40 | 40 | $this->closure = $closure; |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | $replacements = [ |
118 | 118 | $configuration->getMigrationsNamespace(), |
119 | 119 | $version, |
120 | - $up ? " " . implode("\n ", explode("\n", $up)) : null, |
|
121 | - $down ? " " . implode("\n ", explode("\n", $down)) : null, |
|
120 | + $up ? " ".implode("\n ", explode("\n", $up)) : null, |
|
121 | + $down ? " ".implode("\n ", explode("\n", $down)) : null, |
|
122 | 122 | ]; |
123 | 123 | |
124 | 124 | $code = str_replace($placeHolders, $replacements, $this->getTemplate()); |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | |
127 | 127 | $directoryHelper = new MigrationDirectoryHelper($configuration); |
128 | 128 | $dir = $directoryHelper->getMigrationDirectory(); |
129 | - $path = $dir . '/Version' . $version . '.php'; |
|
129 | + $path = $dir.'/Version'.$version.'.php'; |
|
130 | 130 | |
131 | 131 | file_put_contents($path, $code); |
132 | 132 | |
133 | 133 | if ($editorCmd = $input->getOption('editor-cmd')) { |
134 | - proc_open($editorCmd . ' ' . escapeshellarg($path), [], $pipes); |
|
134 | + proc_open($editorCmd.' '.escapeshellarg($path), [], $pipes); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return $path; |
@@ -145,18 +145,18 @@ discard block |
||
145 | 145 | return; |
146 | 146 | } |
147 | 147 | |
148 | - $filePath = getcwd() . '/' . $customTemplate; |
|
148 | + $filePath = getcwd().'/'.$customTemplate; |
|
149 | 149 | |
150 | - if ( ! is_file($filePath) || ! is_readable($filePath)) { |
|
150 | + if (!is_file($filePath) || !is_readable($filePath)) { |
|
151 | 151 | throw new \InvalidArgumentException( |
152 | - 'The specified template "' . $customTemplate . '" cannot be found or is not readable.' |
|
152 | + 'The specified template "'.$customTemplate.'" cannot be found or is not readable.' |
|
153 | 153 | ); |
154 | 154 | } |
155 | 155 | |
156 | 156 | $content = file_get_contents($filePath); |
157 | 157 | |
158 | 158 | if ($content === false) { |
159 | - throw new \InvalidArgumentException('The specified template "' . $customTemplate . '" could not be read.'); |
|
159 | + throw new \InvalidArgumentException('The specified template "'.$customTemplate.'" could not be read.'); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | $output->writeln(sprintf('Using custom migration template "<info>%s</info>"', $customTemplate)); |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | if (is_array($sql)) { |
188 | 188 | foreach ($sql as $key => $query) { |
189 | 189 | $this->sql[] = $query; |
190 | - if ( ! empty($params[$key])) { |
|
190 | + if (!empty($params[$key])) { |
|
191 | 191 | $queryTypes = isset($types[$key]) ? $types[$key] : []; |
192 | 192 | $this->addQueryParams($params[$key], $queryTypes); |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } else { |
196 | 196 | $this->sql[] = $sql; |
197 | - if ( ! empty($params)) { |
|
197 | + if (!empty($params)) { |
|
198 | 198 | $this->addQueryParams($params, $types); |
199 | 199 | } |
200 | 200 | } |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | { |
224 | 224 | $queries = $this->execute($direction, true); |
225 | 225 | |
226 | - if ( ! empty($this->params)) { |
|
226 | + if (!empty($this->params)) { |
|
227 | 227 | throw MigrationException::migrationNotConvertibleToSql($this->class); |
228 | 228 | } |
229 | 229 | |
230 | - $this->outputWriter->write("\n-- Version " . $this->version . "\n"); |
|
230 | + $this->outputWriter->write("\n-- Version ".$this->version."\n"); |
|
231 | 231 | |
232 | 232 | $sqlQueries = [$this->version => $queries]; |
233 | 233 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | $this->state = self::STATE_PRE; |
281 | 281 | $fromSchema = $this->schemaProvider->createFromSchema(); |
282 | 282 | |
283 | - $this->migration->{'pre' . ucfirst($direction)}($fromSchema); |
|
283 | + $this->migration->{'pre'.ucfirst($direction)}($fromSchema); |
|
284 | 284 | |
285 | 285 | if ($direction === self::DIRECTION_UP) { |
286 | - $this->outputWriter->write("\n" . sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version) . "\n"); |
|
286 | + $this->outputWriter->write("\n".sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->version)."\n"); |
|
287 | 287 | } else { |
288 | - $this->outputWriter->write("\n" . sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version) . "\n"); |
|
288 | + $this->outputWriter->write("\n".sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->version)."\n"); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $this->state = self::STATE_EXEC; |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | $this->executeRegisteredSql($dryRun, $timeAllQueries); |
299 | 299 | |
300 | 300 | $this->state = self::STATE_POST; |
301 | - $this->migration->{'post' . ucfirst($direction)}($toSchema); |
|
301 | + $this->migration->{'post'.ucfirst($direction)}($toSchema); |
|
302 | 302 | |
303 | - if ( ! $dryRun) { |
|
303 | + if (!$dryRun) { |
|
304 | 304 | if ($direction === self::DIRECTION_UP) { |
305 | 305 | $this->markMigrated(); |
306 | 306 | } else { |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | |
409 | 409 | private function executeRegisteredSql($dryRun = false, $timeAllQueries = false) |
410 | 410 | { |
411 | - if ( ! $dryRun) { |
|
412 | - if ( ! empty($this->sql)) { |
|
411 | + if (!$dryRun) { |
|
412 | + if (!empty($this->sql)) { |
|
413 | 413 | foreach ($this->sql as $key => $query) { |
414 | 414 | $queryStart = microtime(true); |
415 | 415 | |
416 | - if ( ! isset($this->params[$key])) { |
|
417 | - $this->outputWriter->write(' <comment>-></comment> ' . $query); |
|
416 | + if (!isset($this->params[$key])) { |
|
417 | + $this->outputWriter->write(' <comment>-></comment> '.$query); |
|
418 | 418 | $this->connection->executeQuery($query); |
419 | 419 | } else { |
420 | 420 | $this->outputWriter->write(sprintf(' <comment>-</comment> %s (with parameters)', $query)); |
@@ -473,13 +473,13 @@ discard block |
||
473 | 473 | $platform = $this->connection->getDatabasePlatform(); |
474 | 474 | $out = []; |
475 | 475 | foreach ($params as $key => $value) { |
476 | - $type = isset($types[$key]) ? $types[$key] : 'string'; |
|
476 | + $type = isset($types[$key]) ? $types[$key] : 'string'; |
|
477 | 477 | if (Type::hasType($type)) { |
478 | 478 | $outval = Type::getType($type)->convertToDatabaseValue($value, $platform); |
479 | 479 | } else { |
480 | 480 | $outval = '?'; |
481 | 481 | } |
482 | - $out[] = is_string($key) ? sprintf(':%s => %s', $key, $outval) : $outval; |
|
482 | + $out[] = is_string($key) ? sprintf(':%s => %s', $key, $outval) : $outval; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | return sprintf('with parameters (%s)', implode(', ', $out)); |