1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-15 19:13:59 +02:00

PHPStan: Fix more errors

This commit is contained in:
Jakub Vrana
2025-03-27 18:27:51 +01:00
parent e2deed9a02
commit b23bf6c055
11 changed files with 54 additions and 43 deletions

View File

@@ -52,7 +52,7 @@ if ($_SERVER["HTTP_X_FORWARDED_PREFIX"]) {
}
$HTTPS = ($_SERVER["HTTPS"] && strcasecmp($_SERVER["HTTPS"], "off")) || ini_bool("session.cookie_secure"); // session.cookie_secure could be set on HTTP if we are behind a reverse proxy
@ini_set("session.use_trans_sid", false); // protect links in export, @ - may be disabled
@ini_set("session.use_trans_sid", '0'); // protect links in export, @ - may be disabled
if (!defined("SID")) {
session_cache_limiter(""); // to allow restarting session
session_name("adminer_sid"); // use specific session name to get own namespace
@@ -66,7 +66,7 @@ if (function_exists("get_magic_quotes_runtime") && get_magic_quotes_runtime()) {
set_magic_quotes_runtime(false);
}
@set_time_limit(0); // @ - can be disabled
@ini_set("precision", 15); // @ - can be disabled, 15 - internal PHP precision
@ini_set("precision", '15'); // @ - can be disabled, 15 - internal PHP precision
include "../adminer/include/lang.inc.php";
include "../adminer/lang/$LANG.inc.php";

View File

@@ -102,7 +102,7 @@ function select($result, $connection2 = null, $orgtables = array(), $limit = 0)
/** Get referencable tables with single column primary key except self
* @param string
* @return Field[] [$table_name => $field]
* @return array<string, Field> [$table_name => $field]
*/
function referencable_primary($self) {
$return = array(); // table_name => field
@@ -180,7 +180,7 @@ function json_row($key, $val = null) {
* @param string
* @param Field
* @param list<string>
* @param Field[] returned by referencable_primary()
* @param string[]
* @param list<string> extra types to prepend
* @return void
*/
@@ -246,7 +246,7 @@ function process_length($length) {
}
/** Create SQL string from field type
* @param Field
* @param FieldType
* @param string
* @return string
*/
@@ -317,10 +317,10 @@ function type_class($type) {
}
/** Print table interior for fields editing
* @param Field[]
* @param (Field|RoutineField)[]
* @param list<string>
* @param string TABLE or PROCEDURE
* @param Field[] returned by referencable_primary()
* @param 'TABLE'|'PROCEDURE'
* @param string[]
* @return void
*/
function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = array()) {
@@ -502,7 +502,7 @@ function create_trigger($on, $row) {
}
/** Generate SQL query for creating routine
* @param string "PROCEDURE" or "FUNCTION"
* @param 'PROCEDURE'|'FUNCTION'
* @param Routine result of routine()
* @return string
*/

View File

@@ -354,7 +354,7 @@ function where_link($i, $column, $value, $operator = "=") {
}
/** Get select clause for convertible fields
* @param string[]
* @param mixed[] only keys are used
* @param Field[]
* @param list<string>
* @return string
@@ -436,7 +436,7 @@ function stop_session($force = false) {
$use_cookies = ini_bool("session.use_cookies");
if (!$use_cookies || $force) {
session_write_close(); // improves concurrency if a user opens several pages at once, may be restarted later
if ($use_cookies && @ini_set("session.use_cookies", false) === false) { // @ - may be disabled
if ($use_cookies && @ini_set("session.use_cookies", '0') === false) { // @ - may be disabled
session_start();
}
}
@@ -999,9 +999,12 @@ function slow_query($query) {
$timeout = $adminer->queryTimeout();
$slow_query = $driver->slowQuery($query, $timeout);
$connection2 = null;
if (!$slow_query && support("kill") && is_object($connection2 = connect($adminer->credentials())) && ($db == "" || $connection2->select_db($db))) {
$kill = $connection2->result(connection_id()); // MySQL and MySQLi can use thread_id but it's not in PDO_MySQL
echo script("const timeout = setTimeout(() => { ajax('" . js_escape(ME) . "script=kill', function () {}, 'kill=$kill&token=$token'); }, 1000 * $timeout);");
if (!$slow_query && support("kill")) {
$connection2 = connect($adminer->credentials());
if (is_object($connection2) && ($db == "" || $connection2->select_db($db))) {
$kill = $connection2->result(connection_id()); // MySQL and MySQLi can use thread_id but it's not in PDO_MySQL
echo script("const timeout = setTimeout(() => { ajax('" . js_escape(ME) . "script=kill', function () {}, 'kill=$kill&token=$token'); }, 1000 * $timeout);");
}
}
ob_flush();
flush();

View File

@@ -247,7 +247,7 @@ function enum_input($type, $attrs, $field, $value, $empty = null) {
}
/** Print edit input field
* @param Field one field from fields()
* @param Field|RoutineField one field from fields()
* @param mixed
* @param string
* @param bool
@@ -343,7 +343,7 @@ function input($field, $value, $function, $autofocus = false) {
}
/** Process edit input field
* @param Field one field from fields()
* @param Field|RoutineField one field from fields()
* @return mixed false to leave the original value
*/
function process_input($field) {

View File

@@ -59,11 +59,13 @@ if (extension_loaded('pdo')) {
}
function next_result() {
if (!is_object($this->multi)) {
/** @var PdoResult|bool */
$result = $this->multi;
if (!is_object($result)) {
return false;
}
$this->multi->_offset = 0;
return @$this->multi->nextRowset(); // @ - PDO_PgSQL doesn't support it
$result->_offset = 0;
return @$result->nextRowset(); // @ - PDO_PgSQL doesn't support it
}
}