diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 4bc37972..be3a7571 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -94,7 +94,7 @@ if ($in) { /** Format string as table row * @return string HTML */ -function pre_tr(string $s) { +function pre_tr(string $s): string { return preg_replace('~^~m', '', preg_replace('~\|~', '', preg_replace('~\|$~m', "", rtrim($s)))); } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 2f67494f..7071eb9d 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -84,9 +84,8 @@ if (!defined('Adminer\DRIVER')) { } /** Set the client character set - * @return bool */ - function set_charset(string $charset) { + function set_charset(string $charset): bool { if (function_exists('mysql_set_charset')) { if (mysql_set_charset($charset, $this->link)) { return true; @@ -137,21 +136,21 @@ if (!defined('Adminer\DRIVER')) { /** Fetch next row as associative array * @return array */ - function fetch_assoc() { + function fetch_assoc(): array { return mysql_fetch_assoc($this->result); } /** Fetch next row as numbered array * @return list */ - function fetch_row() { + function fetch_row(): array { return mysql_fetch_row($this->result); } /** Fetch next field * @return object properties: name, type (0 number, 15 varchar, 254 char), charsetnr (63 binary); optionally: table, orgtable, orgname */ - function fetch_field() { + function fetch_field(): object { $return = mysql_fetch_field($this->result, $this->offset++); // offset required under certain conditions $return->orgtable = $return->table; $return->charsetnr = ($return->blob ? 63 : 0); @@ -357,16 +356,14 @@ if (!defined('Adminer\DRIVER')) { /** Escape database identifier - * @return string */ - function idf_escape(string $idf) { + function idf_escape(string $idf): string { return "`" . str_replace("`", "``", $idf) . "`"; } /** Get escaped table name - * @return string */ - function table(string $idf) { + function table(string $idf): string { return idf_escape($idf); } @@ -394,7 +391,7 @@ if (!defined('Adminer\DRIVER')) { /** Get cached list of databases * @return list */ - function get_databases(bool $flush) { + function get_databases(bool $flush): array { // SHOW DATABASES can take a very long time so it is cached $return = get_session("dbs"); if ($return === null) { @@ -410,25 +407,22 @@ if (!defined('Adminer\DRIVER')) { /** Formulate SQL query with limit * @param string $query everything after SELECT * @param string $where including WHERE - * @return string */ - function limit(string $query, string $where, int $limit, int $offset = 0, string $separator = " ") { + function limit(string $query, string $where, int $limit, int $offset = 0, string $separator = " "): string { return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : ""); } /** Formulate SQL modification query with limit 1 * @param string $query everything after UPDATE or DELETE - * @return string */ - function limit1(string $table, string $query, string $where, string $separator = "\n") { + function limit1(string $table, string $query, string $where, string $separator = "\n"): string { return limit($query, $where, 1, 0, $separator); } /** Get database collation * @param string[][] $collations result of collations() - * @return string */ - function db_collation(string $db, array $collations) { + function db_collation(string $db, array $collations): string { $return = null; $create = get_val("SHOW CREATE DATABASE " . idf_escape($db), 1); if (preg_match('~ COLLATE ([^ ]+)~', $create, $match)) { @@ -441,16 +435,15 @@ if (!defined('Adminer\DRIVER')) { } /** Get logged user - * @return string */ - function logged_user() { + function logged_user(): string { return get_val("SELECT USER()"); } /** Get tables list * @return string[] [$name => $type] */ - function tables_list() { + function tables_list(): array { return get_key_vals("SELECT TABLE_NAME, TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_NAME"); } @@ -458,7 +451,7 @@ if (!defined('Adminer\DRIVER')) { * @param list $databases * @return int[] [$db => $tables] */ - function count_tables(array $databases) { + function count_tables(array $databases): array { $return = array(); foreach ($databases as $db) { $return[$db] = count(get_vals("SHOW TABLES IN " . idf_escape($db))); @@ -470,7 +463,7 @@ if (!defined('Adminer\DRIVER')) { * @param bool $fast return only "Name", "Engine" and "Comment" fields * @return TableStatus[] */ - function table_status(string $name = "", bool $fast = false) { + function table_status(string $name = "", bool $fast = false): array { $return = array(); foreach ( get_rows( @@ -497,24 +490,22 @@ if (!defined('Adminer\DRIVER')) { /** Find out whether the identifier is view * @param TableStatus $table_status - * @return bool */ - function is_view(array $table_status) { + function is_view(array $table_status): bool { return $table_status["Engine"] === null; } /** Check if table supports foreign keys * @param TableStatus $table_status result of table_status1() - * @return bool */ - function fk_support(array $table_status) { + function fk_support(array $table_status): bool { return preg_match('~InnoDB|IBMDB2I' . (min_version(5.6) ? '|NDB' : '') . '~i', $table_status["Engine"]); } /** Get information about fields * @return Field[] */ - function fields(string $table) { + function fields(string $table): array { global $connection; $maria = ($connection->flavor == 'maria'); $return = array(); @@ -568,7 +559,7 @@ if (!defined('Adminer\DRIVER')) { /** Get table indexes * @return Index[] */ - function indexes(string $table, ?Db $connection2 = null) { + function indexes(string $table, ?Db $connection2 = null): array { $return = array(); foreach (get_rows("SHOW INDEX FROM " . table($table), $connection2) as $row) { $name = $row["Key_name"]; @@ -583,7 +574,7 @@ if (!defined('Adminer\DRIVER')) { /** Get foreign keys in table * @return ForeignKey[] */ - function foreign_keys(string $table) { + function foreign_keys(string $table): array { global $driver; static $pattern = '(?:`(?:[^`]|``)+`|"(?:[^"]|"")+")'; $return = array(); @@ -614,14 +605,14 @@ if (!defined('Adminer\DRIVER')) { /** Get view SELECT * @return array{select:string} */ - function view(string $name) { + function view(string $name): array { return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)*\s+AS\s+~isU', '', get_val("SHOW CREATE VIEW " . table($name), 1))); } /** Get sorted grouped list of collations * @return string[][] */ - function collations() { + function collations(): array { $return = array(); foreach (get_rows("SHOW COLLATION") as $row) { if ($row["Default"]) { @@ -638,17 +629,15 @@ if (!defined('Adminer\DRIVER')) { } /** Find out if database is information_schema - * @return bool */ - function information_schema(string $db) { + function information_schema(string $db): bool { return ($db == "information_schema") || (min_version(5.5) && $db == "performance_schema"); } /** Get escaped error message - * @return string */ - function error() { + function error(): string { global $connection; return h(preg_replace('~^You have an error.*syntax to use~U', "Syntax error", $connection->error)); } @@ -662,9 +651,8 @@ if (!defined('Adminer\DRIVER')) { /** Drop databases * @param list $databases - * @return bool */ - function drop_databases(array $databases) { + function drop_databases(array $databases): bool { $return = apply_queries("DROP DATABASE", $databases, 'Adminer\idf_escape'); restart_session(); set_session("dbs", null); @@ -673,9 +661,8 @@ if (!defined('Adminer\DRIVER')) { /** Rename database from DB * @param string $name new name - * @return bool */ - function rename_database(string $name, string $collation) { + function rename_database(string $name, string $collation): bool { $return = false; if (create_database($name, $collation)) { $tables = array(); @@ -694,9 +681,8 @@ if (!defined('Adminer\DRIVER')) { } /** Generate modifier for auto increment column - * @return string */ - function auto_increment() { + function auto_increment(): string { $auto_increment_index = " PRIMARY KEY"; // don't overwrite primary key by auto_increment if ($_GET["create"] != "" && $_POST["auto_increment_col"]) { @@ -773,9 +759,8 @@ if (!defined('Adminer\DRIVER')) { /** Run commands to truncate tables * @param list $tables - * @return bool */ - function truncate_tables(array $tables) { + function truncate_tables(array $tables): bool { return apply_queries("TRUNCATE TABLE", $tables); } @@ -798,9 +783,8 @@ if (!defined('Adminer\DRIVER')) { /** Move tables to other schema * @param list $tables * @param list $views - * @return bool */ - function move_tables(array $tables, array $views, string $target) { + function move_tables(array $tables, array $views, string $target): bool { global $connection; $rename = array(); foreach ($tables as $table) { @@ -827,9 +811,8 @@ if (!defined('Adminer\DRIVER')) { /** Copy tables to other schema * @param list $tables * @param list $views - * @return bool */ - function copy_tables(array $tables, array $views, string $target) { + function copy_tables(array $tables, array $views, string $target): bool { queries("SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'"); foreach ($tables as $table) { $name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table)); @@ -864,7 +847,7 @@ if (!defined('Adminer\DRIVER')) { * @param string $name trigger name * @return Trigger */ - function trigger(string $name, string $table) { + function trigger(string $name, string $table): array { if ($name == "") { return array(); } @@ -875,7 +858,7 @@ if (!defined('Adminer\DRIVER')) { /** Get defined triggers * @return array{string, string}[] */ - function triggers(string $table) { + function triggers(string $table): array { $return = array(); foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_\\"))) as $row) { $return[$row["Trigger"]] = array($row["Timing"], $row["Event"]); @@ -886,7 +869,7 @@ if (!defined('Adminer\DRIVER')) { /** Get trigger options * @return array{Timing: list, Event: list, Type: list} */ - function trigger_options() { + function trigger_options(): array { return array( "Timing" => array("BEFORE", "AFTER"), "Event" => array("INSERT", "UPDATE", "DELETE"), @@ -898,7 +881,7 @@ if (!defined('Adminer\DRIVER')) { * @param 'FUNCTION'|'PROCEDURE' $type * @return Routine */ - function routine(string $name, $type) { + function routine(string $name, $type): array { global $driver; $aliases = array("bool", "boolean", "integer", "double precision", "real", "dec", "numeric", "fixed", "national char", "national varchar"); $space = "(?:\\s|/\\*[\s\S]*?\\*/|(?:#|-- )[^\n]*\n?|--\r?\n)"; @@ -935,30 +918,28 @@ if (!defined('Adminer\DRIVER')) { /** Get list of routines * @return list ["SPECIFIC_NAME" => , "ROUTINE_NAME" => , "ROUTINE_TYPE" => , "DTD_IDENTIFIER" => ] */ - function routines() { + function routines(): array { return get_rows("SELECT ROUTINE_NAME AS SPECIFIC_NAME, ROUTINE_NAME, ROUTINE_TYPE, DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = DATABASE()"); } /** Get list of available routine languages * @return list */ - function routine_languages() { + function routine_languages(): array { return array(); // "SQL" not required } /** Get routine signature * @param Routine $row result of routine() - * @return string */ - function routine_id(string $name, array $row) { + function routine_id(string $name, array $row): string { return idf_escape($name); } /** Get last auto increment ID * @param Result $result or true - * @return string */ - function last_id($result) { + function last_id($result): string { return get_val("SELECT LAST_INSERT_ID()"); // mysql_insert_id() truncates bigint } @@ -979,9 +960,8 @@ if (!defined('Adminer\DRIVER')) { } /** Get SQL command to create table - * @return string */ - function create_sql(string $table, bool $auto_increment, string $style) { + function create_sql(string $table, bool $auto_increment, string $style): string { $return = get_val("SHOW CREATE TABLE " . table($table), 1); if (!$auto_increment) { $return = preg_replace('~ AUTO_INCREMENT=\d+~', '', $return); //! skip comments @@ -990,23 +970,20 @@ if (!defined('Adminer\DRIVER')) { } /** Get SQL command to truncate table - * @return string */ - function truncate_sql(string $table) { + function truncate_sql(string $table): string { return "TRUNCATE " . table($table); } /** Get SQL command to change database - * @return string */ - function use_sql(string $database) { + function use_sql(string $database): string { return "USE " . idf_escape($database); } /** Get SQL commands to create triggers - * @return string */ - function trigger_sql(string $table) { + function trigger_sql(string $table): string { $return = ""; foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_\\")), null, "-- ") as $row) { $return .= "\nCREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . table($row["Table"]) . " FOR EACH ROW\n$row[Statement];;\n"; @@ -1017,21 +994,21 @@ if (!defined('Adminer\DRIVER')) { /** Get server variables * @return list [[$name, $value]] */ - function show_variables() { + function show_variables(): array { return get_rows("SHOW VARIABLES"); } /** Get status variables * @return list [[$name, $value]] */ - function show_status() { + function show_status(): array { return get_rows("SHOW STATUS"); } /** Get process list * @return list [$row] */ - function process_list() { + function process_list(): array { return get_rows("SHOW FULL PROCESSLIST"); } @@ -1054,9 +1031,8 @@ if (!defined('Adminer\DRIVER')) { /** Convert value in edit after applying functions back * @param Field $field one element from fields() * @param string $return SQL expression - * @return string */ - function unconvert_field(array $field, string $return) { + function unconvert_field(array $field, string $return): string { if (preg_match("~binary~", $field["type"])) { $return = "UNHEX($return)"; } @@ -1072,9 +1048,8 @@ if (!defined('Adminer\DRIVER')) { /** Check whether a feature is supported * @param literal-string $feature "check|comment|copy|database|descidx|drop_col|dump|event|indexes|kill|materializedview|partitioning|privileges|procedure|processlist|routine|scheme|sequence|status|table|trigger|type|variables|view|view_trigger" - * @return bool */ - function support(string $feature) { + function support(string $feature): bool { return !preg_match("~scheme|sequence|type|view_trigger|materializedview" . (min_version(8) ? "" : "|descidx" . (min_version(5.1) ? "" : "|event|partitioning")) . (min_version('8.0.16', '10.2.1') ? "" : "|check") . "~", $feature); } @@ -1087,16 +1062,15 @@ if (!defined('Adminer\DRIVER')) { } /** Return query to get connection ID - * @return string */ - function connection_id() { + function connection_id(): string { return "SELECT CONNECTION_ID()"; } /** Get maximum number of connections * @return numeric-string */ - function max_connections() { + function max_connections(): string { return get_val("SELECT @@max_connections"); } @@ -1105,35 +1079,32 @@ if (!defined('Adminer\DRIVER')) { /** Get user defined types * @return string[] [$id => $name] */ - function types() { + function types(): array { return array(); } /** Get values of user defined type - * @return string */ - function type_values(int $id) { + function type_values(int $id): string { return ""; } /** Get existing schemas * @return list */ - function schemas() { + function schemas(): array { return array(); } /** Get current schema - * @return string */ - function get_schema() { + function get_schema(): string { return ""; } /** Set current schema - * @return bool */ - function set_schema(string $schema, Db $connection2 = null) { + function set_schema(string $schema, Db $connection2 = null): bool { return true; } } diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index da72e888..f03cba46 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -461,9 +461,8 @@ if (isset($_GET["sqlite"])) { * @param list|'DROP'}> $indexes [[$type, $name, $columns]], empty to preserve * @param string $drop_check CHECK constraint to drop * @param string $add_check CHECK constraint to add - * @return bool */ - function recreate_table(string $table, string $name, array $fields, array $originals, array $foreign, int $auto_increment = 0, $indexes = array(), string $drop_check = "", string $add_check = "") { + function recreate_table(string $table, string $name, array $fields, array $originals, array $foreign, int $auto_increment = 0, $indexes = array(), string $drop_check = "", string $add_check = ""): bool { global $driver; if ($table != "") { if (!$fields) { diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index d42d1cd5..046103ac 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -10,14 +10,14 @@ class Adminer { /** Name in title and navigation * @return string HTML code */ - function name() { + function name(): string { return "Adminer"; } /** Connection parameters * @return array{string, string, string} */ - function credentials() { + function credentials(): array { return array(SERVER, $_GET["username"], get_password()); } @@ -30,28 +30,26 @@ class Adminer { /** Get key used for permanent login * @return string cryptic string which gets combined with password or false in case of an error */ - function permanentLogin(bool $create = false) { + function permanentLogin(bool $create = false): string { return password_file($create); } /** Return key used to group brute force attacks; behind a reverse proxy, you want to return the last part of X-Forwarded-For - * @return string */ - function bruteForceKey() { + function bruteForceKey(): string { return $_SERVER["REMOTE_ADDR"]; } /** Get server name displayed in breadcrumbs * @return string HTML code or null */ - function serverName(string $server) { + function serverName(string $server): string { return h($server); } /** Identifier of selected database - * @return string */ - function database() { + function database(): string { // should be used everywhere instead of DB return DB; } @@ -59,34 +57,33 @@ class Adminer { /** Get cached list of databases * @return list */ - function databases(bool $flush = true) { + function databases(bool $flush = true): array { return get_databases($flush); } /** Get list of schemas * @return list */ - function schemas() { + function schemas(): array { return schemas(); } /** Specify limit for waiting on some slow queries like DB list * @return float number of seconds */ - function queryTimeout() { + function queryTimeout(): float { return 2; } /** Headers to send before HTML output - * @return void */ - function headers() { + function headers(): void { } /** Get Content Security Policy headers * @return list of arrays with directive name in key, allowed sources in value */ - function csp() { + function csp(): array { return csp(); } @@ -94,7 +91,7 @@ class Adminer { * @param bool $dark dark CSS: false to disable, true to force, null to base on user preferences * @return bool true to link favicon.ico */ - function head(bool $dark = null) { + function head(bool $dark = null): bool { // this is matched by compile.php echo "\n"; echo ($dark !== false ? "\n" : ""); @@ -104,7 +101,7 @@ class Adminer { /** Get URLs of the CSS files * @return list */ - function css() { + function css(): array { $return = array(); foreach (array("", "-dark") as $mode) { $filename = "adminer$mode.css"; @@ -116,9 +113,8 @@ class Adminer { } /** Print login form - * @return void */ - function loginForm() { + function loginForm(): void { global $drivers; echo "\n"; // this is matched by compile.php @@ -136,9 +132,8 @@ class Adminer { /** Get login form field * @param string $heading HTML * @param string $value HTML - * @return string */ - function loginFormField(string $name, string $heading, string $value) { + function loginFormField(string $name, string $heading, string $value): string { return $heading . $value . "\n"; } @@ -156,7 +151,7 @@ class Adminer { * @param TableStatus $tableStatus result of table_status1() * @return string HTML code, "" to ignore table */ - function tableName(array $tableStatus) { + function tableName(array $tableStatus): string { return h($tableStatus["Name"]); } @@ -165,7 +160,7 @@ class Adminer { * @param int $order order of column in select * @return string HTML code, "" to ignore field */ - function fieldName(array $field, int $order = 0) { + function fieldName(array $field, int $order = 0): string { $type = $field["full_type"]; $comment = $field["comment"]; return '' . h($field["field"]) . ''; @@ -174,9 +169,8 @@ class Adminer { /** Print links after select heading * @param TableStatus $tableStatus result of table_status1() * @param string $set new item options, NULL for no new item - * @return void */ - function selectLinks(array $tableStatus, string $set = "") { + function selectLinks(array $tableStatus, string $set = ""): void { global $driver; echo '\n"; // required for IE9 inline edit if (!$failed && ($warnings = $driver->warnings())) { @@ -249,20 +241,19 @@ class Adminer { * @param string $query query to be executed * @return string escaped query to be printed */ - function sqlCommandQuery(string $query) { + function sqlCommandQuery(string $query): string { return shorten_utf8(trim($query), 1000); } /** Print HTML code just before the Execute button in SQL command - * @return void */ - function sqlPrintAfter() { + function sqlPrintAfter(): void { } /** Description of a row in a table * @return string SQL expression, empty string for no description */ - function rowDescription(string $table) { + function rowDescription(string $table): string { return ""; } @@ -271,7 +262,7 @@ class Adminer { * @param ForeignKey[] $foreignKeys * @return list */ - function rowDescriptions(array $rows, array $foreignKeys) { + function rowDescriptions(array $rows, array $foreignKeys): array { return $rows; } @@ -288,9 +279,8 @@ class Adminer { * @param string $link link to foreign key * @param Field $field single field returned from fields() * @param string $original original value before applying editVal() and escaping - * @return string */ - function selectVal(string $val, string $link, array $field, string $original) { + function selectVal(string $val, string $link, array $field, string $original): string { $return = ($val === null ? "NULL" : (preg_match("~char|binary|boolean~", $field["type"]) && !preg_match("~var~", $field["type"]) ? "$val" : (preg_match('~json~', $field["type"]) ? "$val" @@ -304,18 +294,16 @@ class Adminer { /** Value conversion used in select and edit * @param Field $field single field returned from fields() - * @return string */ - function editVal(string $val, array $field) { + function editVal(string $val, array $field): string { return $val; } /** Print table structure in tabular format * @param Field[] $fields data about individual fields * @param TableStatus $tableStatus - * @return void */ - function tableStructurePrint(array $fields, array $tableStatus = null) { + function tableStructurePrint(array $fields, array $tableStatus = null): void { global $driver; echo "
\n"; echo "
\n"; @@ -344,9 +332,8 @@ class Adminer { /** Print list of indexes on table in tabular format * @param Index[] $indexes data about all indexes on a table - * @return void */ - function tableIndexesPrint(array $indexes) { + function tableIndexesPrint(array $indexes): void { echo "
\n"; foreach ($indexes as $name => $index) { ksort($index["columns"]); // enforce correct columns order @@ -365,9 +352,8 @@ class Adminer { /** Print columns box in select * @param list $select result of selectColumnsProcess()[0] * @param string[] $columns selectable columns - * @return void */ - function selectColumnsPrint(array $select, array $columns) { + function selectColumnsPrint(array $select, array $columns): void { global $driver; print_fieldset("select", lang('Select'), $select); $i = 0; @@ -393,9 +379,8 @@ class Adminer { * @param list $where result of selectSearchProcess() * @param string[] $columns selectable columns * @param Index[] $indexes - * @return void */ - function selectSearchPrint(array $where, array $columns, array $indexes) { + function selectSearchPrint(array $where, array $columns, array $indexes): void { print_fieldset("search", lang('Search'), $where); foreach ($indexes as $i => $index) { if ($index["type"] == "FULLTEXT") { @@ -429,9 +414,8 @@ class Adminer { * @param list $order result of selectOrderProcess() * @param string[] $columns selectable columns * @param Index[] $indexes - * @return void */ - function selectOrderPrint(array $order, array $columns, array $indexes) { + function selectOrderPrint(array $order, array $columns, array $indexes): void { print_fieldset("sort", lang('Sort'), $order); $i = 0; foreach ((array) $_GET["order"] as $key => $val) { @@ -448,9 +432,8 @@ class Adminer { /** Print limit box in select * @param string $limit result of selectLimitProcess() - * @return void */ - function selectLimitPrint(string $limit) { + function selectLimitPrint(string $limit): void { echo "
" . lang('Limit') . "
"; //
for easy styling echo ""; echo script("qsl('input').oninput = selectFieldChange;", ""); @@ -459,9 +442,8 @@ class Adminer { /** Print text length box in select * @param string $text_length result of selectLengthProcess() - * @return void */ - function selectLengthPrint(string $text_length) { + function selectLengthPrint(string $text_length): void { if ($text_length !== null) { echo "
" . lang('Text length') . "
"; echo ""; @@ -471,9 +453,8 @@ class Adminer { /** Print action box in select * @param Index[] $indexes - * @return void */ - function selectActionPrint(array $indexes) { + function selectActionPrint(array $indexes): void { echo "
" . lang('Action') . "
"; echo ""; echo " "; @@ -499,23 +480,22 @@ class Adminer { /** Print command box in select * @return bool whether to print default commands */ - function selectCommandPrint() { + function selectCommandPrint(): bool { return !information_schema(DB); } /** Print import box in select * @return bool whether to print default import */ - function selectImportPrint() { + function selectImportPrint(): bool { return !information_schema(DB); } /** Print extra text in the end of a select form * @param string[] $emailFields fields holding e-mails * @param string[] $columns selectable columns - * @return void */ - function selectEmailPrint(array $emailFields, array $columns) { + function selectEmailPrint(array $emailFields, array $columns): void { } /** Process columns box in select @@ -523,7 +503,7 @@ class Adminer { * @param Index[] $indexes * @return list> [[select_expressions], [group_expressions]] */ - function selectColumnsProcess(array $columns, array $indexes) { + function selectColumnsProcess(array $columns, array $indexes): array { global $driver; $select = array(); // select expressions, empty for * $group = array(); // expressions without aggregation - will be used for GROUP BY if an aggregation function is used @@ -543,7 +523,7 @@ class Adminer { * @param Index[] $indexes * @return list expressions to join by AND */ - function selectSearchProcess(array $fields, array $indexes) { + function selectSearchProcess(array $fields, array $indexes): array { global $connection, $driver; $return = array(); foreach ($indexes as $i => $index) { @@ -597,7 +577,7 @@ class Adminer { * @param Index[] $indexes * @return list expressions to join by comma */ - function selectOrderProcess(array $fields, array $indexes) { + function selectOrderProcess(array $fields, array $indexes): array { $return = array(); foreach ((array) $_GET["order"] as $key => $val) { if ($val != "") { @@ -612,14 +592,14 @@ class Adminer { /** Process limit box in select * @return string expression to use in LIMIT, will be escaped */ - function selectLimitProcess() { + function selectLimitProcess(): string { return (isset($_GET["limit"]) ? $_GET["limit"] : "50"); } /** Process length box in select * @return string number of characters to shorten texts, will be escaped */ - function selectLengthProcess() { + function selectLengthProcess(): string { return (isset($_GET["text_length"]) ? $_GET["text_length"] : "100"); } @@ -628,7 +608,7 @@ class Adminer { * @param ForeignKey[] $foreignKeys * @return bool true if processed, false to process other parts of form */ - function selectEmailProcess(array $where, array $foreignKeys) { + function selectEmailProcess(array $where, array $foreignKeys): bool { return false; } @@ -641,16 +621,15 @@ class Adminer { * @param int $page index of page starting at zero * @return string empty string to use default query */ - function selectQueryBuild(array $select, array $where, array $group, array $order, int $limit, int $page) { + function selectQueryBuild(array $select, array $where, array $group, array $order, int $limit, int $page): string { return ""; } /** Query printed after execution in the message * @param string $query executed query * @param string $time elapsed time - * @return string */ - function messageQuery(string $query, string $time, bool $failed = false) { + function messageQuery(string $query, string $time, bool $failed = false): string { global $driver; restart_session(); $history = &get_session("queries"); @@ -678,16 +657,15 @@ class Adminer { /** Print before edit form * @param Field[] $fields * @param mixed $row - * @return void */ - function editRowPrint(string $table, array $fields, $row, bool $update) { + function editRowPrint(string $table, array $fields, $row, bool $update): void { } /** Functions displayed in edit form * @param Field $field single field from fields() * @return list */ - function editFunctions(array $field) { + function editFunctions(array $field): array { global $driver; $return = ($field["null"] ? "NULL/" : ""); $update = isset($_GET["select"]) || where($_GET); @@ -715,7 +693,7 @@ class Adminer { * @param string $attrs attributes to use inside the tag * @return string custom input field or empty string for default */ - function editInput(string $table, array $field, string $attrs, string $value) { + function editInput(string $table, array $field, string $attrs, string $value): string { if ($field["type"] == "enum") { return (isset($_GET["select"]) ? " " : "") . ($field["null"] ? " " : "") @@ -728,9 +706,8 @@ class Adminer { /** Get hint for edit field * @param string $table table name * @param Field $field single field from fields() - * @return string */ - function editHint(string $table, array $field, string $value) { + function editHint(string $table, array $field, string $value): string { return ""; } @@ -738,7 +715,7 @@ class Adminer { * @param Field $field single field from fields() * @return string expression to use in a query */ - function processInput(array $field, string $value, string $function = "") { + function processInput(array $field, string $value, string $function = ""): string { if ($function == "SQL") { return $value; // SQL injection } @@ -763,7 +740,7 @@ class Adminer { /** Return export output options * @return string[] */ - function dumpOutput() { + function dumpOutput(): array { $return = array('text' => lang('open'), 'file' => lang('save')); if (function_exists('gzencode')) { $return['gz'] = 'gzip'; @@ -774,21 +751,21 @@ class Adminer { /** Return export format options * @return string[] empty to disable export */ - function dumpFormat() { + function dumpFormat(): array { return (support("dump") ? array('sql' => 'SQL') : array()) + array('csv' => 'CSV,', 'csv;' => 'CSV;', 'tsv' => 'TSV'); } /** Export database structure * @return void prints data */ - function dumpDatabase(string $db) { + function dumpDatabase(string $db): void { } /** Export table structure * @param int $is_view 0 table, 1 view, 2 temporary view table * @return void prints data */ - function dumpTable(string $table, string $style, int $is_view = 0) { + function dumpTable(string $table, string $style, int $is_view = 0): void { if ($_POST["format"] != "sql") { echo "\xef\xbb\xbf"; // UTF-8 byte order mark if ($style) { @@ -820,7 +797,7 @@ class Adminer { /** Export table data * @return void prints data */ - function dumpData(string $table, string $style, string $query) { + function dumpData(string $table, string $style, string $query): void { global $connection; if ($style) { $max_packet = (JUSH == "sqlite" ? 0 : 1048576); // default, minimum is 1024 @@ -911,14 +888,14 @@ class Adminer { /** Set export filename * @return string filename without extension */ - function dumpFilename(string $identifier) { + function dumpFilename(string $identifier): string { return friendly_url($identifier != "" ? $identifier : (SERVER != "" ? SERVER : "localhost")); } /** Send headers for export * @return string extension */ - function dumpHeaders(string $identifier, bool $multi_table = false) { + function dumpHeaders(string $identifier, bool $multi_table = false): string { $output = $_POST["output"]; $ext = (preg_match('~sql~', $_POST["format"]) ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR header("Content-Type: " . @@ -938,7 +915,7 @@ class Adminer { /** Print text after export * @return void prints data */ - function dumpFooter() { + function dumpFooter(): void { if ($_POST["format"] == "sql") { echo "-- " . gmdate("Y-m-d H:i:s e") . "\n"; } @@ -947,14 +924,14 @@ class Adminer { /** Set the path of the file for webserver load * @return string path of the sql dump file */ - function importServerPath() { + function importServerPath(): string { return "adminer.sql"; } /** Print homepage * @return bool whether to print default homepage */ - function homepage() { + function homepage(): bool { echo '

" . $this->name() . " $VERSION"; $new_version = $_COOKIE["adminer_version"]; @@ -1025,9 +1001,8 @@ class Adminer { /** Set up syntax highlight for code and