@@ -7,7 +7,7 @@ |
||
7 | 7 | // Avoid bootstrapping Symfony for something so trivial... |
8 | 8 | $config = \Symfony\Component\Yaml\Yaml::parseFile(dirname(dirname(__DIR__)).'/config/services.yaml'); |
9 | 9 | $servers = []; |
10 | - foreach($config['parameters']['db3v4l.database_instances'] as $instance => $def) { |
|
10 | + foreach ($config['parameters']['db3v4l.database_instances'] as $instance => $def) { |
|
11 | 11 | $servers[$instance] = new AdminerLoginServerEnhanced( |
12 | 12 | $def['host'].':'.$def['port'], |
13 | 13 | $def['vendor'].' '.$def['version'], |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | case 'mysql': |
56 | 56 | $command = 'mysql'; |
57 | 57 | $options = [ |
58 | - '--host=' . $this->databaseConfiguration['host'], |
|
59 | - '--port=' . $this->databaseConfiguration['port'] ?? '3306', |
|
60 | - '--user=' . $this->databaseConfiguration['user'], |
|
61 | - '-p' . $this->databaseConfiguration['password'], |
|
58 | + '--host='.$this->databaseConfiguration['host'], |
|
59 | + '--port='.$this->databaseConfiguration['port'] ?? '3306', |
|
60 | + '--user='.$this->databaseConfiguration['user'], |
|
61 | + '-p'.$this->databaseConfiguration['password'], |
|
62 | 62 | '--binary-mode', // 'It also disables all mysql commands except charset and delimiter in non-interactive mode (for input piped to mysql or loaded using the source command)' |
63 | 63 | '-t', |
64 | 64 | ]; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $options[] = $this->databaseConfiguration['dbname']; |
67 | 67 | } |
68 | 68 | if ($action == self::EXECUTE_COMMAND) { |
69 | - $options[] = '--execute=' . $sqlOrFilename; |
|
69 | + $options[] = '--execute='.$sqlOrFilename; |
|
70 | 70 | } |
71 | 71 | // $env = [ |
72 | 72 | // problematic when wrapping the process in a call to `time`... |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | // NB: this triggers a different behaviour that piping multiple commands to stdin, namely |
89 | 89 | // it wraps all of the commands in a transaction and allows either sql commands or a single meta-command |
90 | 90 | if ($action == self::EXECUTE_COMMAND) { |
91 | - $options[] = '--command=' . $sqlOrFilename; |
|
91 | + $options[] = '--command='.$sqlOrFilename; |
|
92 | 92 | } |
93 | 93 | //$env = [ |
94 | 94 | // problematic when wrapping the process in a call to `time`... |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | case 'sqlcmd': |
100 | 100 | $command = 'sqlcmd'; |
101 | 101 | $options = [ |
102 | - '-S' . $this->databaseConfiguration['host'] . ($this->databaseConfiguration['port'] != '' ? ',' . $this->databaseConfiguration['port'] : ''), |
|
103 | - '-U' . $this->databaseConfiguration['user'], |
|
104 | - '-P' . $this->databaseConfiguration['password'], |
|
102 | + '-S'.$this->databaseConfiguration['host'].($this->databaseConfiguration['port'] != '' ? ','.$this->databaseConfiguration['port'] : ''), |
|
103 | + '-U'.$this->databaseConfiguration['user'], |
|
104 | + '-P'.$this->databaseConfiguration['password'], |
|
105 | 105 | '-r1', |
106 | 106 | '-b', |
107 | 107 | ]; |
108 | 108 | if (isset($this->databaseConfiguration['dbname'])) { |
109 | - $options[] = '-d' . $this->databaseConfiguration['dbname']; |
|
109 | + $options[] = '-d'.$this->databaseConfiguration['dbname']; |
|
110 | 110 | } |
111 | 111 | if ($action == self::EXECUTE_FILE) { |
112 | - $options[] = '-i' . $sqlOrFilename; |
|
112 | + $options[] = '-i'.$sqlOrFilename; |
|
113 | 113 | } elseif ($action == self::EXECUTE_COMMAND) { |
114 | - $options[] = '-Q' . $sqlOrFilename; |
|
114 | + $options[] = '-Q'.$sqlOrFilename; |
|
115 | 115 | } |
116 | 116 | break; |
117 | 117 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | // 'path' is the full path to the 'master' db (for Doctrine compatibility). |
121 | 121 | // non-master dbs are supposed to reside in the same directory |
122 | 122 | if (isset($this->databaseConfiguration['dbname'])) { |
123 | - $options[] = dirname($this->databaseConfiguration['path']) . '/' . $this->databaseConfiguration['dbname'] . '.sqlite'; |
|
123 | + $options[] = dirname($this->databaseConfiguration['path']).'/'.$this->databaseConfiguration['dbname'].'.sqlite'; |
|
124 | 124 | } else { |
125 | 125 | $options[] = $this->databaseConfiguration['path']; |
126 | 126 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | /// @todo investigate: for psql is this better done via --file ? |
145 | 145 | if ($action == self::EXECUTE_FILE && $clientType != 'sqlsrv') { |
146 | - $commandLine .= ' < ' . escapeshellarg($sqlOrFilename); |
|
146 | + $commandLine .= ' < '.escapeshellarg($sqlOrFilename); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return new Process($commandLine, null, $env); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | array_shift($output); // headers |
182 | 182 | array_shift($output); // '+--+' |
183 | 183 | array_pop($output); // '+--+' |
184 | - foreach($output as &$line) { |
|
184 | + foreach ($output as &$line) { |
|
185 | 185 | $line = trim($line, '|'); |
186 | 186 | $line = trim($line); |
187 | 187 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | array_shift($output); // headers |
193 | 193 | array_shift($output); // '---' |
194 | 194 | //array_pop($output); // '(N rows)' |
195 | - foreach($output as &$line) { |
|
195 | + foreach ($output as &$line) { |
|
196 | 196 | $line = trim($line); |
197 | 197 | } |
198 | 198 | return $output; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | array_shift($output); // '---' |
206 | 206 | array_pop($output); // blank line |
207 | 207 | array_pop($output); // '(N rows affected)' |
208 | - foreach($output as &$line) { |
|
208 | + foreach ($output as &$line) { |
|
209 | 209 | $line = trim($line); |
210 | 210 | } |
211 | 211 | return $output; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | // wrap in a `time` call |
30 | 30 | $this->timingFile = tempnam(sys_get_temp_dir(), 'db3v4l_'); |
31 | 31 | $process->setCommandLine( |
32 | - $this->timeCmd . ' ' . escapeshellarg('--output=' . $this->timingFile) . ' ' . escapeshellarg('--format=%M %e') . ' ' |
|
32 | + $this->timeCmd.' '.escapeshellarg('--output='.$this->timingFile).' '.escapeshellarg('--format=%M %e').' ' |
|
33 | 33 | . $process->getCommandLine()); |
34 | 34 | return $process; |
35 | 35 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | // wrap in a `time` call |
42 | 42 | $this->timingFile = tempnam(sys_get_temp_dir(), 'db3v4l_'); |
43 | 43 | $process->setCommandLine( |
44 | - $this->timeCmd . ' ' . escapeshellarg('--output=' . $this->timingFile) . ' ' . escapeshellarg('--format=%M %e') . ' ' |
|
44 | + $this->timeCmd.' '.escapeshellarg('--output='.$this->timingFile).' '.escapeshellarg('--format=%M %e').' ' |
|
45 | 45 | . $process->getCommandLine()); |
46 | 46 | |
47 | 47 | return $process; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | if ($onceIsEnough) { |
73 | - unlink ($this->timingFile); |
|
73 | + unlink($this->timingFile); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return $results; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | case 'mariadb': |
48 | 48 | case 'mysql': |
49 | 49 | $statements = [ |
50 | - "CREATE DATABASE `$dbName`" . ($collation !== null ? " CHARACTER SET $collation" : '') . ';' |
|
50 | + "CREATE DATABASE `$dbName`".($collation !== null ? " CHARACTER SET $collation" : '').';' |
|
51 | 51 | ]; |
52 | 52 | if ($userName != '') { |
53 | 53 | $statements[] = "CREATE USER '$userName'@'%' IDENTIFIED BY '$password';"; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | // Also, by default connections are in autocommit mode... |
63 | 63 | // And yet, we need a GO to commit the db creation... |
64 | 64 | "SET QUOTED_IDENTIFIER ON;", |
65 | - "CREATE DATABASE \"$dbName\"" . ($collation !== null ? " COLLATE $collation" : '') . ';' |
|
65 | + "CREATE DATABASE \"$dbName\"".($collation !== null ? " COLLATE $collation" : '').';' |
|
66 | 66 | ]; |
67 | 67 | if ($userName != '') { |
68 | 68 | $statements[] = "CREATE LOGIN \"$userName\" WITH PASSWORD = '$password', DEFAULT_DATABASE = \"$dbName\", CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF;"; |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | $statements = [ |
80 | 80 | // q: do we need to add 'TEMPLATE template0' ? |
81 | 81 | // see f.e. https://www.vertabelo.com/blog/collations-in-postgresql/ |
82 | - "CREATE DATABASE \"$dbName\"" . ($collation !== null ? " ENCODING $collation" : '') . ';', |
|
82 | + "CREATE DATABASE \"$dbName\"".($collation !== null ? " ENCODING $collation" : '').';', |
|
83 | 83 | ]; |
84 | 84 | if ($userName != '') { |
85 | 85 | $statements[] = "COMMIT;"; |
86 | - $statements[] = "CREATE USER \"$userName\" WITH PASSWORD '$password'" . ';'; |
|
86 | + $statements[] = "CREATE USER \"$userName\" WITH PASSWORD '$password'".';'; |
|
87 | 87 | $statements[] = "GRANT ALL ON DATABASE \"$dbName\" TO \"$userName\""; // q: should we avoid granting CREATE? |
88 | 88 | } |
89 | 89 | return new Command($statements); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | case 'sqlite': |
92 | 92 | /// @todo this does not support creation of the new db with a different character encoding... |
93 | 93 | /// see https://stackoverflow.com/questions/21348459/set-pragma-encoding-utf-16-for-main-database-in-sqlite |
94 | - $filename = dirname($this->databaseConfiguration['path']) . '/' . $dbName . '.sqlite'; |
|
94 | + $filename = dirname($this->databaseConfiguration['path']).'/'.$dbName.'.sqlite'; |
|
95 | 95 | return new Command( |
96 | 96 | "ATTACH '$filename' AS \"$dbName\";" |
97 | 97 | ); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | return new Command($statements); |
158 | 158 | |
159 | 159 | case 'sqlite': |
160 | - $filename = dirname($this->databaseConfiguration['path']) . '/' . $dbName . '.sqlite'; |
|
160 | + $filename = dirname($this->databaseConfiguration['path']).'/'.$dbName.'.sqlite'; |
|
161 | 161 | return new Command( |
162 | 162 | null, |
163 | 163 | function() use($filename, $dbName, $ifExists) { |
@@ -242,13 +242,13 @@ discard block |
||
242 | 242 | case 'mysql': |
243 | 243 | return new Command( |
244 | 244 | 'SHOW COLLATION;', |
245 | - function ($output, $executor) { |
|
245 | + function($output, $executor) { |
|
246 | 246 | /** @var Executor $executor */ |
247 | 247 | $lines = $executor->resultSetToArray($output); |
248 | 248 | $out = []; |
249 | - foreach($lines as $line) { |
|
249 | + foreach ($lines as $line) { |
|
250 | 250 | $parts = explode("|", $line, 3); |
251 | - $out[] = trim($parts[0]) . ' (' . trim($parts[1]) .')'; |
|
251 | + $out[] = trim($parts[0]).' ('.trim($parts[1]).')'; |
|
252 | 252 | } |
253 | 253 | return $out; |
254 | 254 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | case 'postgresql': |
260 | 260 | return new Command( |
261 | 261 | 'SELECT collname AS Collation FROM pg_collation ORDER BY collname', |
262 | - function ($output, $executor) { |
|
262 | + function($output, $executor) { |
|
263 | 263 | /** @var Executor $executor */ |
264 | 264 | return $executor->resultSetToArray($output); |
265 | 265 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | return new Command( |
270 | 270 | null, |
271 | 271 | /// @todo list the supported utf16 variants as soon as allow using them |
272 | - function () { |
|
272 | + function() { |
|
273 | 273 | return []; |
274 | 274 | } |
275 | 275 | ); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | case 'mssql': |
290 | 290 | return new Command( |
291 | 291 | 'SELECT name AS Collation FROM fn_helpcollations();', |
292 | - function ($output, $executor) { |
|
292 | + function($output, $executor) { |
|
293 | 293 | /** @var Executor $executor */ |
294 | 294 | return $executor->resultSetToArray($output); |
295 | 295 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | return new Command( |
316 | 316 | /// @todo use 'SHOW DATABASES' for versions < 5 |
317 | 317 | "SELECT SCHEMA_NAME AS 'Database' FROM information_schema.SCHEMATA ORDER BY SCHEMA_NAME;", |
318 | - function ($output, $executor) { |
|
318 | + function($output, $executor) { |
|
319 | 319 | /** @var Executor $executor */ |
320 | 320 | return $executor->resultSetToArray($output); |
321 | 321 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | // the way we create it, the user account is contained in the db |
327 | 327 | // @todo add "WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')" ? |
328 | 328 | "SELECT name AS 'Database' FROM sys.databases ORDER BY name;", |
329 | - function ($output, $executor) { |
|
329 | + function($output, $executor) { |
|
330 | 330 | /** @var Executor $executor */ |
331 | 331 | return $executor->resultSetToArray($output); |
332 | 332 | } |
@@ -337,20 +337,20 @@ discard block |
||
337 | 337 | case 'postgresql': |
338 | 338 | return new Command( |
339 | 339 | 'SELECT datname AS "Database" FROM pg_database ORDER BY datname;', |
340 | - function ($output, $executor) { |
|
340 | + function($output, $executor) { |
|
341 | 341 | /** @var Executor $executor */ |
342 | 342 | return $executor->resultSetToArray($output); |
343 | 343 | } |
344 | 344 | ); |
345 | 345 | |
346 | 346 | case 'sqlite': |
347 | - $fileGlob = dirname($this->databaseConfiguration['path']) . '/*.sqlite'; |
|
347 | + $fileGlob = dirname($this->databaseConfiguration['path']).'/*.sqlite'; |
|
348 | 348 | return new Command( |
349 | 349 | null, |
350 | 350 | function() use ($fileGlob) { |
351 | 351 | $out = []; |
352 | 352 | foreach (glob($fileGlob) as $filename) { |
353 | - $out[] = basename($filename); |
|
353 | + $out[] = basename($filename); |
|
354 | 354 | } |
355 | 355 | return $out; |
356 | 356 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | case 'mysql': |
375 | 375 | return new Command( |
376 | 376 | 'SELECT DISTINCT User FROM mysql.user ORDER BY User;', |
377 | - function ($output, $executor) { |
|
377 | + function($output, $executor) { |
|
378 | 378 | /** @var Executor $executor */ |
379 | 379 | return $executor->resultSetToArray($output); |
380 | 380 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | case 'mssql': |
384 | 384 | return new Command( |
385 | 385 | "SELECT name AS 'User' FROM sys.sql_logins ORDER BY name", |
386 | - function ($output, $executor) { |
|
386 | + function($output, $executor) { |
|
387 | 387 | /** @var Executor $executor */ |
388 | 388 | return $executor->resultSetToArray($output); |
389 | 389 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | case 'postgresql': |
395 | 395 | return new Command( |
396 | 396 | 'SELECT usename AS "User" FROM pg_catalog.pg_user ORDER BY usename;', |
397 | - function ($output, $executor) { |
|
397 | + function($output, $executor) { |
|
398 | 398 | /** @var Executor $executor */ |
399 | 399 | return $executor->resultSetToArray($output); |
400 | 400 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | case 'sqlite': |
404 | 404 | return new Command( |
405 | 405 | null, |
406 | - function () { |
|
406 | + function() { |
|
407 | 407 | // since sqlite does not support users, null seems more appropriate than an empty array... |
408 | 408 | return null; |
409 | 409 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | case 'mysql': |
427 | 427 | return new Command( |
428 | 428 | 'SHOW VARIABLES LIKE "version";', |
429 | - function ($output, $executor) { |
|
429 | + function($output, $executor) { |
|
430 | 430 | /** @var Executor $executor */ |
431 | 431 | $line = $executor->resultSetToArray($output)[0]; |
432 | 432 | $parts = explode('|', $line); |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | case 'postgresql': |
440 | 440 | return new Command( |
441 | 441 | 'SHOW server_version;', |
442 | - function ($output, $executor) { |
|
442 | + function($output, $executor) { |
|
443 | 443 | /** @var Executor $executor */ |
444 | 444 | return $executor->resultSetToArray($output)[0]; |
445 | 445 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | case 'sqlite': |
449 | 449 | return new Command( |
450 | 450 | "select sqlite_version();", |
451 | - function ($output, $executor) { |
|
451 | + function($output, $executor) { |
|
452 | 452 | /** @var Executor $executor */ |
453 | 453 | return $executor->resultSetToArray($output)[0]; |
454 | 454 | } |
@@ -457,12 +457,12 @@ discard block |
||
457 | 457 | case 'mssql': |
458 | 458 | return new Command( |
459 | 459 | "SELECT @@version", |
460 | - function ($output, $executor) { |
|
460 | + function($output, $executor) { |
|
461 | 461 | /** @var Executor $executor */ |
462 | 462 | $output = $executor->resultSetToArray($output); |
463 | 463 | $line = $output[0]; |
464 | 464 | preg_match('/Microsoft SQL Server +([^ ]+) +([^ ]+) +/', $line, $matches); |
465 | - return $matches[1] . ' ' . $matches[2]; |
|
465 | + return $matches[1].' '.$matches[2]; |
|
466 | 466 | } |
467 | 467 | ); |
468 | 468 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $currentProcesses = array_splice($processesQueue, 0, $maxParallel); |
29 | 29 | // start the initial stack of processes |
30 | 30 | foreach ($currentProcesses as $idx => $process) { |
31 | - $process->start(function ($type, $buffer) use ($callback, $idx, $process) { |
|
31 | + $process->start(function($type, $buffer) use ($callback, $idx, $process) { |
|
32 | 32 | if ($callback) { |
33 | 33 | $callback($type, $buffer, $idx, $process); |
34 | 34 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | // directly add and start new process after the previous finished |
45 | 45 | if (count($processesQueue) > 0) { |
46 | 46 | $nextProcess = array_shift($processesQueue); |
47 | - $nextProcess->start(function ($type, $buffer) use ($callback, $nextProcess) { |
|
47 | + $nextProcess->start(function($type, $buffer) use ($callback, $nextProcess) { |
|
48 | 48 | if ($callback) { |
49 | 49 | $callback($type, $buffer, $nextProcess); |
50 | 50 | } |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function list() |
20 | 20 | { |
21 | - $docs = glob($this->docRoot . '/*.md'); |
|
22 | - array_walk($docs, function(&$path, $key) {$path = basename($path);}); |
|
21 | + $docs = glob($this->docRoot.'/*.md'); |
|
22 | + array_walk($docs, function(&$path, $key) {$path = basename($path); }); |
|
23 | 23 | return $this->render('Doc/list.html.twig', ['docs' => $docs]); |
24 | 24 | } |
25 | 25 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | // sanitize |
35 | 35 | $filename = basename($filename); |
36 | 36 | |
37 | - $filename = $this->docRoot . '/' . $filename; |
|
37 | + $filename = $this->docRoot.'/'.$filename; |
|
38 | 38 | |
39 | 39 | if (!is_file($filename)) { |
40 | 40 | throw $this->createNotFoundException("The doc file '$filename' does not exist"); |
@@ -17,7 +17,7 @@ |
||
17 | 17 | public function list(DatabaseConfigurationManager $configurationManager) |
18 | 18 | { |
19 | 19 | $instances = []; |
20 | - foreach($configurationManager->listInstances() as $instanceName) { |
|
20 | + foreach ($configurationManager->listInstances() as $instanceName) { |
|
21 | 21 | $instances[$instanceName] = $configurationManager->getInstanceConfiguration($instanceName); |
22 | 22 | } |
23 | 23 | return $this->render('Instance/list.html.twig', ['instances' => $instances]); |
@@ -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 | } |