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

PHPStan: Fix level 5 errors

This commit is contained in:
Jakub Vrana
2025-03-26 19:29:50 +01:00
parent c78299a3f6
commit c96894ecd4
9 changed files with 34 additions and 26 deletions

View File

@@ -159,7 +159,7 @@ function select_input($attrs, $options, $value = "", $onchange = "", $placeholde
/** Print one row in JSON object
* @param string or "" to close the object
* @param string
* @param string|int
* @return void
*/
function json_row($key, $val = null) {
@@ -318,7 +318,7 @@ function type_class($type) {
/** Print table interior for fields editing
* @param Field[]
* @param list<string>[]
* @param list<string>
* @param string TABLE or PROCEDURE
* @param Field[] returned by referencable_primary()
* @return void
@@ -423,11 +423,12 @@ function process_fields(&$fields) {
}
/** Callback used in routine()
* @param list<array>
* @param list<string>
* @return string
*/
function normalize_enum($match) {
return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($match[0][0] . $match[0][0], $match[0][0], substr($match[0], 1, -1))), '\\')) . "'";
$val = $match[0];
return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($val[0] . $val[0], $val[0], substr($val, 1, -1))), '\\')) . "'";
}
/** Issue grant or revoke commands

View File

@@ -124,8 +124,8 @@ function bracket_escape($idf, $back = false) {
}
/** Check if connection has at least the given version
* @param string required version
* @param string required MariaDB version
* @param string|float required version
* @param string|float required MariaDB version
* @param Db defaults to $connection
* @return bool
*/
@@ -311,7 +311,7 @@ function where($where, $fields = array()) {
global $connection;
$return = array();
foreach ((array) $where["where"] as $key => $val) {
$key = bracket_escape($key, 1); // 1 - back
$key = bracket_escape($key, true); // true - back
$column = escape_key($key);
$field = idx($fields, $key, array());
$field_type = $field["type"];
@@ -694,7 +694,7 @@ function shorten_utf8($string, $length = 80, $suffix = "") {
}
/** Format decimal number
* @param int
* @param float|numeric-string
* @return string
*/
function format_number($val) {
@@ -749,7 +749,7 @@ function fields_from_edit() { // used by Mongo and SimpleDB
}
}
foreach ((array) $_POST["fields"] as $key => $val) {
$name = bracket_escape($key, 1); // 1 - back
$name = bracket_escape($key, true); // true - back
$return[$name] = array(
"field" => $name,
"privileges" => array("insert" => 1, "update" => 1, "where" => 1, "order" => 1),
@@ -898,7 +898,7 @@ function password_file($create) {
* @return string 32 hexadecimal characters
*/
function rand_string() {
return md5(uniqid(mt_rand(), true));
return md5(uniqid(strval(mt_rand()), true));
}
/** Format value to use in select

View File

@@ -27,7 +27,7 @@ function nonce() {
/** Get <input type="hidden">
* @param string
* @param string
* @param string|int
* @return string HTML
*/
function input_hidden($name, $value = "") {
@@ -68,7 +68,7 @@ function nl_br($string) {
/** Generate HTML checkbox
* @param string
* @param string
* @param string|int
* @param bool
* @param string
* @param string

View File

@@ -61,7 +61,7 @@ function get_lang() {
/** Translate string
* @param literal-string
* @param int
* @param float|string
* @return string
*/
// this is matched by compile.php

View File

@@ -5,7 +5,7 @@ class Plugins extends Adminer {
public $plugins; ///< @var list<object> @visibility protected(set)
/** Register plugins
* @param list<object> object instances or null to autoload plugins from adminer-plugins/
* @param ?list<object> object instances or null to autoload plugins from adminer-plugins/
*/
function __construct($plugins) {
if ($plugins === null) {