]> git.joonet.de Git - adminer.git/commitdiff
Specify coding style and follow it
authorJakub Vrana <jakub@vrana.cz>
Wed, 5 Mar 2025 08:14:49 +0000 (09:14 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 5 Mar 2025 12:10:37 +0000 (13:10 +0100)
27 files changed:
.editorconfig
adminer/call.inc.php
adminer/create.inc.php
adminer/drivers/mongo.inc.php
adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/pgsql.inc.php
adminer/dump.inc.php
adminer/file.inc.php
adminer/include/editing.inc.php
adminer/include/functions.inc.php
adminer/processlist.inc.php
adminer/select.inc.php
adminer/static/editing.js
adminer/static/functions.js
adminer/user.inc.php
compile.php
coverage.php
lang.php
phpcs.xml [new file with mode: 0644]
plugins/adminer.js.php
plugins/drivers/elastic.php
plugins/drivers/firebird.php
plugins/edit-calendar.php
plugins/foreign-system.php
plugins/plugin.php
plugins/tables-filter.php

index b67cfe0dcec33d65b70118a9057f514f61c88e87..f416309e1440290e89df2e9e02a1996e270a003b 100644 (file)
@@ -7,7 +7,7 @@ end_of_line = lf
 insert_final_newline = true
 trim_trailing_whitespace = true
 
-[*.{php,css,js}]
+[*.{php,css,js,xml}]
 indent_style = tab
 
 [*.json]
index 3bb25bc713fdcfd1cc093fe3adb7dcaf53083bff..b87f9141209077fbd038715ef24ffffdc935d65e 100644 (file)
@@ -101,9 +101,10 @@ echo
                $first_row = pre_tr($match[2]);
                return "<table>\n" . ($match[1] ? "<thead>$first_row</thead>\n" : $first_row) . pre_tr($match[4]) . "\n</table>";
        },
-       preg_replace('~(\n(    -|mysql)&gt; )(.+)~', "\\1<code class='jush-sql'>\\3</code>",
-       preg_replace('~(.+)\n---+\n~', "<b>\\1</b>\n",
-       h($routine['comment'])
-)));
+       preg_replace(
+               '~(\n(    -|mysql)&gt; )(.+)~',
+               "\\1<code class='jush-sql'>\\3</code>",
+               preg_replace('~(.+)\n---+\n~', "<b>\\1</b>\n", h($routine['comment']))
+       ));
 ?>
 </pre>
index 1d1906e0db7b5ddc0c28be3a84b5684ffbac88e9..abdf83889c10ea8943717997339186ba3b5ba68b 100644 (file)
@@ -188,8 +188,8 @@ foreach ($engines as $engine) {
 <div class="scrollable">
 <table id="edit-fields" class="nowrap">
 <?php
-edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
-?>
+       edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
+       ?>
 </table>
 <?php echo script("editFields();"); ?>
 </div>
@@ -197,16 +197,16 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys);
 <?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" class="size" value="<?php echo h($row["Auto_increment"]); ?>">
 <?php echo checkbox("defaults", 1, ($_POST ? $_POST["defaults"] : adminer_setting("defaults")), lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
 <?php
-$comments = ($_POST ? $_POST["comments"] : adminer_setting("comments"));
-echo (support("comment")
-       ? checkbox("comments", 1, $comments, lang('Comment'), "editingCommentsClick(this, true);", "jsonly")
-               . ' ' . (preg_match('~\n~', $row["Comment"])
-                       ? "<textarea name='Comment' rows='2' cols='20'" . ($comments ? "" : " class='hidden'") . ">" . h($row["Comment"]) . "</textarea>"
-                       : '<input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? "" : " class='hidden'") . '>'
-               )
-       : '')
-;
-?>
+       $comments = ($_POST ? $_POST["comments"] : adminer_setting("comments"));
+       echo (support("comment")
+               ? checkbox("comments", 1, $comments, lang('Comment'), "editingCommentsClick(this, true);", "jsonly")
+                       . ' ' . (preg_match('~\n~', $row["Comment"])
+                               ? "<textarea name='Comment' rows='2' cols='20'" . ($comments ? "" : " class='hidden'") . ">" . h($row["Comment"]) . "</textarea>"
+                               : '<input name="Comment" value="' . h($row["Comment"]) . '" data-maxlength="' . (min_version(5.5) ? 2048 : 60) . '"' . ($comments ? "" : " class='hidden'") . '>'
+                       )
+               : '')
+       ;
+       ?>
 <p>
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php } ?>
@@ -224,13 +224,13 @@ if (support("partitioning")) {
 <table id="partition-table"<?php echo ($partition_table ? "" : " class='hidden'"); ?>>
 <thead><tr><th><?php echo lang('Partition name'); ?><th><?php echo lang('Values'); ?></thead>
 <?php
-foreach ($row["partition_names"] as $key => $val) {
-       echo '<tr>';
-       echo '<td><input name="partition_names[]" value="' . h($val) . '" autocapitalize="off">';
-       echo ($key == count($row["partition_names"]) - 1 ? script("qsl('input').oninput = partitionNameChange;") : '');
-       echo '<td><input name="partition_values[]" value="' . h($row["partition_values"][$key]) . '">';
-}
-?>
+       foreach ($row["partition_names"] as $key => $val) {
+               echo '<tr>';
+               echo '<td><input name="partition_names[]" value="' . h($val) . '" autocapitalize="off">';
+               echo ($key == count($row["partition_names"]) - 1 ? script("qsl('input').oninput = partitionNameChange;") : '');
+               echo '<td><input name="partition_values[]" value="' . h($row["partition_values"][$key]) . '">';
+       }
+       ?>
 </table>
 </div></fieldset>
 <?php
index a11e1d96e6e39004b4cf6dfffe968cde5768dc29..35110b2ea58d5fbd0e8ae7a8530745d49a2ca258 100644 (file)
@@ -376,7 +376,6 @@ if (isset($_GET["mongo"])) {
                        "(date)>=",
                        "(date)<=",
                );
-
        }
 
        function table($idf) {
index 1d5dbcde925c924d727e1dcf90e5c5278012a3f7..0af106b2a3a74a5b63c376fb05519b623a3fe69d 100644 (file)
@@ -367,8 +367,7 @@ WHERE o.schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND o.type IN ('S', 'U',
 FROM sys.indexes i
 INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
 INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
-WHERE OBJECT_NAME(i.object_id) = " . q($table)
-               , $connection2) as $row) {
+WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row) {
                        $name = $row["name"];
                        $return[$name]["type"] = ($row["is_primary_key"] ? "PRIMARY" : ($row["is_unique"] ? "UNIQUE" : "INDEX"));
                        $return[$name]["lengths"] = array();
index 21b304f5fa542a2f20fa2f0b9067036d4b1c6ed6..6ae89e9042e4dd8d083392e9298c59c18ab27022 100644 (file)
@@ -1152,7 +1152,7 @@ if (!defined("DRIVER")) {
        /** Return query to get connection ID
        * @return string
        */
-       function connection_id(){
+       function connection_id() {
                return "SELECT CONNECTION_ID()";
        }
 
index 33be88ff26812e99e8f376da17f76dd498b9b64d..b1557ee4f322701d2780146bd9cf42569124de3f 100644 (file)
@@ -618,10 +618,10 @@ ORDER BY conkey, conname") as $row) {
 
        function drop_tables($tables) {
                foreach ($tables as $table) {
-                               $status = table_status($table);
-                               if (!queries("DROP " . strtoupper($status["Engine"]) . " " . table($table))) {
-                                       return false;
-                               }
+                       $status = table_status($table);
+                       if (!queries("DROP " . strtoupper($status["Engine"]) . " " . table($table))) {
+                               return false;
+                       }
                }
                return true;
        }
@@ -902,7 +902,7 @@ AND typelem = 0"
                return queries("SELECT pg_terminate_backend(" . number($val) . ")");
        }
 
-       function connection_id(){
+       function connection_id() {
                return "SELECT pg_backend_pid()";
        }
 
index 8dfbed605fcbae85e64bcfa508a98ab8c10a0c19..68235ab74aa296c26c99fee4bfab01887ac071e7 100644 (file)
@@ -10,7 +10,8 @@ if ($_POST && !$error) {
        $tables = array_flip((array) $_POST["tables"]) + array_flip((array) $_POST["data"]);
        $ext = dump_headers(
                (count($tables) == 1 ? key($tables) : DB),
-               (DB == "" || count($tables) > 1));
+               (DB == "" || count($tables) > 1)
+       );
        $is_sql = preg_match('~sql~', $_POST["format"]);
 
        if ($is_sql) {
index 8c817697a12ee1362c34a4d4f9e50ad9f4ea395a..0ffe2a896b073363f8b0f8c3f32e93bb5bf97e1e 100644 (file)
@@ -16,11 +16,21 @@ if ($_GET["file"] == "favicon.ico") {
 } else {
        header("Content-Type: image/gif");
        switch ($_GET["file"]) {
-               case "plus.gif": echo compile_file('../adminer/static/plus.gif'); break;
-               case "cross.gif": echo compile_file('../adminer/static/cross.gif'); break;
-               case "up.gif": echo compile_file('../adminer/static/up.gif'); break;
-               case "down.gif": echo compile_file('../adminer/static/down.gif'); break;
-               case "arrow.gif": echo compile_file('../adminer/static/arrow.gif'); break;
+               case "plus.gif":
+                       echo compile_file('../adminer/static/plus.gif');
+                       break;
+               case "cross.gif":
+                       echo compile_file('../adminer/static/cross.gif');
+                       break;
+               case "up.gif":
+                       echo compile_file('../adminer/static/up.gif');
+                       break;
+               case "down.gif":
+                       echo compile_file('../adminer/static/down.gif');
+                       break;
+               case "arrow.gif":
+                       echo compile_file('../adminer/static/arrow.gif');
+                       break;
        }
 }
 exit;
index 6739f5e92f31188eaf0418f8e9c0d76d190e0c42..b23394ef2b3d289a38c72360eefca2fcdfc837ad 100644 (file)
@@ -370,9 +370,11 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
 <?php echo ($type == "PROCEDURE" ? "<td>" . html_select("fields[$i][inout]", explode("|", $inout), $field["inout"]) : ""); ?>
 <th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" data-maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?>
 <input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>"><?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
-<?php if ($type == "TABLE") { ?>
+<?php
+               if ($type == "TABLE") {
+                       ?>
 <td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?>
-<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> aria-labelledby="label-ai"></label><td<?php echo $default_class; ?>><?php
+<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php echo ($field["auto_increment"] ? " checked" : ""); ?> aria-labelledby="label-ai"></label><td<?php echo $default_class; ?>><?php
                        echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php
                        echo (support("comment") ? "<td$comment_class><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' data-maxlength='" . (min_version(5.5) ? 1024 : 255) . "' aria-labelledby='label-comment'>" : "");
                }
@@ -582,9 +584,12 @@ function tar_file($filename, $tmp_file) {
 function ini_bytes($ini) {
        $val = ini_get($ini);
        switch (strtolower(substr($val, -1))) {
-               case 'g': $val = (int)$val * 1024; // no break
-               case 'm': $val = (int)$val * 1024; // no break
-               case 'k': $val = (int)$val * 1024;
+               case 'g':
+                       $val = (int)$val * 1024; // no break
+               case 'm':
+                       $val = (int)$val * 1024; // no break
+               case 'k':
+                       $val = (int)$val * 1024;
        }
        return $val;
 }
index bb841de29a8412c0c1601bb42e531526e80a9ac3..a47031541ede0f39ff4f64f2eb03ba4b459d5ad9 100644 (file)
@@ -502,17 +502,19 @@ function convert_fields($columns, $fields, $select = array()) {
 /** Set cookie valid on current path
 * @param string
 * @param string
-* @param int number of seconds, 0 for session cookie
+* @param int number of seconds, 0 for session cookie, 2592000 - 30 days
 * @return bool
 */
-function cookie($name, $value, $lifetime = 2592000) { // 2592000 - 30 days
+function cookie($name, $value, $lifetime = 2592000) {
        global $HTTPS;
-       return header("Set-Cookie: $name=" . urlencode($value)
-               . ($lifetime ? "; expires=" . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT" : "")
-               . "; path=" . preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"])
-               . ($HTTPS ? "; secure" : "")
-               . "; HttpOnly; SameSite=lax",
-               false);
+       return header(
+               "Set-Cookie: $name=" . urlencode($value)
+                       . ($lifetime ? "; expires=" . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT" : "")
+                       . "; path=" . preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"])
+                       . ($HTTPS ? "; secure" : "")
+                       . "; HttpOnly; SameSite=lax",
+               false
+       );
 }
 
 /** Restart stopped session
index cd804b97aae84438cc64c7476a657fcb2f615deb..e36143a1766fb77f3e599f98e1a07a3985d751b0 100644 (file)
@@ -22,7 +22,6 @@ echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(ta
 // HTML valid because there is always at least one process
 $i = -1;
 foreach (process_list() as $i => $row) {
-
        if (!$i) {
                echo "<thead><tr lang='en'>" . (support("kill") ? "<th>" : "");
                foreach ($row as $key => $val) {
index 9c5dec8e5d9ccd2432cd528bffaaffed8d387ff2..065dba4092232051078d7941fa55302c423ecb8e 100644 (file)
@@ -526,9 +526,8 @@ if (!$columns && support("table")) {
                                echo "<fieldset>";
                                echo "<legend>" . lang('Whole result') . "</legend>";
                                $display_rows = ($exact_count ? "" : "~ ") . $found_rows;
-                               echo checkbox("all", 1, 0, ($found_rows !== false ? ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) : ""),
-                                       "var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$display_rows' : checked); selectCount('selected2', this.checked || !checked ? '$display_rows' : checked);"
-                               ) . "\n";
+                               $onclick = "var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$display_rows' : checked); selectCount('selected2', this.checked || !checked ? '$display_rows' : checked);";
+                               echo checkbox("all", 1, 0, ($found_rows !== false ? ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) : ""), $onclick) . "\n";
                                echo "</fieldset>\n";
 
                                if ($adminer->selectCommandPrint()) {
index 46ec30bd3684387f78c47caf391bc94a98a9e3a8..59d8723ec51da9fd140606ffb266f7ef4a80f967 100644 (file)
@@ -238,9 +238,13 @@ function editFields() {
        els = qsa('[name$="[type]"]');
        for (var i = 0; i < els.length; i++) {
                mixin(els[i], {
-                       onfocus: function () { lastType = selectValue(this); },
+                       onfocus: function () {
+                               lastType = selectValue(this);
+                       },
                        onchange: editingTypeChange,
-                       onmouseover: function (event) { helpMouseover.call(this, event, getTarget(event).value, 1) },
+                       onmouseover: function (event) {
+                               helpMouseover.call(this, event, getTarget(event).value, 1);
+                       },
                        onmouseout: helpMouseout
                });
        }
index 14252b65b96067ebaae007a34a1746c0e1e25345..787ebf73da03a17010ed86deae8af28754086239 100644 (file)
@@ -884,7 +884,8 @@ function addEvent(el, action, handler) {
 * @param HTMLElement
 */
 function focus(el) {
-       setTimeout(function () { // this has to be an anonymous function because Firefox passes some arguments to setTimeout callback
+       setTimeout(function () {
+               // this has to be an anonymous function because Firefox passes some arguments to setTimeout callback
                el.focus();
        }, 0);
 }
index 45e0bb057335ea270aa1f6755aa43940416f3ee6..2a7a53a592cc459e27cbb3742b41ef18d1f37caf 100644 (file)
@@ -135,7 +135,7 @@ if ($_POST) {
 <tr><th><?php echo lang('Server'); ?><td><input name="host" data-maxlength="60" value="<?php echo h($row["host"]); ?>" autocapitalize="off">
 <tr><th><?php echo lang('Username'); ?><td><input name="user" data-maxlength="80" value="<?php echo h($row["user"]); ?>" autocapitalize="off">
 <tr><th><?php echo lang('Password'); ?><td><input name="pass" id="pass" value="<?php echo h($row["pass"]); ?>" autocomplete="new-password">
-<?php if (!$row["hashed"]) { echo script("typePassword(qs('#pass'));"); } ?>
+<?php echo ($row["hashed"] ? "" : script("typePassword(qs('#pass'));")); ?>
 <?php echo (min_version(8) ? "" : checkbox("hashed", 1, $row["hashed"], lang('Hashed'), "typePassword(this.form['pass'], this.checked);")); ?>
 </table>
 
index eac03fc8b3a77754cb7fd0635c96d15f851621fe..17d8cb375d28fdfba747a58b79ca74dd13e715ae 100755 (executable)
@@ -277,11 +277,12 @@ function php_shrink($input) {
        $output = '';
        $in_echo = false;
        $doc_comment = false; // include only first /**
-       for (reset($tokens); list($i, $token) = each($tokens); ) {
+       for (reset($tokens); list($i, $token) = each($tokens);) {
                if (!is_array($token)) {
                        $token = array(0, $token);
                }
-               if ($tokens[$i+2][0] === T_CLOSE_TAG && $tokens[$i+3][0] === T_INLINE_HTML && $tokens[$i+4][0] === T_OPEN_TAG
+               if (
+                       $tokens[$i+2][0] === T_CLOSE_TAG && $tokens[$i+3][0] === T_INLINE_HTML && $tokens[$i+4][0] === T_OPEN_TAG
                        && strlen(add_apo_slashes($tokens[$i+3][1])) < strlen($tokens[$i+3][1]) + 3
                ) {
                        $tokens[$i+2] = array(T_ECHO, 'echo');
index f10fc7fab548fc6e7cd7afd23ca285499ee09aff..8f047395d27d14ab40a3dc44cfc8d00394f4e3c5 100644 (file)
@@ -39,9 +39,15 @@ if (!extension_loaded("xdebug")) {
                $line = $file[$l];
                $color = "#C0FFC0"; // tested
                switch ($coverage[realpath($filename)][$l+1]) {
-                       case -1: $color = "#FFC0C0"; break; // untested
-                       case -2: $color = "Silver"; break; // dead code
-                       case null: $color = ""; break; // not executable
+                       case -1: // untested
+                               $color = "#FFC0C0";
+                               break;
+                       case -2: // dead code
+                               $color = "Silver";
+                               break;
+                       case null: // not executable
+                               $color = "";
+                               break;
                }
                if ($prev_color === null) {
                        $prev_color = $color;
index fa34b91d3744edc1508d4bf7f7d59732341e45ed..b9b805ffabad9593dc33c871a3f9b48d23917a01 100755 (executable)
--- a/lang.php
+++ b/lang.php
@@ -13,13 +13,15 @@ if (isset($_SESSION["lang"])) {
 }
 
 $messages_all = array();
-foreach (array_merge(
-       glob(__DIR__ . "/adminer/*.php"),
-       glob(__DIR__ . "/adminer/include/*.php"),
-       glob(__DIR__ . "/adminer/drivers/*.php"),
-       glob(__DIR__ . "/editor/*.php"),
-       glob(__DIR__ . "/editor/include/*.php")
-) as $filename) {
+foreach (
+       array_merge(
+               glob(__DIR__ . "/adminer/*.php"),
+               glob(__DIR__ . "/adminer/include/*.php"),
+               glob(__DIR__ . "/adminer/drivers/*.php"),
+               glob(__DIR__ . "/editor/*.php"),
+               glob(__DIR__ . "/editor/include/*.php")
+       ) as $filename
+) {
        $file = file_get_contents($filename);
        if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) { // lang() always uses apostrophes
                $messages_all += array_combine($matches[1], $matches[2]);
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644 (file)
index 0000000..e59547b
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<ruleset name="Adminer Coding Standard">
+       <description>The coding standard for Adminer.</description>
+       <arg value="s"/>
+       <arg name="parallel" value="8"/>
+
+       <file>.</file>
+       <exclude-pattern>/externals/</exclude-pattern>
+       <exclude-pattern>/designs/</exclude-pattern>
+
+       <rule ref="PSR12">
+               <exclude name="Generic.Files.LineLength"/>
+               <exclude name="Generic.Whitespace.DisallowTabIndent"/><!-- Replaced by: Generic.Whitespace.DisallowSpaceIndent -->
+               <exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
+               <exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
+               <exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
+               <exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>
+               <exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
+               <exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses"/>
+               <exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine"/><!-- Replaced by: Generic.Classes.OpeningBraceSameLine -->
+               <exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody"/>
+               <exclude name="PSR2.Classes.PropertyDeclaration.Multiple"/>
+               <exclude name="PSR2.Classes.PropertyDeclaration.VarUsed"/>
+               <exclude name="PSR2.Classes.PropertyDeclaration.ScopeMissing"/>
+               <exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
+               <exclude name="PSR12.Classes.ClassInstantiation.MissingParentheses"/>
+               <exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
+               <exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
+               <exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
+               <exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
+               <exclude name="PSR2.Methods.FunctionCallSignature.SpaceBeforeCloseBracket"/>
+               <exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine"/>
+               <exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
+               <exclude name="PSR12.ControlStructures.ControlStructureSpacing.LineIndent"/>
+               <exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine"/><!-- Replaced by: Generic.Functions.OpeningFunctionBraceKernighanRitchie -->
+               <exclude name="PSR12.Properties.ConstantVisibility.NotFound"/><!-- PHP 7.1 is not required. -->
+               <exclude name="Squiz.Scope.MethodScope.Missing"/>
+               <exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose"/>
+
+               <!-- TODO: Ignore only in <?php if () { ?><?php } ?> -->
+               <exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect"/>
+               <exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact"/>
+               <exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
+               <exclude name="Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore"/>
+       </rule>
+
+       <rule ref="Generic.Classes.OpeningBraceSameLine"/>
+       <rule ref="Generic.Whitespace.DisallowSpaceIndent"/>
+       <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
+</ruleset>
index 7e8cf892908fe5ab7f4a7a48d2ae7d891410759d..ad346927f19c5c871c42665e460ac37e8e8b7915 100644 (file)
@@ -8,13 +8,12 @@
  * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
  */
-class AdminerDotJs
-{
-       const FileName = "adminer.js";
+class AdminerDotJs {
+       const FILENAME = "adminer.js";
 
        function head() {
-               if (file_exists(self::FileName)) {
-                       echo script_src(self::FileName . "?v=" . crc32(file_get_contents(self::FileName))), "\n";
+               if (file_exists(self::FILENAME)) {
+                       echo script_src(self::FILENAME . "?v=" . crc32(file_get_contents(self::FILENAME))), "\n";
                }
        }
 }
index 03f480b2370486212da121b07c7ae8d835cfe891..efe8355d423a6eab6b924fe7b03fcb3935e3cf82 100644 (file)
@@ -365,10 +365,12 @@ if (isset($_GET["elastic"])) {
                if ($name != "") {
                        if (isset($stats["indices"][$name])) {
                                return format_index_status($name, $stats["indices"][$name]);
-                       } else foreach ($aliases as $index_name => $index) {
-                               foreach ($index["aliases"] as $alias_name => $alias) {
-                                       if ($alias_name == $name) {
-                                               return format_alias_status($alias_name, $stats["indices"][$index_name]);
+                       } else {
+                               foreach ($aliases as $index_name => $index) {
+                                       foreach ($index["aliases"] as $alias_name => $alias) {
+                                               if ($alias_name == $name) {
+                                                       return format_alias_status($alias_name, $stats["indices"][$index_name]);
+                                               }
                                        }
                                }
                        }
index 31e93fb9d0fda632e48bc4710aae65bf5607c963..434bb54c3da73057555e6de4ccd0f1d92c4413c0 100644 (file)
@@ -8,7 +8,7 @@ add_driver('firebird', 'Firebird (alpha)');
 if (isset($_GET["firebird"])) {
        define("DRIVER", "firebird");
 
-       if (extension_loaded("interbase") ) {
+       if (extension_loaded("interbase")) {
                class Min_DB {
                        var
                                $extension = "Firebird",
index 655a37237a141f36b5678218284480a798592b75..93702d5a5c2ad2aa9c1cc9eedf16f8a93d6702fa 100644 (file)
@@ -49,7 +49,8 @@ class AdminerEditCalendar {
                                . ($field["type"] == "time" ? "timepicker({ $timeFormat })"
                                        : (preg_match("~time~", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
                                                : "datepicker({ $dateFormat })"
-                                       )) . ";");
+                                       )) . ";"
+                       );
                }
        }
 
index ae26cca77da969202ba66081bd4c1b82bc8b9bc2..757ae852f46000ae04c2318350e784f8996d9897 100644 (file)
@@ -10,18 +10,19 @@ class AdminerForeignSystem {
 
        function foreignKeys($table) {
                if (DRIVER == "server" && DB == "mysql") {
-                       switch ($table) {
-                               case "columns_priv": return array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User")));
-                               case "db": return array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User")));
-                               case "help_category": return array(array("table" => "help_category", "source" => array("parent_category_id"), "target" => array("help_category_id")));
-                               case "help_relation": return array(array("table" => "help_topic", "source" => array("help_topic_id"), "target" => array("help_topic_id")), array("table" => "help_keyword", "source" => array("help_keyword_id"), "target" => array("help_keyword_id")));
-                               case "help_topic": return array(array("table" => "help_category", "source" => array("help_category_id"), "target" => array("help_category_id")));
-                               case "procs_priv": return array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User")), array("table" => "proc", "source" => array("Db", "Routine_name"), "target" => array("db", "name")));
-                               case "tables_priv": return array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User")));
-                               case "time_zone_name": return array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id")));
-                               case "time_zone_transition": return array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id")), array("table" => "time_zone_transition_type", "source" => array("Time_zone_id", "Transition_type_id"), "target" => array("Time_zone_id", "Transition_type_id")));
-                               case "time_zone_transition_type": return array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id")));
-                       }
+                       $return = array(
+                               "columns_priv" => array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))),
+                               "db" => array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))),
+                               "help_category" => array(array("table" => "help_category", "source" => array("parent_category_id"), "target" => array("help_category_id"))),
+                               "help_relation" => array(array("table" => "help_topic", "source" => array("help_topic_id"), "target" => array("help_topic_id")), array("table" => "help_keyword", "source" => array("help_keyword_id"), "target" => array("help_keyword_id"))),
+                               "help_topic" => array(array("table" => "help_category", "source" => array("help_category_id"), "target" => array("help_category_id"))),
+                               "procs_priv" => array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User")), array("table" => "proc", "source" => array("Db", "Routine_name"), "target" => array("db", "name"))),
+                               "tables_priv" => array(array("table" => "user", "source" => array("Host", "User"), "target" => array("Host", "User"))),
+                               "time_zone_name" => array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id"))),
+                               "time_zone_transition" => array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id")), array("table" => "time_zone_transition_type", "source" => array("Time_zone_id", "Transition_type_id"), "target" => array("Time_zone_id", "Transition_type_id"))),
+                               "time_zone_transition_type" => array(array("table" => "time_zone", "source" => array("Time_zone_id"), "target" => array("Time_zone_id"))),
+                       );
+                       return $return[$table];
                } elseif (DB == "information_schema") {
                        $schemata = array("table" => "SCHEMATA", "source" => array("TABLE_CATALOG", "TABLE_SCHEMA"), "target" => array("CATALOG_NAME", "SCHEMA_NAME"));
                        $tables = array("table" => "TABLES", "source" => array("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME"), "target" => array("TABLE_CATALOG", "TABLE_SCHEMA", "TABLE_NAME"));
@@ -29,27 +30,28 @@ class AdminerForeignSystem {
                        $character_sets = array("table" => "CHARACTER_SETS", "source" => array("CHARACTER_SET_NAME"), "target" => array("CHARACTER_SET_NAME"));
                        $collations = array("table" => "COLLATIONS", "source" => array("COLLATION_NAME"), "target" => array("COLLATION_NAME"));
                        $routine_charsets = array(array("source" => array("CHARACTER_SET_CLIENT")) + $character_sets, array("source" => array("COLLATION_CONNECTION")) + $collations, array("source" => array("DATABASE_COLLATION")) + $collations);
-                       switch ($table) {
-                               case "CHARACTER_SETS": return array(array("source" => array("DEFAULT_COLLATE_NAME")) + $collations);
-                               case "COLLATIONS": return array($character_sets);
-                               case "COLLATION_CHARACTER_SET_APPLICABILITY": return array($collations, $character_sets);
-                               case "COLUMNS": return array($schemata, $tables, $character_sets, $collations);
-                               case "COLUMN_PRIVILEGES": return array($schemata, $tables, $columns);
-                               case "TABLES": return array($schemata, array("source" => array("TABLE_COLLATION")) + $collations);
-                               case "SCHEMATA": return array(array("source" => array("DEFAULT_CHARACTER_SET_NAME")) + $character_sets, array("source" => array("DEFAULT_COLLATION_NAME")) + $collations);
-                               case "EVENTS": return array_merge(array(array("source" => array("EVENT_CATALOG", "EVENT_SCHEMA")) + $schemata), $routine_charsets);
-                               case "FILES": return array($schemata, $tables);
-                               case "KEY_COLUMN_USAGE": return array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, $schemata, $tables, $columns, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA")) + $schemata, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA", "REFERENCED_TABLE_NAME")) + $tables, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA", "REFERENCED_TABLE_NAME", "REFERENCED_COLUMN_NAME")) + $columns);
-                               case "PARTITIONS": return array($schemata, $tables);
-                               case "REFERENTIAL_CONSTRAINTS": return array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("UNIQUE_CONSTRAINT_CATALOG", "UNIQUE_CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "TABLE_NAME")) + $tables, array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "REFERENCED_TABLE_NAME")) + $tables);
-                               case "ROUTINES": return array_merge(array(array("source" => array("ROUTINE_CATALOG", "ROUTINE_SCHEMA")) + $schemata), $routine_charsets);
-                               case "SCHEMA_PRIVILEGES": return array($schemata);
-                               case "STATISTICS": return array($schemata, $tables, $columns, array("source" => array("TABLE_CATALOG", "INDEX_SCHEMA")) + $schemata);
-                               case "TABLE_CONSTRAINTS": return array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "TABLE_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "TABLE_SCHEMA", "TABLE_NAME")) + $tables);
-                               case "TABLE_PRIVILEGES": return array($schemata, $tables);
-                               case "TRIGGERS": return array_merge(array(array("source" => array("TRIGGER_CATALOG", "TRIGGER_SCHEMA")) + $schemata, array("source" => array("EVENT_OBJECT_CATALOG", "EVENT_OBJECT_SCHEMA")) + $schemata, array("source" => array("EVENT_OBJECT_CATALOG", "EVENT_OBJECT_SCHEMA", "EVENT_OBJECT_TABLE")) + $tables), $routine_charsets);
-                               case "VIEWS": return array($schemata);
-                       }
+                       $return = array(
+                               "CHARACTER_SETS" => array(array("source" => array("DEFAULT_COLLATE_NAME")) + $collations),
+                               "COLLATIONS" => array($character_sets),
+                               "COLLATION_CHARACTER_SET_APPLICABILITY" => array($collations, $character_sets),
+                               "COLUMNS" => array($schemata, $tables, $character_sets, $collations),
+                               "COLUMN_PRIVILEGES" => array($schemata, $tables, $columns),
+                               "TABLES" => array($schemata, array("source" => array("TABLE_COLLATION")) + $collations),
+                               "SCHEMATA" => array(array("source" => array("DEFAULT_CHARACTER_SET_NAME")) + $character_sets, array("source" => array("DEFAULT_COLLATION_NAME")) + $collations),
+                               "EVENTS" => array_merge(array(array("source" => array("EVENT_CATALOG", "EVENT_SCHEMA")) + $schemata), $routine_charsets),
+                               "FILES" => array($schemata, $tables),
+                               "KEY_COLUMN_USAGE" => array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, $schemata, $tables, $columns, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA")) + $schemata, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA", "REFERENCED_TABLE_NAME")) + $tables, array("source" => array("TABLE_CATALOG", "REFERENCED_TABLE_SCHEMA", "REFERENCED_TABLE_NAME", "REFERENCED_COLUMN_NAME")) + $columns),
+                               "PARTITIONS" => array($schemata, $tables),
+                               "REFERENTIAL_CONSTRAINTS" => array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("UNIQUE_CONSTRAINT_CATALOG", "UNIQUE_CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "TABLE_NAME")) + $tables, array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA", "REFERENCED_TABLE_NAME")) + $tables),
+                               "ROUTINES" => array_merge(array(array("source" => array("ROUTINE_CATALOG", "ROUTINE_SCHEMA")) + $schemata), $routine_charsets),
+                               "SCHEMA_PRIVILEGES" => array($schemata),
+                               "STATISTICS" => array($schemata, $tables, $columns, array("source" => array("TABLE_CATALOG", "INDEX_SCHEMA")) + $schemata),
+                               "TABLE_CONSTRAINTS" => array(array("source" => array("CONSTRAINT_CATALOG", "CONSTRAINT_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "TABLE_SCHEMA")) + $schemata, array("source" => array("CONSTRAINT_CATALOG", "TABLE_SCHEMA", "TABLE_NAME")) + $tables),
+                               "TABLE_PRIVILEGES" => array($schemata, $tables),
+                               "TRIGGERS" => array_merge(array(array("source" => array("TRIGGER_CATALOG", "TRIGGER_SCHEMA")) + $schemata, array("source" => array("EVENT_OBJECT_CATALOG", "EVENT_OBJECT_SCHEMA")) + $schemata, array("source" => array("EVENT_OBJECT_CATALOG", "EVENT_OBJECT_SCHEMA", "EVENT_OBJECT_TABLE")) + $tables), $routine_charsets),
+                               "VIEWS" => array($schemata),
+                       );
+                       return $return[$table];
                }
        }
 
index adcc440d3043532417618c5eeaa97a7a9764013e..03f6b5fd26f22f4974aec884650b7f79b68ed08f 100644 (file)
@@ -10,7 +10,8 @@ class AdminerPlugin extends Adminer {
        /** @access protected */
        var $plugins;
 
-       function _findRootClass($class) { // is_subclass_of(string, string) is available since PHP 5.0.3
+       function _findRootClass($class) {
+               // is_subclass_of(string, string) is available since PHP 5.0.3
                do {
                        $return = $class;
                } while ($class = get_parent_class($class));
@@ -41,14 +42,29 @@ class AdminerPlugin extends Adminer {
                foreach ($this->plugins as $plugin) {
                        if (method_exists($plugin, $function)) {
                                switch (count($args)) { // call_user_func_array() doesn't work well with references
-                                       case 0: $return = $plugin->$function(); break;
-                                       case 1: $return = $plugin->$function($args[0]); break;
-                                       case 2: $return = $plugin->$function($args[0], $args[1]); break;
-                                       case 3: $return = $plugin->$function($args[0], $args[1], $args[2]); break;
-                                       case 4: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3]); break;
-                                       case 5: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4]); break;
-                                       case 6: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]); break;
-                                       default: trigger_error('Too many parameters.', E_USER_WARNING);
+                                       case 0:
+                                               $return = $plugin->$function();
+                                               break;
+                                       case 1:
+                                               $return = $plugin->$function($args[0]);
+                                               break;
+                                       case 2:
+                                               $return = $plugin->$function($args[0], $args[1]);
+                                               break;
+                                       case 3:
+                                               $return = $plugin->$function($args[0], $args[1], $args[2]);
+                                               break;
+                                       case 4:
+                                               $return = $plugin->$function($args[0], $args[1], $args[2], $args[3]);
+                                               break;
+                                       case 5:
+                                               $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4]);
+                                               break;
+                                       case 6:
+                                               $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
+                                               break;
+                                       default:
+                                               trigger_error('Too many parameters.', E_USER_WARNING);
                                }
                                if ($return !== null) {
                                        return $return;
index 6836325810ebe9292eb39a75adfb6a17e53eacad..879a392475d69f42daf92a48ae056d91ceb9c1c1 100644 (file)
@@ -7,7 +7,8 @@
 * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
 */
 class AdminerTablesFilter {
-       function tablesPrint($tables) { ?>
+       function tablesPrint($tables) {
+               ?>
 <script<?php echo nonce(); ?>>
 var tablesFilterTimeout = null;
 var tablesFilterValue = '';