@@ -42,7 +42,7 @@ |
||
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Transform the recursiveIterator result array of array into the expected array of migration file |
45 | - * @param iterable|string[][] $iteratorFilesMatch |
|
45 | + * @param \RegexIterator $iteratorFilesMatch |
|
46 | 46 | * @return string[] |
47 | 47 | */ |
48 | 48 | private function getMatches($iteratorFilesMatch) |
@@ -12,6 +12,9 @@ |
||
12 | 12 | /** @var \Closure|null */ |
13 | 13 | private $closure; |
14 | 14 | |
15 | + /** |
|
16 | + * @param \Closure $closure |
|
17 | + */ |
|
15 | 18 | public function __construct(?\Closure $closure = null) |
16 | 19 | { |
17 | 20 | if ($closure === null) { |
@@ -15,7 +15,7 @@ |
||
15 | 15 | public function __construct(?\Closure $closure = null) |
16 | 16 | { |
17 | 17 | if ($closure === null) { |
18 | - $closure = function ($message) { |
|
18 | + $closure = function($message) { |
|
19 | 19 | }; |
20 | 20 | } |
21 | 21 | $this->closure = $closure; |
@@ -160,7 +160,7 @@ |
||
160 | 160 | |
161 | 161 | /** |
162 | 162 | * @param string $versionAlias |
163 | - * @return bool|string |
|
163 | + * @return false|string |
|
164 | 164 | */ |
165 | 165 | private function getVersionNameFromAlias($versionAlias, OutputInterface $output, Configuration $configuration) |
166 | 166 | { |
@@ -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 |
@@ -69,11 +69,17 @@ |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | + /** |
|
73 | + * @param string $title |
|
74 | + */ |
|
72 | 75 | private function writeStatusInfosLineAligned(OutputInterface $output, $title, $value) |
73 | 76 | { |
74 | 77 | $output->writeln(' <comment>>></comment> ' . $title . ': ' . str_repeat(' ', 50 - strlen($title)) . $value); |
75 | 78 | } |
76 | 79 | |
80 | + /** |
|
81 | + * @param \Doctrine\DBAL\Migrations\Version[] $migrations |
|
82 | + */ |
|
77 | 83 | private function showVersions($migrations, Configuration $configuration, OutputInterface $output) |
78 | 84 | { |
79 | 85 | $migratedVersions = $configuration->getMigratedVersions(); |
@@ -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 | } |
@@ -27,6 +27,10 @@ discard block |
||
27 | 27 | */ |
28 | 28 | private $configuration; |
29 | 29 | |
30 | + /** |
|
31 | + * @param Connection $connection |
|
32 | + * @param Configuration $configuration |
|
33 | + */ |
|
30 | 34 | public function __construct(?Connection $connection = null, ?Configuration $configuration = null) |
31 | 35 | { |
32 | 36 | $this->connection = $connection; |
@@ -76,6 +80,9 @@ discard block |
||
76 | 80 | } |
77 | 81 | |
78 | 82 | |
83 | + /** |
|
84 | + * @param string $config |
|
85 | + */ |
|
79 | 86 | private function configExists($config) |
80 | 87 | { |
81 | 88 | return file_exists($config); |
@@ -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 | } |
@@ -81,6 +81,10 @@ discard block |
||
81 | 81 | /** @var SchemaDiffProviderInterface */ |
82 | 82 | private $schemaProvider; |
83 | 83 | |
84 | + /** |
|
85 | + * @param string $version |
|
86 | + * @param string $class |
|
87 | + */ |
|
84 | 88 | public function __construct(Configuration $configuration, $version, $class, ?SchemaDiffProviderInterface $schemaProvider = null) |
85 | 89 | { |
86 | 90 | $this->configuration = $configuration; |
@@ -137,6 +141,9 @@ discard block |
||
137 | 141 | $this->markVersion('up'); |
138 | 142 | } |
139 | 143 | |
144 | + /** |
|
145 | + * @param string $direction |
|
146 | + */ |
|
140 | 147 | private function markVersion($direction) |
141 | 148 | { |
142 | 149 | $action = $direction === 'up' ? 'insert' : 'delete'; |
@@ -157,7 +164,7 @@ discard block |
||
157 | 164 | * Add some SQL queries to this versions migration |
158 | 165 | * |
159 | 166 | * @param string|string[] $sql |
160 | - * @param mixed[]|mixed[][] $params |
|
167 | + * @param string[] $params |
|
161 | 168 | * @param string[]|string[][] $types |
162 | 169 | */ |
163 | 170 | public function addSql($sql, array $params = [], array $types = []) |
@@ -360,6 +367,9 @@ discard block |
||
360 | 367 | } |
361 | 368 | } |
362 | 369 | |
370 | + /** |
|
371 | + * @param double $queryStart |
|
372 | + */ |
|
363 | 373 | private function outputQueryTime($queryStart, $timeAllQueries = false) |
364 | 374 | { |
365 | 375 | if ($timeAllQueries !== false) { |
@@ -464,6 +474,10 @@ discard block |
||
464 | 474 | return sprintf('with parameters (%s)', implode(', ', $out)); |
465 | 475 | } |
466 | 476 | |
477 | + /** |
|
478 | + * @param string $direction |
|
479 | + * @param boolean $dryRun |
|
480 | + */ |
|
467 | 481 | private function dispatchEvent($eventName, $direction, $dryRun) |
468 | 482 | { |
469 | 483 | $this->configuration->dispatchEvent($eventName, new MigrationsVersionEventArgs( |
@@ -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 |