Passed
Push — master ( 1eafe3...862746 )
by Gaetano
07:42
created
app/src/Command/SQLExecutingCommand.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
     protected function addCommonOptions()
50 50
     {
51 51
         $this
52
-            ->addOption('only-instances', 'o', InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Filter the database servers to run this command against. Usage of * and ? wildcards is allowed. To see all instances available, use `instance:list`', null)
53
-            ->addOption('except-instances', 'x', InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Filter the database servers to run this command against', null)
52
+            ->addOption('only-instances', 'o', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter the database servers to run this command against. Usage of * and ? wildcards is allowed. To see all instances available, use `instance:list`', null)
53
+            ->addOption('except-instances', 'x', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter the database servers to run this command against', null)
54 54
             ->addOption('output-type', null, InputOption::VALUE_REQUIRED, 'The format for the output: json, php, text or yml', self::DEFAULT_OUTPUT_FORMAT)
55 55
             ->addOption('output-file', null, InputOption::VALUE_REQUIRED, 'Save output to a file instead of writing it to stdout. NB: take care that dbconsole runs in a container, which has a different view of the filesystem. A good dir for output is ./shared')
56 56
             ->addOption('timeout', null, InputOption::VALUE_REQUIRED, 'The maximum time to wait for subprocess execution (secs)', self::DEFAULT_PROCESS_TIMEOUT)
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         // On Debian, which we use by default, SF has troubles understanding that php was compiled with --enable-sigchild
78 78
         // We thus force it, but give end users an option to disable this
79 79
         // For more details, see comment 12 at https://bugs.launchpad.net/ubuntu/+source/php5/+bug/516061
80
-        if (! $input->getOption('dont-force-enabled-sigchild')) {
80
+        if (!$input->getOption('dont-force-enabled-sigchild')) {
81 81
             Process::forceSigchildEnabled(true);
82 82
         }
83 83
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                     $sql = null;
122 122
                 } else {
123 123
                     // this is a coding error, not a sql execution error
124
-                    throw new \Exception("Unsupported action type: " . get_class($sqlAction));
124
+                    throw new \Exception("Unsupported action type: ".get_class($sqlAction));
125 125
                 }
126 126
                 $filterCallable = $sqlAction->getResultsFilterCallable();
127 127
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                     $outputFilters[$instanceName] = $filterCallable;
133 133
 
134 134
                     if ($filename === null && !$sqlAction->isSingleStatement()) {
135
-                        $filename = tempnam(sys_get_temp_dir(), 'db3v4l_') . '.sql';
135
+                        $filename = tempnam(sys_get_temp_dir(), 'db3v4l_').'.sql';
136 136
                         file_put_contents($filename, $sql);
137 137
                         $tempSQLFileNames[] = $filename;
138 138
                     }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                         }
156 156
 
157 157
                         if ($this->outputFormat === 'text') {
158
-                            $this->writeln('Command line: ' . $process->getCommandLine(), OutputInterface::VERBOSITY_VERY_VERBOSE);
158
+                            $this->writeln('Command line: '.$process->getCommandLine(), OutputInterface::VERBOSITY_VERY_VERBOSE);
159 159
                         }
160 160
 
161 161
                         $process->setTimeout($this->processTimeout);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     $succeeded++;
178 178
                 } catch (\Throwable $t) {
179 179
                     $failed++;
180
-                    $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $t->getMessage() . "</error>\n", OutputInterface::VERBOSITY_NORMAL);
180
+                    $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$t->getMessage()."</error>\n", OutputInterface::VERBOSITY_NORMAL);
181 181
                 }
182 182
             }
183 183
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                                 //$result = null;
200 200
                                 $failed++;
201 201
                                 $succeeded--;
202
-                                $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $t->getMessage() . "</error>\n", OutputInterface::VERBOSITY_NORMAL);
202
+                                $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$t->getMessage()."</error>\n", OutputInterface::VERBOSITY_NORMAL);
203 203
                             }
204 204
                         }
205 205
                         $results[$instanceName] = $output;
@@ -210,19 +210,19 @@  discard block
 block discarded – undo
210 210
                             'exitcode' => $process->getExitCode()
211 211
                         ];
212 212
                         $failed++;
213
-                        $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $process->getErrorOutput() . "</error>\n", OutputInterface::VERBOSITY_NORMAL);
213
+                        $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$process->getErrorOutput()."</error>\n", OutputInterface::VERBOSITY_NORMAL);
214 214
                     }
215 215
                 }
216 216
             }
217 217
 
218 218
         } finally {
219 219
             // make sure that we clean up temp files, as they might contain sensitive data
220
-            foreach($tempSQLFileNames as $tempSQLFileName) {
220
+            foreach ($tempSQLFileNames as $tempSQLFileName) {
221 221
                 unlink($tempSQLFileName);
222 222
             }
223 223
         }
224 224
 
225
-        uksort($results, function ($a, $b) {
225
+        uksort($results, function($a, $b) {
226 226
             $aParts = explode('_', $a, 2);
227 227
             $bParts = explode('_', $b, 2);
228 228
             $cmp = strcasecmp($aParts[0], $bParts[0]);
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
             $this->writeResultsToFile($results);
282 282
         } else {
283 283
             $formattedResults = $this->formatResults($results);
284
-            $this->writeln($formattedResults, OutputInterface::VERBOSITY_QUIET,  OutputInterface::OUTPUT_RAW);
284
+            $this->writeln($formattedResults, OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW);
285 285
         }
286 286
 
287 287
         if ($this->outputFormat === 'text' || $this->outputFile != null) {
288
-            $this->writeln($results['succeeded'] . ' succeeded, ' . $results['failed'] . ' failed');
288
+            $this->writeln($results['succeeded'].' succeeded, '.$results['failed'].' failed');
289 289
             if ($this->outputFile != null) {
290 290
                 $this->writeln("Results saved to file {$this->outputFile}");
291 291
             }
Please login to merge, or discard this patch.
app/src/Command/SqlExecute.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 
83 83
             /// @todo inject more randomness in the username, by allowing more chars than bin2hex produces
84 84
 
85
-            $userName = 'db3v4l_' . substr(bin2hex(random_bytes(5)), 0, 9); // some mysql versions have a limitation of 16 chars for usernames
85
+            $userName = 'db3v4l_'.substr(bin2hex(random_bytes(5)), 0, 9); // some mysql versions have a limitation of 16 chars for usernames
86 86
             $password = bin2hex(random_bytes(16));
87 87
             //$dbName = bin2hex(random_bytes(31));
88 88
             $dbName = $userName; // $userName will be used as db name
89 89
 
90 90
             $tempDbSpecs = [];
91
-            foreach($instanceList as $instanceName => $instanceSpecs) {
91
+            foreach ($instanceList as $instanceName => $instanceSpecs) {
92 92
                 $tempDbSpecs[$instanceName] = [
93 93
                     'dbname' => $dbName,
94 94
                     'user' => $userName,
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             }
98 98
 
99 99
             if (($charset = $input->getOption('charset')) != '') {
100
-                foreach($instanceList as $instanceName) {
100
+                foreach ($instanceList as $instanceName) {
101 101
                     $tempDbSpecs[$instanceName]['charset'] = $charset;
102 102
                 }
103 103
             }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             ];
125 125
 
126 126
             $dbConnectionSpecs = [];
127
-            foreach($instanceList as $instanceName => $instanceSpecs) {
127
+            foreach ($instanceList as $instanceName => $instanceSpecs) {
128 128
                 $dbConnectionSpecs[$instanceName] = array_merge($instanceSpecs, $dbConfig);
129 129
             }
130 130
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             if ($createDB) {
140 140
                 $results['failed'] += $creationResults['failed'];
141 141
 
142
-                foreach($instanceList as $instanceName  => $instanceSpecs) {
142
+                foreach ($instanceList as $instanceName  => $instanceSpecs) {
143 143
                     if (!isset($dbConnectionSpecs[$instanceName])) {
144 144
                         unset($instanceList[$instanceName]);
145 145
                     }
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
                 $this->executionStrategy = $previousStrategy;
152 152
             }
153 153
         } else {
154
-            $results = ['succeeded' => 0,  'failed' => 0, 'data' => null];
154
+            $results = ['succeeded' => 0, 'failed' => 0, 'data' => null];
155 155
         }
156 156
 
157 157
         $time = microtime(true) - $start;
158 158
 
159 159
         $this->writeResults($results, $time);
160 160
 
161
-        return (int)$results['failed'];
161
+        return (int) $results['failed'];
162 162
     }
163 163
 
164 164
     /**
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
         return $this->executeSqlAction(
177 177
             $dbConnectionSpecs,
178 178
             'Execution of SQL',
179
-            function ($schemaManager, $instanceName) use ($sql, $filename) {
179
+            function($schemaManager, $instanceName) use ($sql, $filename) {
180 180
                 if ($sql != null) {
181 181
                     return new Command(
182 182
                         $sql,
183
-                        function ($output, $executor) {
183
+                        function($output, $executor) {
184 184
                             /** @var TimedExecutor $executor */
185 185
                             return array_merge(['stdout' => $output], $executor->getTimingData());
186 186
                         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                     }
194 194
                     return new File(
195 195
                         $realFileName,
196
-                        function ($output, $executor) {
196
+                        function($output, $executor) {
197 197
                             /** @var TimedExecutor $executor */
198 198
                             return array_merge(['stdout' => $output], $executor->getTimingData());
199 199
                         }
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
             if (trim($line) !== '') {
229 229
                 if ($type === 'err') {
230 230
                     $this->writeErrorln(
231
-                        '[' . $processIndex . '][' . $pid . '] ' . trim($line),
231
+                        '['.$processIndex.']['.$pid.'] '.trim($line),
232 232
                         OutputInterface::VERBOSITY_VERBOSE,
233 233
                         OutputInterface::OUTPUT_RAW
234 234
                     );
235 235
                 } else {
236 236
                     $this->writeln(
237
-                        '[' . $processIndex . '][' . $pid . '] ' . trim($line),
237
+                        '['.$processIndex.']['.$pid.'] '.trim($line),
238 238
                         OutputInterface::VERBOSITY_VERBOSE,
239 239
                         OutputInterface::OUTPUT_RAW
240 240
                     );
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             return;
278 278
         }
279 279
 
280
-        foreach($results['data'] as $instanceName => $data) {
280
+        foreach ($results['data'] as $instanceName => $data) {
281 281
             $formattedData = $this->formatResults(array('data' => $data));
282 282
             $outputFile = $this->replaceDBSpecTokens($this->outputFile, $instanceName, $this->dbConfigurationManager->getInstanceConfiguration($instanceName));
283 283
             file_put_contents($outputFile, $formattedData);
Please login to merge, or discard this patch.