Failed Conditions
Pull Request — master (#590)
by Michael
12:00
created
lib/Doctrine/DBAL/Migrations/Tools/Console/Command/MigrateCommand.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
lib/Doctrine/DBAL/Migrations/Tools/Console/Command/StatusCommand.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -69,11 +69,17 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/Doctrine/DBAL/Migrations/Tools/Console/Helper/ConfigurationHelper.php 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -27,6 +27,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
lib/Doctrine/DBAL/Migrations/Event/Listeners/AutoCommitListener.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
lib/Doctrine/DBAL/Migrations/Tools/Console/Command/DiffCommand.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
lib/Doctrine/DBAL/Migrations/Tools/Console/Command/GenerateCommand.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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));
Please login to merge, or discard this patch.
lib/Doctrine/DBAL/Migrations/Tools/Console/Command/VersionCommand.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 {
Please login to merge, or discard this patch.
lib/Doctrine/DBAL/Migrations/Tools/Console/Command/AbstractCommand.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
DBAL/Migrations/Tools/Console/Helper/ConfigurationHelperInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.