From 0c15a9f42debfabd828f620112da1df15bc571a2 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 11 Mar 2025 07:56:28 +0100 Subject: [PATCH] Use private visibility on methods --- adminer/drivers/mssql.inc.php | 8 +- editor/include/adminer.inc.php | 6 +- plugins/drivers/simpledb.php | 20 ++--- plugins/json-column.php | 10 +-- plugins/plugin.php | 142 ++++++++++++++++----------------- plugins/pretty-json-column.php | 6 +- plugins/sql-log.php | 6 +- plugins/translation.php | 8 +- 8 files changed, 103 insertions(+), 103 deletions(-) diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index 93d00541..8626bdcc 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -16,7 +16,7 @@ if (isset($_GET["mssql"])) { var $extension = "sqlsrv", $server_info, $affected_rows, $errno, $error; private $link, $result; - function _get_error() { + private function get_error() { $this->error = ""; foreach (sqlsrv_errors() as $error) { $this->errno = $error["code"]; @@ -44,7 +44,7 @@ if (isset($_GET["mssql"])) { $info = sqlsrv_server_info($this->link); $this->server_info = $info['SQLServerVersion']; } else { - $this->_get_error(); + $this->get_error(); } return (bool) $this->link; } @@ -62,7 +62,7 @@ if (isset($_GET["mssql"])) { $result = sqlsrv_query($this->link, $query); //! , array(), ($unbuffered ? array() : array("Scrollable" => "keyset")) $this->error = ""; if (!$result) { - $this->_get_error(); + $this->get_error(); return false; } return $this->store_result($result); @@ -72,7 +72,7 @@ if (isset($_GET["mssql"])) { $this->result = sqlsrv_query($this->link, $query); $this->error = ""; if (!$this->result) { - $this->_get_error(); + $this->get_error(); return false; } return true; diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index cd1beb32..d6f71bc2 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -248,7 +248,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row //! requires MySQL 5 ); echo "\n"; unset($columns[$name]); - } elseif (is_array($options = $this->_foreignKeyOptions($_GET["select"], $name))) { + } elseif (is_array($options = $this->foreignKeyOptions($_GET["select"], $name))) { if ($fields[$name]["null"]) { $options[0] = '(' . lang('empty') . ')'; } @@ -482,7 +482,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row //! requires MySQL 5 . enum_input("radio", $attrs, $field, ($value || isset($_GET["select"]) ? $value : 0), ($field["null"] ? "" : null)) ; } - $options = $this->_foreignKeyOptions($table, $field["field"], $value); + $options = $this->foreignKeyOptions($table, $field["field"], $value); if ($options !== null) { return (is_array($options) ? "" . optionlist($options, $value, true) . "" @@ -651,7 +651,7 @@ qsl('div').onclick = whisperClick;", "") } } - function _foreignKeyOptions($table, $column, $value = null) { + private function foreignKeyOptions($table, $column, $value = null) { if (list($target, $id, $name) = $this->_foreignColumn(column_foreign_keys($table), $column)) { $return = &$this->values[$target]; if ($return === null) { diff --git a/plugins/drivers/simpledb.php b/plugins/drivers/simpledb.php index 392c1e48..74268789 100644 --- a/plugins/drivers/simpledb.php +++ b/plugins/drivers/simpledb.php @@ -66,8 +66,8 @@ if (isset($_GET["simpledb"])) { $row['itemName()'] = (string) $item->Name; } foreach ($item->Attribute as $attribute) { - $name = $this->_processValue($attribute->Name); - $value = $this->_processValue($attribute->Value); + $name = $this->processValue($attribute->Name); + $value = $this->processValue($attribute->Value); if (isset($row[$name])) { $row[$name] = (array) $row[$name]; $row[$name][] = $value; @@ -85,7 +85,7 @@ if (isset($_GET["simpledb"])) { $this->num_rows = count($this->rows); } - function _processValue($element) { + private function processValue($element) { return (is_object($element) && $element['encoding'] == 'base64' ? base64_decode($element) : (string) $element); } @@ -128,7 +128,7 @@ if (isset($_GET["simpledb"])) { public $primary = "itemName()"; - function _chunkRequest($ids, $action, $params, $expand = array()) { + private function chunkRequest($ids, $action, $params, $expand = array()) { $connection = connection(); foreach (array_chunk($ids, 25) as $chunk) { $params2 = $params; @@ -146,7 +146,7 @@ if (isset($_GET["simpledb"])) { return true; } - function _extractIds($table, $queryWhere, $limit) { + private function extractIds($table, $queryWhere, $limit) { $return = array(); if (preg_match_all("~itemName\(\) = (('[^']*+')+)~", $queryWhere, $matches)) { $return = array_map('Adminer\idf_unescape', $matches[1]); @@ -167,8 +167,8 @@ if (isset($_GET["simpledb"])) { } function delete($table, $queryWhere, $limit = 0) { - return $this->_chunkRequest( - $this->_extractIds($table, $queryWhere, $limit), + return $this->chunkRequest( + $this->extractIds($table, $queryWhere, $limit), 'BatchDeleteAttributes', array('DomainName' => $table) ); @@ -178,7 +178,7 @@ if (isset($_GET["simpledb"])) { $delete = array(); $insert = array(); $i = 0; - $ids = $this->_extractIds($table, $queryWhere, $limit); + $ids = $this->extractIds($table, $queryWhere, $limit); $id = idf_unescape($set["`itemName()`"]); unset($set["`itemName()`"]); foreach ($set as $key => $val) { @@ -198,8 +198,8 @@ if (isset($_GET["simpledb"])) { } } $params = array('DomainName' => $table); - return (!$insert || $this->_chunkRequest(($id != "" ? array($id) : $ids), 'BatchPutAttributes', $params, $insert)) - && (!$delete || $this->_chunkRequest($ids, 'BatchDeleteAttributes', $params, $delete)) + return (!$insert || $this->chunkRequest(($id != "" ? array($id) : $ids), 'BatchPutAttributes', $params, $insert)) + && (!$delete || $this->chunkRequest($ids, 'BatchDeleteAttributes', $params, $delete)) ; } diff --git a/plugins/json-column.php b/plugins/json-column.php index 4d145fcb..c373a2bd 100644 --- a/plugins/json-column.php +++ b/plugins/json-column.php @@ -8,14 +8,14 @@ * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) */ class AdminerJsonColumn { - private function _testJson($value) { + private function testJson($value) { if ((substr($value, 0, 1) == '{' || substr($value, 0, 1) == '[') && ($json = json_decode($value, true))) { return $json; } return $value; } - private function _buildTable($json) { + private function buildTable($json) { echo ''; foreach ($json as $key => $val) { echo ''; @@ -31,7 +31,7 @@ class AdminerJsonColumn { } echo '' . $val . ''; } else { - $this->_buildTable($val); + $this->buildTable($val); } echo ''; echo ''; @@ -40,9 +40,9 @@ class AdminerJsonColumn { } function editInput($table, $field, $attrs, $value) { - $json = $this->_testJson($value); + $json = $this->testJson($value); if ($json !== $value) { - $this->_buildTable($json); + $this->buildTable($json); } } } diff --git a/plugins/plugin.php b/plugins/plugin.php index 551a15f7..aa3cb6db 100644 --- a/plugins/plugin.php +++ b/plugins/plugin.php @@ -25,11 +25,11 @@ class AdminerPlugin extends Adminer\Adminer { //! it is possible to use ReflectionObject to find out which plugins defines which methods at once } - function _callParent($function, $args) { + private function callParent($function, $args) { return call_user_func_array(array('parent', $function), $args); } - function _applyPlugin($function, $args) { + private function applyPlugin($function, $args) { foreach ($this->plugins as $plugin) { if (method_exists($plugin, $function)) { switch (count($args)) { // call_user_func_array() doesn't work well with references @@ -62,11 +62,11 @@ class AdminerPlugin extends Adminer\Adminer { } } } - return $this->_callParent($function, $args); + return $this->callParent($function, $args); } - function _appendPlugin($function, $args) { - $return = $this->_callParent($function, $args); + private function appendPlugin($function, $args) { + $return = $this->callParent($function, $args); foreach ($this->plugins as $plugin) { if (method_exists($plugin, $function)) { $value = call_user_func_array(array($plugin, $function), $args); @@ -82,333 +82,333 @@ class AdminerPlugin extends Adminer\Adminer { function dumpFormat() { $args = func_get_args(); - return $this->_appendPlugin(__FUNCTION__, $args); + return $this->appendPlugin(__FUNCTION__, $args); } function dumpOutput() { $args = func_get_args(); - return $this->_appendPlugin(__FUNCTION__, $args); + return $this->appendPlugin(__FUNCTION__, $args); } function editRowPrint($table, $fields, $row, $update) { $args = func_get_args(); - return $this->_appendPlugin(__FUNCTION__, $args); + return $this->appendPlugin(__FUNCTION__, $args); } function editFunctions($field) { $args = func_get_args(); - return $this->_appendPlugin(__FUNCTION__, $args); + return $this->appendPlugin(__FUNCTION__, $args); } // applyPlugin function name() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function credentials() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function connectSsl() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function permanentLogin($create = false) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function bruteForceKey() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function serverName($server) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function database() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function schemas() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function databases($flush = true) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function queryTimeout() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function headers() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function csp() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function head() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function css() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function loginForm() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function loginFormField($name, $heading, $value) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function login($login, $password) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function tableName($tableStatus) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function fieldName($field, $order = 0) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectLinks($tableStatus, $set = "") { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function foreignKeys($table) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function backwardKeys($table, $tableName) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function backwardKeysPrint($backwardKeys, $row) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectQuery($query, $start, $failed = false) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function sqlCommandQuery($query) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function rowDescription($table) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function rowDescriptions($rows, $foreignKeys) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectLink($val, $field) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectVal($val, $link, $field, $original) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function editVal($val, $field) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function tableStructurePrint($fields) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function tableIndexesPrint($indexes) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectColumnsPrint($select, $columns) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectSearchPrint($where, $columns, $indexes) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectOrderPrint($order, $columns, $indexes) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectLimitPrint($limit) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectLengthPrint($text_length) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectActionPrint($indexes) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectCommandPrint() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectImportPrint() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectEmailPrint($emailFields, $columns) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectColumnsProcess($columns, $indexes) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectSearchProcess($fields, $indexes) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectOrderProcess($fields, $indexes) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectLimitProcess() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectLengthProcess() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectEmailProcess($where, $foreignKeys) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function selectQueryBuild($select, $where, $group, $order, $limit, $page) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function messageQuery($query, $time, $failed = false) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function editInput($table, $field, $attrs, $value) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function editHint($table, $field, $value) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function processInput($field, $value, $function = "") { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function dumpDatabase($db) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function dumpTable($table, $style, $is_view = 0) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function dumpData($table, $style, $query) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function dumpFilename($identifier) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function dumpHeaders($identifier, $multi_table = false) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function importServerPath() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function homepage() { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function navigation($missing) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function databasesPrint($missing) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } function tablesPrint($tables) { $args = func_get_args(); - return $this->_applyPlugin(__FUNCTION__, $args); + return $this->applyPlugin(__FUNCTION__, $args); } } diff --git a/plugins/pretty-json-column.php b/plugins/pretty-json-column.php index 01d63077..f814276f 100644 --- a/plugins/pretty-json-column.php +++ b/plugins/pretty-json-column.php @@ -10,7 +10,7 @@ class AdminerPrettyJsonColumn { $this->adminer = $adminer; } - private function _testJson($value) { + private function testJson($value) { if ((substr($value, 0, 1) == '{' || substr($value, 0, 1) == '[') && ($json = json_decode($value, true))) { return $json; } @@ -18,7 +18,7 @@ class AdminerPrettyJsonColumn { } function editInput($table, $field, $attrs, $value) { - $json = $this->_testJson($value); + $json = $this->testJson($value); if ($json !== $value) { $jsonText = json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); return <<_testJson($value); + $json = $this->testJson($value); if ($json !== $value) { $value = json_encode($json); } diff --git a/plugins/sql-log.php b/plugins/sql-log.php index 8e632225..5927b42f 100644 --- a/plugins/sql-log.php +++ b/plugins/sql-log.php @@ -17,14 +17,14 @@ class AdminerSqlLog { } function messageQuery($query, $time, $failed = false) { - $this->_log($query); + $this->log($query); } function sqlCommandQuery($query) { - $this->_log($query); + $this->log($query); } - function _log($query) { + private function log($query) { if ($this->filename == "") { $adminer = Adminer\adminer(); $this->filename = $adminer->database() . ".sql"; // no database goes to ".sql" to avoid collisions diff --git a/plugins/translation.php b/plugins/translation.php index 6d2561fb..97144b67 100644 --- a/plugins/translation.php +++ b/plugins/translation.php @@ -18,7 +18,7 @@ CREATE TABLE translation ( */ class AdminerTranslation { - function _translate($idf) { + private function translate($idf) { static $translations, $lang; if ($lang === null) { $lang = Adminer\get_lang(); @@ -39,16 +39,16 @@ class AdminerTranslation { } function tableName(&$tableStatus) { - $tableStatus["Comment"] = $this->_translate($tableStatus["Comment"]); + $tableStatus["Comment"] = $this->translate($tableStatus["Comment"]); } function fieldName(&$field, $order = 0) { - $field["comment"] = $this->_translate($field["comment"]); + $field["comment"] = $this->translate($field["comment"]); } function editVal(&$val, $field) { if ($field["type"] == "enum") { - $val = $this->_translate($val); + $val = $this->translate($val); } } }