mirror of
https://github.com/vrana/adminer.git
synced 2025-08-21 21:55:43 +02:00
PHPStan: Fix level 4 errors
This commit is contained in:
@@ -444,7 +444,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
|
||||
/** Connect to the database
|
||||
* @param array{string, string, string} [$server, $username, $password]
|
||||
* @return mixed Db or string for error
|
||||
* @return string|Db string for error
|
||||
*/
|
||||
function connect($credentials) {
|
||||
global $drivers;
|
||||
@@ -1073,47 +1073,12 @@ if (!defined('Adminer\DRIVER')) {
|
||||
/** Get approximate number of rows
|
||||
* @param TableStatus
|
||||
* @param list<string>
|
||||
* @return numeric-string|void null if approximate number can't be retrieved
|
||||
* @return numeric-string|null null if approximate number can't be retrieved
|
||||
*/
|
||||
function found_rows($table_status, $where) {
|
||||
return ($where || $table_status["Engine"] != "InnoDB" ? null : $table_status["Rows"]);
|
||||
}
|
||||
|
||||
/* Not used is MySQL but checked in compile.php:
|
||||
/** Get user defined types
|
||||
* @return string[] [$id => $name]
|
||||
function types() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/** Get values of user defined type
|
||||
* @param int
|
||||
* @return string
|
||||
function type_values($id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/** Get existing schemas
|
||||
* @return list<string>
|
||||
function schemas() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/** Get current schema
|
||||
* @return string
|
||||
function get_schema() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/** Set current schema
|
||||
* @param string
|
||||
* @param Db
|
||||
* @return bool
|
||||
function set_schema($schema, $connection2 = null) {
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
/** Get SQL command to create table
|
||||
* @param string
|
||||
* @param bool
|
||||
@@ -1241,4 +1206,44 @@ if (!defined('Adminer\DRIVER')) {
|
||||
function max_connections() {
|
||||
return get_val("SELECT @@max_connections");
|
||||
}
|
||||
|
||||
// Not used is MySQL but checked in compile.php:
|
||||
|
||||
/** Get user defined types
|
||||
* @return string[] [$id => $name]
|
||||
*/
|
||||
function types() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/** Get values of user defined type
|
||||
* @param int
|
||||
* @return string
|
||||
*/
|
||||
function type_values($id) {
|
||||
return "";
|
||||
}
|
||||
|
||||
/** Get existing schemas
|
||||
* @return list<string>
|
||||
*/
|
||||
function schemas() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/** Get current schema
|
||||
* @return string
|
||||
*/
|
||||
function get_schema() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/** Set current schema
|
||||
* @param string
|
||||
* @param Db
|
||||
* @return bool
|
||||
*/
|
||||
function set_schema($schema, $connection2 = null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -854,7 +854,7 @@ AND typelem = 0"
|
||||
}
|
||||
$fields = fields($table);
|
||||
|
||||
if (!$status || empty($fields)) {
|
||||
if (count($status) < 2 || empty($fields)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -61,6 +61,7 @@ function check_invalid_login() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/** @var array{int, int} */
|
||||
$invalid = idx($invalids, $adminer->bruteForceKey(), array());
|
||||
$next_attempt = ($invalid[1] > 29 ? $invalid[0] - time() : 0); // allow 30 invalid attempts
|
||||
if ($next_attempt > 0) { //! do the same with permanent login
|
||||
|
@@ -124,7 +124,7 @@ function referencable_primary($self) {
|
||||
|
||||
/** Print SQL <textarea> tag
|
||||
* @param string
|
||||
* @param string or array in which case [0] of every element is used
|
||||
* @param string|list<array{string}>
|
||||
* @param int
|
||||
* @param int
|
||||
* @return void
|
||||
|
@@ -174,7 +174,7 @@ function sid() {
|
||||
* @param string
|
||||
* @param string
|
||||
* @param string
|
||||
* @param string
|
||||
* @param ?string
|
||||
* @return void
|
||||
*/
|
||||
function set_password($vendor, $server, $username, $password) {
|
||||
@@ -185,7 +185,7 @@ function set_password($vendor, $server, $username, $password) {
|
||||
}
|
||||
|
||||
/** Get password from session
|
||||
* @return string or null for missing password or false for expired password
|
||||
* @return string|false|null null for missing password, false for expired password
|
||||
*/
|
||||
function get_password() {
|
||||
$return = get_session("pwds");
|
||||
@@ -549,7 +549,7 @@ class Queries {
|
||||
|
||||
/** Execute and remember query
|
||||
* @param string end with ';' to use DELIMITER
|
||||
* @return Result
|
||||
* @return Result|bool
|
||||
*/
|
||||
function queries($query) {
|
||||
global $connection;
|
||||
@@ -902,7 +902,7 @@ function rand_string() {
|
||||
}
|
||||
|
||||
/** Format value to use in select
|
||||
* @param string
|
||||
* @param string|string[]
|
||||
* @param string
|
||||
* @param Field
|
||||
* @param int
|
||||
@@ -945,7 +945,7 @@ function select_value($val, $link, $field, $text_length) {
|
||||
}
|
||||
|
||||
/** Check whether the string is e-mail address
|
||||
* @param string
|
||||
* @param ?string
|
||||
* @return bool
|
||||
*/
|
||||
function is_mail($email) {
|
||||
|
@@ -337,6 +337,7 @@ if (!$columns && support("table")) {
|
||||
$rank = 1;
|
||||
foreach ($rows[0] as $key => $val) {
|
||||
if (!isset($unselected[$key])) {
|
||||
/** @var array{fun?:string, col?:string} */
|
||||
$val = idx($_GET["columns"], key($select)) ?: array();
|
||||
$field = $fields[$select ? ($val ? $val["col"] : current($select)) : $key];
|
||||
$name = ($field ? $adminer->fieldName($field, $rank) : ($val["fun"] ? "*" : h($key)));
|
||||
|
Reference in New Issue
Block a user