@@ -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 | } |
@@ -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 |
@@ -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)); |
@@ -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 |