@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $dbToDropSpecs = []; |
| 59 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
| 59 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
| 60 | 60 | $dbToDropSpecs[$instanceName] = [ |
| 61 | 61 | 'dbname' => $dbName |
| 62 | 62 | ]; |
@@ -74,6 +74,6 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $this->writeResults($results, $time); |
| 76 | 76 | |
| 77 | - return (int)$results['failed']; |
|
| 77 | + return (int) $results['failed']; |
|
| 78 | 78 | } |
| 79 | 79 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $newDbSpecs = []; |
| 77 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
| 77 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
| 78 | 78 | $newDbSpecs[$instanceName] = [ |
| 79 | 79 | 'dbname' => $dbName |
| 80 | 80 | ]; |
@@ -93,6 +93,6 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $this->writeResults($results, $time); |
| 95 | 95 | |
| 96 | - return (int)$results['failed']; |
|
| 96 | + return (int) $results['failed']; |
|
| 97 | 97 | } |
| 98 | 98 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $this->writeResults($results, $time); |
| 49 | 49 | |
| 50 | - return (int)$results['failed']; |
|
| 50 | + return (int) $results['failed']; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | return $this->executeSqlAction( |
| 61 | 61 | $instanceList, |
| 62 | 62 | 'Listing of users', |
| 63 | - function ($schemaManager, $instanceName) { |
|
| 63 | + function($schemaManager, $instanceName) { |
|
| 64 | 64 | /** @var DatabaseSchemaManager $schemaManager */ |
| 65 | 65 | return $schemaManager->getListUsersSqlAction(); |
| 66 | 66 | } |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | /// @todo inject more randomness in the username, by allowing more chars than bin2hex produces |
| 83 | 83 | |
| 84 | - $userName = 'db3v4l_' . substr(bin2hex(random_bytes(5)), 0, 9); // some mysql versions have a limitation of 16 chars for usernames |
|
| 84 | + $userName = 'db3v4l_'.substr(bin2hex(random_bytes(5)), 0, 9); // some mysql versions have a limitation of 16 chars for usernames |
|
| 85 | 85 | $password = bin2hex(random_bytes(16)); |
| 86 | 86 | //$dbName = bin2hex(random_bytes(31)); |
| 87 | 87 | $dbName = $userName; // $userName will be used as db name |
| 88 | 88 | |
| 89 | 89 | $tempDbSpecs = []; |
| 90 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
| 90 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
| 91 | 91 | $tempDbSpecs[$instanceName] = [ |
| 92 | 92 | 'dbname' => $dbName, |
| 93 | 93 | 'user' => $userName, |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if (($charset = $input->getOption('charset')) != '') { |
| 99 | - foreach($instanceList as $instanceName) { |
|
| 99 | + foreach ($instanceList as $instanceName) { |
|
| 100 | 100 | $tempDbSpecs[$instanceName]['charset'] = $charset; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | ]; |
| 119 | 119 | |
| 120 | 120 | $dbConnectionSpecs = []; |
| 121 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
| 121 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
| 122 | 122 | $dbConnectionSpecs[$instanceName] = array_merge($instanceSpecs, $dbConfig); |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | if ($createDB) { |
| 134 | 134 | $results['failed'] += $creationResults['failed']; |
| 135 | 135 | |
| 136 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
| 136 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
| 137 | 137 | if (!isset($dbConnectionSpecs[$instanceName])) { |
| 138 | 138 | unset($instanceList[$instanceName]); |
| 139 | 139 | } |
@@ -141,14 +141,14 @@ discard block |
||
| 141 | 141 | $this->dropDatabases($instanceList, $dbConnectionSpecs, true); |
| 142 | 142 | } |
| 143 | 143 | } else { |
| 144 | - $results = ['succeeded' => 0, 'failed' => 0, 'data' => null]; |
|
| 144 | + $results = ['succeeded' => 0, 'failed' => 0, 'data' => null]; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $time = microtime(true) - $start; |
| 148 | 148 | |
| 149 | 149 | $this->writeResults($results, $time); |
| 150 | 150 | |
| 151 | - return (int)$results['failed']; |
|
| 151 | + return (int) $results['failed']; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -166,11 +166,11 @@ discard block |
||
| 166 | 166 | return $this->executeSqlAction( |
| 167 | 167 | $dbConnectionSpecs, |
| 168 | 168 | 'Execution of SQL', |
| 169 | - function ($schemaManager, $instanceName) use ($sql, $filename) { |
|
| 169 | + function($schemaManager, $instanceName) use ($sql, $filename) { |
|
| 170 | 170 | if ($sql != null) { |
| 171 | 171 | return new Command( |
| 172 | 172 | $sql, |
| 173 | - function ($output, $executor) { |
|
| 173 | + function($output, $executor) { |
|
| 174 | 174 | /** @var TimedExecutor $executor */ |
| 175 | 175 | return array_merge(['stdout' => $output], $executor->getTimingData()); |
| 176 | 176 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | return new File( |
| 185 | 185 | $realFileName, |
| 186 | - function ($output, $executor) { |
|
| 186 | + function($output, $executor) { |
|
| 187 | 187 | /** @var TimedExecutor $executor */ |
| 188 | 188 | return array_merge(['stdout' => $output], $executor->getTimingData()); |
| 189 | 189 | } |
@@ -218,13 +218,13 @@ discard block |
||
| 218 | 218 | if (trim($line) !== '') { |
| 219 | 219 | if ($type === 'err') { |
| 220 | 220 | $this->writeErrorln( |
| 221 | - '[' . $processIndex . '][' . $pid . '] ' . trim($line), |
|
| 221 | + '['.$processIndex.']['.$pid.'] '.trim($line), |
|
| 222 | 222 | OutputInterface::VERBOSITY_VERBOSE, |
| 223 | 223 | OutputInterface::OUTPUT_RAW |
| 224 | 224 | ); |
| 225 | 225 | } else { |
| 226 | 226 | $this->writeln( |
| 227 | - '[' . $processIndex . '][' . $pid . '] ' . trim($line), |
|
| 227 | + '['.$processIndex.']['.$pid.'] '.trim($line), |
|
| 228 | 228 | OutputInterface::VERBOSITY_VERBOSE, |
| 229 | 229 | OutputInterface::OUTPUT_RAW |
| 230 | 230 | ); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | // On Debian, which we use by default, SF has troubles understanding that php was compiled with --enable-sigchild |
| 68 | 68 | // We thus force it, but give end users an option to disable this |
| 69 | 69 | // For more details, see comment 12 at https://bugs.launchpad.net/ubuntu/+source/php5/+bug/516061 |
| 70 | - if (! $input->getOption('dont-force-enabled-sigchild')) { |
|
| 70 | + if (!$input->getOption('dont-force-enabled-sigchild')) { |
|
| 71 | 71 | Process::forceSigchildEnabled(true); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $sql = null; |
| 112 | 112 | } else { |
| 113 | 113 | // this is a coding error, not a sql execution error |
| 114 | - throw new \Exception("Unsupported action type: " . get_class($sqlAction)); |
|
| 114 | + throw new \Exception("Unsupported action type: ".get_class($sqlAction)); |
|
| 115 | 115 | } |
| 116 | 116 | $filterCallable = $sqlAction->getResultsFilterCallable(); |
| 117 | 117 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | if ($filename === null) { |
| 128 | 128 | if (!$sqlAction->isSingleStatement()) { |
| 129 | - $tempSQLFileName = tempnam(sys_get_temp_dir(), 'db3v4l_') . '.sql'; |
|
| 129 | + $tempSQLFileName = tempnam(sys_get_temp_dir(), 'db3v4l_').'.sql'; |
|
| 130 | 130 | file_put_contents($tempSQLFileName, $sql); |
| 131 | 131 | $tempSQLFileNames[] = $tempSQLFileName; |
| 132 | 132 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | if ($this->outputFormat === 'text') { |
| 142 | - $this->writeln('Command line: ' . $process->getCommandLine(), OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 142 | + $this->writeln('Command line: '.$process->getCommandLine(), OutputInterface::VERBOSITY_VERY_VERBOSE); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $process->setTimeout($this->processTimeout); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $succeeded++; |
| 159 | 159 | } catch (\Throwable $t) { |
| 160 | 160 | $failed++; |
| 161 | - $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $t->getMessage() . "</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
| 161 | + $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$t->getMessage()."</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | //$result = null; |
| 181 | 181 | $failed++; |
| 182 | 182 | $succeeded--; |
| 183 | - $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $t->getMessage() . "</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
| 183 | + $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$t->getMessage()."</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | $results[$instanceName] = $output; |
@@ -191,14 +191,14 @@ discard block |
||
| 191 | 191 | 'exitcode' => $process->getExitCode() |
| 192 | 192 | ]; |
| 193 | 193 | $failed++; |
| 194 | - $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: " . $process->getErrorOutput() . "</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
| 194 | + $this->writeErrorln("\n<error>$actionName in instance '$instanceName' failed! Reason: ".$process->getErrorOutput()."</error>\n", OutputInterface::VERBOSITY_NORMAL); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | } finally { |
| 200 | 200 | // make sure that we clean up temp files, as they might contain sensitive data |
| 201 | - foreach($tempSQLFileNames as $tempSQLFileName) { |
|
| 201 | + foreach ($tempSQLFileNames as $tempSQLFileName) { |
|
| 202 | 202 | unlink($tempSQLFileName); |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | protected function writeResults(array $results, $time = null) |
| 245 | 245 | { |
| 246 | - $this->writeln($this->formatResults($results), OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW); |
|
| 246 | + $this->writeln($this->formatResults($results), OutputInterface::VERBOSITY_QUIET, OutputInterface::OUTPUT_RAW); |
|
| 247 | 247 | |
| 248 | 248 | if ($this->outputFormat === 'text') { |
| 249 | - $this->writeln($results['succeeded'] . ' succeeded, ' . $results['failed'] . ' failed'); |
|
| 249 | + $this->writeln($results['succeeded'].' succeeded, '.$results['failed'].' failed'); |
|
| 250 | 250 | |
| 251 | 251 | if ($time !== null) { |
| 252 | 252 | $this->writeln("<info>Time taken: ".sprintf('%.2f', $time)." secs</info>"); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $this->writeResults($results, $time); |
| 49 | 49 | |
| 50 | - return (int)$results['failed']; |
|
| 50 | + return (int) $results['failed']; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | return $this->executeSqlAction( |
| 61 | 61 | $instanceList, |
| 62 | 62 | 'Listing of collations', |
| 63 | - function ($schemaManager, $instanceName) { |
|
| 63 | + function($schemaManager, $instanceName) { |
|
| 64 | 64 | /** @var DatabaseSchemaManager $schemaManager */ |
| 65 | 65 | return $schemaManager->getListCollationsSqlAction(); |
| 66 | 66 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | $dbConnectionSpec = $this->dbConfigurationManager->getInstanceConfiguration($instanceName); |
| 48 | 48 | $executor = $this->executorFactory->createForkedExecutor($dbConnectionSpec, 'NativeClient', false); |
| 49 | 49 | |
| 50 | - if (! $executor instanceof ShellExecutor) { |
|
| 50 | + if (!$executor instanceof ShellExecutor) { |
|
| 51 | 51 | throw new \Exception("Can not start an interactive shell for databases of type '{$dbConnectionSpec['vendor']}'"); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $this->writeResults($results, $time); |
| 49 | 49 | |
| 50 | - return (int)$results['failed']; |
|
| 50 | + return (int) $results['failed']; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | return $this->executeSqlAction( |
| 61 | 61 | $instanceList, |
| 62 | 62 | 'Listing of databases', |
| 63 | - function ($schemaManager, $instanceName) { |
|
| 63 | + function($schemaManager, $instanceName) { |
|
| 64 | 64 | /** @var DatabaseSchemaManager $schemaManager */ |
| 65 | 65 | return $schemaManager->getListDatabasesSqlAction(); |
| 66 | 66 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $userToDropSpecs = []; |
| 53 | - foreach($instanceList as $instanceName => $instanceSpecs) { |
|
| 53 | + foreach ($instanceList as $instanceName => $instanceSpecs) { |
|
| 54 | 54 | $userToDropSpecs[$instanceName] = [ |
| 55 | 55 | 'user' => $userName |
| 56 | 56 | ]; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $this->writeResults($results, $time); |
| 66 | 66 | |
| 67 | - return (int)$results['failed']; |
|
| 67 | + return (int) $results['failed']; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | return $this->executeSqlAction( |
| 80 | 80 | $instanceList, |
| 81 | 81 | 'Dropping of user', |
| 82 | - function ($schemaManager, $instanceName) use ($userToDropSpecs, $ifExists) { |
|
| 82 | + function($schemaManager, $instanceName) use ($userToDropSpecs, $ifExists) { |
|
| 83 | 83 | $dbConnectionSpec = $userToDropSpecs[$instanceName]; |
| 84 | 84 | /** @var DatabaseSchemaManager $schemaManager */ |
| 85 | 85 | return $schemaManager->getDropUserSqlAction( |