diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 67b0eab5..4bc37972 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -92,10 +92,9 @@ if ($in) {
 ', preg_replace('~\|~', '', preg_replace('~\|$~m', "", rtrim($s))));
 }
 
diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php
index d975b680..2f67494f 100644
--- a/adminer/drivers/mysql.inc.php
+++ b/adminer/drivers/mysql.inc.php
@@ -84,10 +84,9 @@ if (!defined('Adminer\DRIVER')) {
 			}
 
 			/** Set the client character set
-			* @param string $charset
 			* @return bool
 			*/
-			function set_charset($charset) {
+			function set_charset(string $charset) {
 				if (function_exists('mysql_set_charset')) {
 					if (mysql_set_charset($charset, $this->link)) {
 						return true;
@@ -129,9 +128,8 @@ if (!defined('Adminer\DRIVER')) {
 			/** @var int */ private $offset = 0;
 
 			/** Constructor
-			* @param resource $result
 			*/
-			function __construct($result) {
+			function __construct(resource $result) {
 				$this->result = $result;
 				$this->num_rows = mysql_num_rows($result);
 			}
@@ -359,18 +357,16 @@ if (!defined('Adminer\DRIVER')) {
 
 
 	/** Escape database identifier
-	* @param string $idf
 	* @return string
 	*/
-	function idf_escape($idf) {
+	function idf_escape(string $idf) {
 		return "`" . str_replace("`", "``", $idf) . "`";
 	}
 
 	/** Get escaped table name
-	* @param string $idf
 	* @return string
 	*/
-	function table($idf) {
+	function table(string $idf) {
 		return idf_escape($idf);
 	}
 
@@ -378,7 +374,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param array{string, string, string} $credentials [$server, $username, $password]
 	* @return string|Db string for error
 	*/
-	function connect($credentials) {
+	function connect(array $credentials) {
 		global $drivers;
 		$connection = new Db;
 		if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
@@ -396,10 +392,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get cached list of databases
-	* @param bool $flush
 	* @return list
 	*/
-	function get_databases($flush) {
+	function get_databases(bool $flush) {
 		// SHOW DATABASES can take a very long time so it is cached
 		$return = get_session("dbs");
 		if ($return === null) {
@@ -415,32 +410,25 @@ if (!defined('Adminer\DRIVER')) {
 	/** Formulate SQL query with limit
 	* @param string $query everything after SELECT
 	* @param string $where including WHERE
-	* @param int $limit
-	* @param int $offset
-	* @param string $separator
 	* @return string
 	*/
-	function limit($query, $where, $limit, $offset = 0, $separator = " ") {
+	function limit(string $query, string $where, int $limit, int $offset = 0, string $separator = " ") {
 		return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
 	}
 
 	/** Formulate SQL modification query with limit 1
-	* @param string $table
 	* @param string $query everything after UPDATE or DELETE
-	* @param string $where
-	* @param string $separator
 	* @return string
 	*/
-	function limit1($table, $query, $where, $separator = "\n") {
+	function limit1(string $table, string $query, string $where, string $separator = "\n") {
 		return limit($query, $where, 1, 0, $separator);
 	}
 
 	/** Get database collation
-	* @param string $db
 	* @param string[][] $collations result of collations()
 	* @return string
 	*/
-	function db_collation($db, $collations) {
+	function db_collation(string $db, array $collations) {
 		$return = null;
 		$create = get_val("SHOW CREATE DATABASE " . idf_escape($db), 1);
 		if (preg_match('~ COLLATE ([^ ]+)~', $create, $match)) {
@@ -470,7 +458,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param list $databases
 	* @return int[] [$db => $tables]
 	*/
-	function count_tables($databases) {
+	function count_tables(array $databases) {
 		$return = array();
 		foreach ($databases as $db) {
 			$return[$db] = count(get_vals("SHOW TABLES IN " . idf_escape($db)));
@@ -479,11 +467,10 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get table status
-	* @param string $name
 	* @param bool $fast return only "Name", "Engine" and "Comment" fields
 	* @return TableStatus[]
 	*/
-	function table_status($name = "", $fast = false) {
+	function table_status(string $name = "", bool $fast = false) {
 		$return = array();
 		foreach (
 			get_rows(
@@ -512,7 +499,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param TableStatus $table_status
 	* @return bool
 	*/
-	function is_view($table_status) {
+	function is_view(array $table_status) {
 		return $table_status["Engine"] === null;
 	}
 
@@ -520,15 +507,14 @@ if (!defined('Adminer\DRIVER')) {
 	* @param TableStatus $table_status result of table_status1()
 	* @return bool
 	*/
-	function fk_support($table_status) {
+	function fk_support(array $table_status) {
 		return preg_match('~InnoDB|IBMDB2I' . (min_version(5.6) ? '|NDB' : '') . '~i', $table_status["Engine"]);
 	}
 
 	/** Get information about fields
-	* @param string $table
 	* @return Field[]
 	*/
-	function fields($table) {
+	function fields(string $table) {
 		global $connection;
 		$maria = ($connection->flavor == 'maria');
 		$return = array();
@@ -580,11 +566,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get table indexes
-	* @param string $table
-	* @param ?Db $connection2
 	* @return Index[]
 	*/
-	function indexes($table, $connection2 = null) {
+	function indexes(string $table, ?Db $connection2 = null) {
 		$return = array();
 		foreach (get_rows("SHOW INDEX FROM " . table($table), $connection2) as $row) {
 			$name = $row["Key_name"];
@@ -597,10 +581,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get foreign keys in table
-	* @param string $table
 	* @return ForeignKey[]
 	*/
-	function foreign_keys($table) {
+	function foreign_keys(string $table) {
 		global $driver;
 		static $pattern = '(?:`(?:[^`]|``)+`|"(?:[^"]|"")+")';
 		$return = array();
@@ -629,10 +612,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get view SELECT
-	* @param string $name
 	* @return array{select:string}
 	*/
-	function view($name) {
+	function view(string $name) {
 		return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)*\s+AS\s+~isU', '', get_val("SHOW CREATE VIEW " . table($name), 1)));
 	}
 
@@ -656,10 +638,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Find out if database is information_schema
-	* @param string $db
 	* @return bool
 	*/
-	function information_schema($db) {
+	function information_schema(string $db) {
 		return ($db == "information_schema")
 			|| (min_version(5.5) && $db == "performance_schema");
 	}
@@ -673,11 +654,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Create database
-	* @param string $db
-	* @param string $collation
 	* @return Result
 	*/
-	function create_database($db, $collation) {
+	function create_database(string $db, string $collation) {
 		return queries("CREATE DATABASE " . idf_escape($db) . ($collation ? " COLLATE " . q($collation) : ""));
 	}
 
@@ -685,7 +664,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param list $databases
 	* @return bool
 	*/
-	function drop_databases($databases) {
+	function drop_databases(array $databases) {
 		$return = apply_queries("DROP DATABASE", $databases, 'Adminer\idf_escape');
 		restart_session();
 		set_session("dbs", null);
@@ -694,10 +673,9 @@ if (!defined('Adminer\DRIVER')) {
 
 	/** Rename database from DB
 	* @param string $name new name
-	* @param string $collation
 	* @return bool
 	*/
-	function rename_database($name, $collation) {
+	function rename_database(string $name, string $collation) {
 		$return = false;
 		if (create_database($name, $collation)) {
 			$tables = array();
@@ -740,14 +718,10 @@ if (!defined('Adminer\DRIVER')) {
 	* @param string $name new name
 	* @param list, string}> $fields of [$orig, $process_field, $after]
 	* @param string[] $foreign
-	* @param string $comment
-	* @param string $engine
-	* @param string $collation
 	* @param string $auto_increment number
-	* @param string $partitioning
 	* @return Result|bool
 	*/
-	function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
+	function alter_table(string $table, string $name, array $fields, array $foreign, string $comment, string $engine, string $collation, string $auto_increment, string $partitioning) {
 		global $connection;
 		$alter = array();
 		foreach ($fields as $field) {
@@ -786,7 +760,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param list}> $alter of ["index type", "name", ["column definition", ...]] or ["index type", "name", "DROP"]
 	* @return Result|bool
 	*/
-	function alter_indexes($table, $alter) {
+	function alter_indexes(string $table, $alter) {
 		$changes = array();
 		foreach ($alter as $val) {
 			$changes[] = ($val[2] == "DROP"
@@ -801,7 +775,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param list $tables
 	* @return bool
 	*/
-	function truncate_tables($tables) {
+	function truncate_tables(array $tables) {
 		return apply_queries("TRUNCATE TABLE", $tables);
 	}
 
@@ -809,7 +783,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param list $views
 	* @return Result|bool
 	*/
-	function drop_views($views) {
+	function drop_views(array $views) {
 		return queries("DROP VIEW " . implode(", ", array_map('Adminer\table', $views)));
 	}
 
@@ -817,17 +791,16 @@ if (!defined('Adminer\DRIVER')) {
 	* @param list $tables
 	* @return Result|bool
 	*/
-	function drop_tables($tables) {
+	function drop_tables(array $tables) {
 		return queries("DROP TABLE " . implode(", ", array_map('Adminer\table', $tables)));
 	}
 
 	/** Move tables to other schema
 	* @param list $tables
 	* @param list $views
-	* @param string $target
 	* @return bool
 	*/
-	function move_tables($tables, $views, $target) {
+	function move_tables(array $tables, array $views, string $target) {
 		global $connection;
 		$rename = array();
 		foreach ($tables as $table) {
@@ -854,10 +827,9 @@ if (!defined('Adminer\DRIVER')) {
 	/** Copy tables to other schema
 	* @param list $tables
 	* @param list $views
-	* @param string $target
 	* @return bool
 	*/
-	function copy_tables($tables, $views, $target) {
+	function copy_tables(array $tables, array $views, string $target) {
 		queries("SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'");
 		foreach ($tables as $table) {
 			$name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table));
@@ -890,10 +862,9 @@ if (!defined('Adminer\DRIVER')) {
 
 	/** Get information about trigger
 	* @param string $name trigger name
-	* @param string $table
 	* @return Trigger
 	*/
-	function trigger($name, $table) {
+	function trigger(string $name, string $table) {
 		if ($name == "") {
 			return array();
 		}
@@ -902,10 +873,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get defined triggers
-	* @param string $table
 	* @return array{string, string}[]
 	*/
-	function triggers($table) {
+	function triggers(string $table) {
 		$return = array();
 		foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_\\"))) as $row) {
 			$return[$row["Trigger"]] = array($row["Timing"], $row["Event"]);
@@ -925,11 +895,10 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get information about stored routine
-	* @param string $name
 	* @param 'FUNCTION'|'PROCEDURE' $type
 	* @return Routine
 	*/
-	function routine($name, $type) {
+	function routine(string $name, $type) {
 		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)";
@@ -978,11 +947,10 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get routine signature
-	* @param string $name
 	* @param Routine $row result of routine()
 	* @return string
 	*/
-	function routine_id($name, $row) {
+	function routine_id(string $name, array $row) {
 		return idf_escape($name);
 	}
 
@@ -995,11 +963,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Explain select
-	* @param Db $connection
-	* @param string $query
 	* @return Result
 	*/
-	function explain($connection, $query) {
+	function explain(Db $connection, string $query) {
 		return $connection->query("EXPLAIN " . (min_version(5.1) && !min_version(5.7) ? "PARTITIONS " : "") . $query);
 	}
 
@@ -1008,17 +974,14 @@ if (!defined('Adminer\DRIVER')) {
 	* @param list $where
 	* @return numeric-string|null null if approximate number can't be retrieved
 	*/
-	function found_rows($table_status, $where) {
+	function found_rows(array $table_status, array $where) {
 		return ($where || $table_status["Engine"] != "InnoDB" ? null : $table_status["Rows"]);
 	}
 
 	/** Get SQL command to create table
-	* @param string $table
-	* @param bool $auto_increment
-	* @param string $style
 	* @return string
 	*/
-	function create_sql($table, $auto_increment, $style) {
+	function create_sql(string $table, bool $auto_increment, string $style) {
 		$return = get_val("SHOW CREATE TABLE " . table($table), 1);
 		if (!$auto_increment) {
 			$return = preg_replace('~ AUTO_INCREMENT=\d+~', '', $return); //! skip comments
@@ -1027,26 +990,23 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get SQL command to truncate table
-	* @param string $table
 	* @return string
 	*/
-	function truncate_sql($table) {
+	function truncate_sql(string $table) {
 		return "TRUNCATE " . table($table);
 	}
 
 	/** Get SQL command to change database
-	* @param string $database
 	* @return string
 	*/
-	function use_sql($database) {
+	function use_sql(string $database) {
 		return "USE " . idf_escape($database);
 	}
 
 	/** Get SQL commands to create triggers
-	* @param string $table
 	* @return string
 	*/
-	function trigger_sql($table) {
+	function trigger_sql(string $table) {
 		$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";
@@ -1079,7 +1039,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param Field $field one element from fields()
 	* @return string|void
 	*/
-	function convert_field($field) {
+	function convert_field(array $field) {
 		if (preg_match("~binary~", $field["type"])) {
 			return "HEX(" . idf_escape($field["field"]) . ")";
 		}
@@ -1096,7 +1056,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param string $return SQL expression
 	* @return string
 	*/
-	function unconvert_field($field, $return) {
+	function unconvert_field(array $field, string $return) {
 		if (preg_match("~binary~", $field["type"])) {
 			$return = "UNHEX($return)";
 		}
@@ -1114,7 +1074,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @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($feature) {
+	function support(string $feature) {
 		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);
 	}
 
@@ -1122,7 +1082,7 @@ if (!defined('Adminer\DRIVER')) {
 	* @param numeric-string $val
 	* @return Result|bool
 	*/
-	function kill_process($val) {
+	function kill_process(string $val) {
 		return queries("KILL " . number($val));
 	}
 
@@ -1150,10 +1110,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Get values of user defined type
-	* @param int $id
 	* @return string
 	*/
-	function type_values($id) {
+	function type_values(int $id) {
 		return "";
 	}
 
@@ -1172,11 +1131,9 @@ if (!defined('Adminer\DRIVER')) {
 	}
 
 	/** Set current schema
-	* @param string $schema
-	* @param Db $connection2
 	* @return bool
 	*/
-	function set_schema($schema, $connection2 = null) {
+	function set_schema(string $schema, Db $connection2 = null) {
 		return true;
 	}
 }
diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php
index 54211c27..da72e888 100644
--- a/adminer/drivers/sqlite.inc.php
+++ b/adminer/drivers/sqlite.inc.php
@@ -463,7 +463,7 @@ if (isset($_GET["sqlite"])) {
 	* @param string $add_check CHECK constraint to add
 	* @return bool
 	*/
-	function recreate_table($table, $name, $fields, $originals, $foreign, $auto_increment = 0, $indexes = array(), $drop_check = "", $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 = "") {
 		global $driver;
 		if ($table != "") {
 			if (!$fields) {
diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index d9c1800b..d42d1cd5 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -28,10 +28,9 @@ class Adminer {
 	}
 
 	/** Get key used for permanent login
-	* @param bool $create
 	* @return string cryptic string which gets combined with password or false in case of an error
 	*/
-	function permanentLogin($create = false) {
+	function permanentLogin(bool $create = false) {
 		return password_file($create);
 	}
 
@@ -43,10 +42,9 @@ class Adminer {
 	}
 
 	/** Get server name displayed in breadcrumbs
-	* @param string $server
 	* @return string HTML code or null
 	*/
-	function serverName($server) {
+	function serverName(string $server) {
 		return h($server);
 	}
 
@@ -59,10 +57,9 @@ class Adminer {
 	}
 
 	/** Get cached list of databases
-	* @param bool $flush
 	* @return list
 	*/
-	function databases($flush = true) {
+	function databases(bool $flush = true) {
 		return get_databases($flush);
 	}
 
@@ -97,7 +94,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($dark = null) {
+	function head(bool $dark = null) {
 		// this is matched by compile.php
 		echo "\n";
 		echo ($dark !== false ? "\n" : "");
@@ -137,21 +134,18 @@ class Adminer {
 	}
 
 	/** Get login form field
-	* @param string $name
 	* @param string $heading HTML
 	* @param string $value HTML
 	* @return string
 	*/
-	function loginFormField($name, $heading, $value) {
+	function loginFormField(string $name, string $heading, string $value) {
 		return $heading . $value . "\n";
 	}
 
 	/** Authorize the user
-	* @param string $login
-	* @param string $password
 	* @return mixed true for success, string for error message, false for unknown error
 	*/
-	function login($login, $password) {
+	function login(string $login, string $password) {
 		if ($password == "") {
 			return lang('Adminer does not support accessing a database without a password, more information.', target_blank());
 		}
@@ -162,7 +156,7 @@ class Adminer {
 	* @param TableStatus $tableStatus result of table_status1()
 	* @return string HTML code, "" to ignore table
 	*/
-	function tableName($tableStatus) {
+	function tableName(array $tableStatus) {
 		return h($tableStatus["Name"]);
 	}
 
@@ -171,7 +165,7 @@ class Adminer {
 	* @param int $order order of column in select
 	* @return string HTML code, "" to ignore field
 	*/
-	function fieldName($field, $order = 0) {
+	function fieldName(array $field, int $order = 0) {
 		$type = $field["full_type"];
 		$comment = $field["comment"];
 		return '' . h($field["field"]) . '';
@@ -182,7 +176,7 @@ class Adminer {
 	* @param string $set new item options, NULL for no new item
 	* @return void
 	*/
-	function selectLinks($tableStatus, $set = "") {
+	function selectLinks(array $tableStatus, string $set = "") {
 		global $driver;
 		echo '\n"; // required for IE9 inline edit
 		if (!$failed && ($warnings = $driver->warnings())) {
@@ -259,7 +249,7 @@ class Adminer {
 	* @param string $query query to be executed
 	* @return string escaped query to be printed
 	*/
-	function sqlCommandQuery($query) {
+	function sqlCommandQuery(string $query) {
 		return shorten_utf8(trim($query), 1000);
 	}
 
@@ -270,10 +260,9 @@ class Adminer {
 	}
 
 	/** Description of a row in a table
-	* @param string $table
 	* @return string SQL expression, empty string for no description
 	*/
-	function rowDescription($table) {
+	function rowDescription(string $table) {
 		return "";
 	}
 
@@ -282,7 +271,7 @@ class Adminer {
 	* @param ForeignKey[] $foreignKeys
 	* @return list
 	*/
-	function rowDescriptions($rows, $foreignKeys) {
+	function rowDescriptions(array $rows, array $foreignKeys) {
 		return $rows;
 	}
 
@@ -291,7 +280,7 @@ class Adminer {
 	* @param Field $field single field returned from fields()
 	* @return string|void null to create the default link
 	*/
-	function selectLink($val, $field) {
+	function selectLink(string $val, array $field) {
 	}
 
 	/** Value printed in select table
@@ -301,7 +290,7 @@ class Adminer {
 	* @param string $original original value before applying editVal() and escaping
 	* @return string
 	*/
-	function selectVal($val, $link, $field, $original) {
+	function selectVal(string $val, string $link, array $field, string $original) {
 		$return = ($val === null ? "NULL"
 			: (preg_match("~char|binary|boolean~", $field["type"]) && !preg_match("~var~", $field["type"]) ? "$val"
 			: (preg_match('~json~', $field["type"]) ? "$val"
@@ -314,11 +303,10 @@ class Adminer {
 	}
 
 	/** Value conversion used in select and edit
-	* @param string $val
 	* @param Field $field single field returned from fields()
 	* @return string
 	*/
-	function editVal($val, $field) {
+	function editVal(string $val, array $field) {
 		return $val;
 	}
 
@@ -327,7 +315,7 @@ class Adminer {
 	* @param TableStatus $tableStatus
 	* @return void
 	*/
-	function tableStructurePrint($fields, $tableStatus = null) {
+	function tableStructurePrint(array $fields, array $tableStatus = null) {
 		global $driver;
 		echo "
\n"; echo "\n"; @@ -358,7 +346,7 @@ class Adminer { * @param Index[] $indexes data about all indexes on a table * @return void */ - function tableIndexesPrint($indexes) { + function tableIndexesPrint(array $indexes) { echo "
\n"; foreach ($indexes as $name => $index) { ksort($index["columns"]); // enforce correct columns order @@ -379,7 +367,7 @@ class Adminer { * @param string[] $columns selectable columns * @return void */ - function selectColumnsPrint($select, $columns) { + function selectColumnsPrint(array $select, array $columns) { global $driver; print_fieldset("select", lang('Select'), $select); $i = 0; @@ -407,7 +395,7 @@ class Adminer { * @param Index[] $indexes * @return void */ - function selectSearchPrint($where, $columns, $indexes) { + function selectSearchPrint(array $where, array $columns, array $indexes) { print_fieldset("search", lang('Search'), $where); foreach ($indexes as $i => $index) { if ($index["type"] == "FULLTEXT") { @@ -443,7 +431,7 @@ class Adminer { * @param Index[] $indexes * @return void */ - function selectOrderPrint($order, $columns, $indexes) { + function selectOrderPrint(array $order, array $columns, array $indexes) { print_fieldset("sort", lang('Sort'), $order); $i = 0; foreach ((array) $_GET["order"] as $key => $val) { @@ -462,7 +450,7 @@ class Adminer { * @param string $limit result of selectLimitProcess() * @return void */ - function selectLimitPrint($limit) { + function selectLimitPrint(string $limit) { echo "
" . lang('Limit') . "
"; //
for easy styling echo ""; echo script("qsl('input').oninput = selectFieldChange;", ""); @@ -473,7 +461,7 @@ class Adminer { * @param string $text_length result of selectLengthProcess() * @return void */ - function selectLengthPrint($text_length) { + function selectLengthPrint(string $text_length) { if ($text_length !== null) { echo "
" . lang('Text length') . "
"; echo ""; @@ -485,7 +473,7 @@ class Adminer { * @param Index[] $indexes * @return void */ - function selectActionPrint($indexes) { + function selectActionPrint(array $indexes) { echo "
" . lang('Action') . "
"; echo ""; echo " "; @@ -527,7 +515,7 @@ class Adminer { * @param string[] $columns selectable columns * @return void */ - function selectEmailPrint($emailFields, $columns) { + function selectEmailPrint(array $emailFields, array $columns) { } /** Process columns box in select @@ -535,7 +523,7 @@ class Adminer { * @param Index[] $indexes * @return list> [[select_expressions], [group_expressions]] */ - function selectColumnsProcess($columns, $indexes) { + function selectColumnsProcess(array $columns, array $indexes) { 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 @@ -555,7 +543,7 @@ class Adminer { * @param Index[] $indexes * @return list expressions to join by AND */ - function selectSearchProcess($fields, $indexes) { + function selectSearchProcess(array $fields, array $indexes) { global $connection, $driver; $return = array(); foreach ($indexes as $i => $index) { @@ -609,7 +597,7 @@ class Adminer { * @param Index[] $indexes * @return list expressions to join by comma */ - function selectOrderProcess($fields, $indexes) { + function selectOrderProcess(array $fields, array $indexes) { $return = array(); foreach ((array) $_GET["order"] as $key => $val) { if ($val != "") { @@ -640,7 +628,7 @@ class Adminer { * @param ForeignKey[] $foreignKeys * @return bool true if processed, false to process other parts of form */ - function selectEmailProcess($where, $foreignKeys) { + function selectEmailProcess(array $where, array $foreignKeys) { return false; } @@ -653,17 +641,16 @@ class Adminer { * @param int $page index of page starting at zero * @return string empty string to use default query */ - function selectQueryBuild($select, $where, $group, $order, $limit, $page) { + function selectQueryBuild(array $select, array $where, array $group, array $order, int $limit, int $page) { return ""; } /** Query printed after execution in the message * @param string $query executed query * @param string $time elapsed time - * @param bool $failed * @return string */ - function messageQuery($query, $time, $failed = false) { + function messageQuery(string $query, string $time, bool $failed = false) { global $driver; restart_session(); $history = &get_session("queries"); @@ -689,20 +676,18 @@ class Adminer { } /** Print before edit form - * @param string $table * @param Field[] $fields * @param mixed $row - * @param bool $update * @return void */ - function editRowPrint($table, $fields, $row, $update) { + function editRowPrint(string $table, array $fields, $row, bool $update) { } /** Functions displayed in edit form * @param Field $field single field from fields() * @return list */ - function editFunctions($field) { + function editFunctions(array $field) { global $driver; $return = ($field["null"] ? "NULL/" : ""); $update = isset($_GET["select"]) || where($_GET); @@ -728,10 +713,9 @@ class Adminer { * @param string $table table name * @param Field $field single field from fields() * @param string $attrs attributes to use inside the tag - * @param string $value * @return string custom input field or empty string for default */ - function editInput($table, $field, $attrs, $value) { + function editInput(string $table, array $field, string $attrs, string $value) { if ($field["type"] == "enum") { return (isset($_GET["select"]) ? " " : "") . ($field["null"] ? " " : "") @@ -744,20 +728,17 @@ class Adminer { /** Get hint for edit field * @param string $table table name * @param Field $field single field from fields() - * @param string $value * @return string */ - function editHint($table, $field, $value) { + function editHint(string $table, array $field, string $value) { return ""; } /** Process sent input * @param Field $field single field from fields() - * @param string $value - * @param string $function * @return string expression to use in a query */ - function processInput($field, $value, $function = "") { + function processInput(array $field, string $value, string $function = "") { if ($function == "SQL") { return $value; // SQL injection } @@ -798,19 +779,16 @@ class Adminer { } /** Export database structure - * @param string $db * @return void prints data */ - function dumpDatabase($db) { + function dumpDatabase(string $db) { } /** Export table structure - * @param string $table - * @param string $style * @param int $is_view 0 table, 1 view, 2 temporary view table * @return void prints data */ - function dumpTable($table, $style, $is_view = 0) { + function dumpTable(string $table, string $style, int $is_view = 0) { if ($_POST["format"] != "sql") { echo "\xef\xbb\xbf"; // UTF-8 byte order mark if ($style) { @@ -840,12 +818,9 @@ class Adminer { } /** Export table data - * @param string $table - * @param string $style - * @param string $query * @return void prints data */ - function dumpData($table, $style, $query) { + function dumpData(string $table, string $style, string $query) { global $connection; if ($style) { $max_packet = (JUSH == "sqlite" ? 0 : 1048576); // default, minimum is 1024 @@ -934,19 +909,16 @@ class Adminer { } /** Set export filename - * @param string $identifier * @return string filename without extension */ - function dumpFilename($identifier) { + function dumpFilename(string $identifier) { return friendly_url($identifier != "" ? $identifier : (SERVER != "" ? SERVER : "localhost")); } /** Send headers for export - * @param string $identifier - * @param bool $multi_table * @return string extension */ - function dumpHeaders($identifier, $multi_table = false) { + function dumpHeaders(string $identifier, bool $multi_table = false) { $output = $_POST["output"]; $ext = (preg_match('~sql~', $_POST["format"]) ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR header("Content-Type: " . @@ -994,7 +966,7 @@ class Adminer { * @param string $missing can be "auth" if there is no database connection, "db" if there is no database selected, "ns" with invalid schema * @return void */ - function navigation($missing) { + function navigation(string $missing) { global $VERSION, $drivers, $connection; echo "

" . $this->name() . " $VERSION"; $new_version = $_COOKIE["adminer_version"]; @@ -1055,7 +1027,7 @@ class Adminer { * @param TableStatus[] $tables result of table_status('', true) * @return void */ - function syntaxHighlighting($tables) { + function syntaxHighlighting(array $tables) { global $connection; // this is matched by compile.php echo script_src("../externals/jush/modules/jush.js"); @@ -1083,10 +1055,9 @@ class Adminer { } /** Print databases list in menu - * @param string $missing * @return void */ - function databasesPrint($missing) { + function databasesPrint(string $missing) { global $adminer, $connection; $databases = $this->databases(); if (DB && $databases && !in_array(DB, $databases)) { @@ -1121,7 +1092,7 @@ class Adminer { * @param TableStatus[] $tables result of table_status('', true) * @return void */ - function tablesPrint($tables) { + function tablesPrint(array $tables) { echo "
    " . script("mixin(qs('#tables'), {onmouseover: menuOver, onmouseout: menuOut});"); foreach ($tables as $table => $status) { $name = $this->tableName($status); diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index b2e670d9..dab95da1 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -131,7 +131,7 @@ function unset_permanent() { * @param string $error plain text * @return never */ -function auth_error($error) { +function auth_error(string $error) { global $adminer, $has_token; $session_name = session_name(); if (isset($_GET["username"])) { diff --git a/adminer/include/db.inc.php b/adminer/include/db.inc.php index becd34e8..5e3c6177 100644 --- a/adminer/include/db.inc.php +++ b/adminer/include/db.inc.php @@ -14,37 +14,29 @@ abstract class SqlDb { /** @var Result|bool */ protected $multi; // used for multiquery /** Connect to server - * @param string $server - * @param string $username - * @param string $password * @return bool */ - abstract function connect($server, $username, $password); + abstract function connect(string $server, string $username, string $password); /** Quote string to use in SQL - * @param string $string * @return string escaped string enclosed in ' */ - abstract function quote($string); + abstract function quote(string $string); /** Select database - * @param string $database * @return bool */ - abstract function select_db($database); + abstract function select_db(string $database); /** Send query - * @param string $query - * @param bool $unbuffered * @return Result|bool */ - abstract function query($query, $unbuffered = false); + abstract function query(string $query, bool $unbuffered = false); /** Send query with more resultsets - * @param string $query * @return Result|bool */ - function multi_query($query) { + function multi_query(string $query) { return $this->multi = $this->query($query); } @@ -63,11 +55,9 @@ abstract class SqlDb { } /** Get single field from result - * @param string $query - * @param int $field * @return string|bool */ - function result($query, $field = 0) { + function result(string $query, int $field = 0) { $result = $this->query($query); if (!is_object($result)) { return false; diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 50ebc0bf..07f9766c 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -3,12 +3,11 @@ namespace Adminer; /** Print HTML header * @param string $title used in title, breadcrumb and heading, should be HTML escaped -* @param string $error * @param mixed $breadcrumb ["key" => "link", "key2" => ["link", "desc"]], null for nothing, false for driver only, true for driver and server * @param string $title2 used after colon in title and heading, should be HTML escaped * @return void */ -function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { +function page_header(string $title, string $error = "", $breadcrumb = array(), string $title2 = "") { global $LANG, $VERSION, $adminer, $drivers; page_headers(); if (is_ajax() && $error) { @@ -176,10 +175,9 @@ function get_nonce() { } /** Print flash and error messages -* @param string $error * @return void */ -function page_messages($error) { +function page_messages(string $error) { global $adminer; $uri = preg_replace('~^[^?]*~', '', $_SERVER["REQUEST_URI"]); $messages = idx($_SESSION["messages"], $uri); @@ -199,7 +197,7 @@ function page_messages($error) { * @param string $missing "auth", "db", "ns" * @return void */ -function page_footer($missing = "") { +function page_footer(string $missing = "") { global $adminer; echo "

\n\n