mirror of
https://github.com/vrana/adminer.git
synced 2025-08-16 03:24:01 +02:00
PHPStan: Fix level 6 errors
This commit is contained in:
@@ -4,8 +4,8 @@ namespace Adminer;
|
||||
// any method change in this file should be transferred to editor/include/adminer.inc.php and plugins.inc.php
|
||||
|
||||
class Adminer {
|
||||
public $operators; ///< @var list<string> operators used in select, null for all operators
|
||||
public $error = ''; ///< @var string @visibility protected(set) string HTML
|
||||
/** @var list<string> */ public $operators; // operators used in select, null for all operators
|
||||
/** @var string @visibility protected(set) */ public $error = ''; // HTML
|
||||
|
||||
/** Name in title and navigation
|
||||
* @return string HTML code
|
||||
@@ -264,6 +264,7 @@ class Adminer {
|
||||
}
|
||||
|
||||
/** Print HTML code just before the Execute button in SQL command
|
||||
* @return void
|
||||
*/
|
||||
function sqlPrintAfter() {
|
||||
}
|
||||
@@ -689,7 +690,7 @@ class Adminer {
|
||||
|
||||
/** Print before edit form
|
||||
* @param string
|
||||
* @param array[]
|
||||
* @param Field[]
|
||||
* @param mixed
|
||||
* @param bool
|
||||
* @return void
|
||||
@@ -1052,6 +1053,7 @@ class Adminer {
|
||||
|
||||
/** Set up syntax highlight for code and <textarea>
|
||||
* @param TableStatus[] result of table_status('', true)
|
||||
* @return void
|
||||
*/
|
||||
function syntaxHighlighting($tables) {
|
||||
global $connection;
|
||||
|
@@ -17,6 +17,7 @@ if ($_COOKIE["adminer_permanent"]) {
|
||||
}
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
function add_invalid_login() {
|
||||
global $adminer;
|
||||
$base = get_temp_dir() . "/adminer.invalid";
|
||||
@@ -50,6 +51,7 @@ function add_invalid_login() {
|
||||
file_write_unlock($fp, serialize($invalids));
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
function check_invalid_login() {
|
||||
global $adminer;
|
||||
$invalids = array();
|
||||
@@ -113,6 +115,7 @@ if ($auth) {
|
||||
}
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
function unset_permanent() {
|
||||
global $permanent;
|
||||
foreach ($permanent as $key => $val) {
|
||||
|
@@ -3,6 +3,7 @@ namespace Adminer;
|
||||
|
||||
// coverage is used in tests and removed in compilation
|
||||
if (extension_loaded("xdebug") && file_exists(sys_get_temp_dir() . "/adminer.coverage")) {
|
||||
/** @return void */
|
||||
function save_coverage() {
|
||||
$coverage_filename = sys_get_temp_dir() . "/adminer.coverage";
|
||||
$coverage = unserialize(file_get_contents($coverage_filename));
|
||||
|
@@ -23,20 +23,20 @@ function get_driver($id) {
|
||||
}
|
||||
|
||||
abstract class SqlDriver {
|
||||
static $possibleDrivers = array(); ///< @var list<string>
|
||||
static $jush; ///< @var string JUSH identifier
|
||||
/** @var list<string> */ static $possibleDrivers = array();
|
||||
/** @var string */ static $jush; // JUSH identifier
|
||||
|
||||
protected $conn; ///< @var Db
|
||||
protected $types = array(); ///< @var int[][] [$group => [$type => $maximum_unsigned_length, ...], ...]
|
||||
public $editFunctions = array(); ///< @var array of ["$type|$type2" => "$function/$function2"] functions used in editing, [0] - edit and insert, [1] - edit only
|
||||
public $unsigned = array(); ///< @var list<string> number variants
|
||||
public $operators = array(); ///< @var list<string> operators used in select
|
||||
public $functions = array(); ///< @var list<string> functions used in select
|
||||
public $grouping = array(); ///< @var list<string> grouping functions used in select
|
||||
public $onActions = "RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT"; ///< @var string used in foreign_keys()
|
||||
public $inout = "IN|OUT|INOUT"; ///< @var string used in routines
|
||||
public $enumLength = "'(?:''|[^'\\\\]|\\\\.)*'"; ///< @var string regular expression for parsing enum lengths
|
||||
public $generated = array(); ///< @var list<string> allowed types of generated columns
|
||||
/** @var Db */ protected $conn;
|
||||
/** @var int[][] */ protected $types = array(); // [$group => [$type => $maximum_unsigned_length, ...], ...]
|
||||
/** @var array{0?:string[], 1?:string[]} */ public $editFunctions = array(); // of ["$type|$type2" => "$function/$function2"] functions used in editing, [0] - edit and insert, [1] - edit only
|
||||
/** @var list<string> */ public $unsigned = array(); // number variants
|
||||
/** @var list<string> */ public $operators = array(); // operators used in select
|
||||
/** @var list<string> */ public $functions = array(); // functions used in select
|
||||
/** @var list<string> */ public $grouping = array(); // grouping functions used in select
|
||||
/** @var string */ public $onActions = "RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT"; // used in foreign_keys()
|
||||
/** @var string */ public $inout = "IN|OUT|INOUT"; // used in routines
|
||||
/** @var string */ public $enumLength = "'(?:''|[^'\\\\]|\\\\.)*'"; // regular expression for parsing enum lengths
|
||||
/** @var list<string> */ public $generated = array(); // allowed types of generated columns
|
||||
|
||||
/** Create object for performing database operations
|
||||
* @param Db
|
||||
|
@@ -67,7 +67,7 @@ function escape_string($val) {
|
||||
|
||||
/** Get a possibly missing item from a possibly missing array
|
||||
* idx($row, $key) is better than $row[$key] ?? null because PHP will report error for undefined $row
|
||||
* @param ?array
|
||||
* @param ?mixed[]
|
||||
* @param string|int
|
||||
* @param mixed
|
||||
* @return mixed
|
||||
@@ -543,8 +543,8 @@ function query_redirect($query, $location, $message, $redirect = true, $execute
|
||||
}
|
||||
|
||||
class Queries {
|
||||
static $queries = array();
|
||||
static $start;
|
||||
/** @var string[] */ static $queries = array();
|
||||
/** @var float */ static $start;
|
||||
}
|
||||
|
||||
/** Execute and remember query
|
||||
@@ -846,6 +846,7 @@ function file_open_lock($filename) {
|
||||
/** Write and unlock a file
|
||||
* @param resource
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function file_write_unlock($fp, $data) {
|
||||
rewind($fp);
|
||||
@@ -856,6 +857,7 @@ function file_write_unlock($fp, $data) {
|
||||
|
||||
/** Unlock and close a file
|
||||
* @param resource
|
||||
* @return void
|
||||
*/
|
||||
function file_unlock($fp) {
|
||||
flock($fp, LOCK_UN);
|
||||
@@ -863,8 +865,8 @@ function file_unlock($fp) {
|
||||
}
|
||||
|
||||
/** Get first element of an array
|
||||
* @param array
|
||||
* @return mixed or false if not found
|
||||
* @param mixed[]
|
||||
* @return mixed if not found
|
||||
*/
|
||||
function first($array) {
|
||||
// reset(f()) triggers a notice
|
||||
@@ -1029,6 +1031,10 @@ function verify_token() {
|
||||
}
|
||||
|
||||
// used in compiled version
|
||||
/**
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function lzw_decompress($binary) {
|
||||
// convert binary string to codes
|
||||
$dictionary_count = 256;
|
||||
|
@@ -197,7 +197,7 @@ function pagination($page, $current) {
|
||||
}
|
||||
|
||||
/** Print hidden fields
|
||||
* @param array
|
||||
* @param mixed[]
|
||||
* @param list<string>
|
||||
* @param string
|
||||
* @return bool
|
||||
|
@@ -92,6 +92,7 @@ function lang($idf, $number = null) {
|
||||
return vsprintf($format, $args);
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
function switch_lang() {
|
||||
global $LANG, $langs;
|
||||
echo "<form action='' method='post'>\n<div id='lang'>";
|
||||
|
@@ -2,7 +2,7 @@
|
||||
namespace Adminer;
|
||||
|
||||
class Plugins extends Adminer {
|
||||
public $plugins; ///< @var list<object> @visibility protected(set)
|
||||
/** @var list<object> @visibility protected(set) */ public $plugins;
|
||||
|
||||
/** Register plugins
|
||||
* @param ?list<object> object instances or null to autoload plugins from adminer-plugins/
|
||||
@@ -42,10 +42,20 @@ class Plugins extends Adminer {
|
||||
$this->plugins = $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param literal-string
|
||||
* @param mixed[]
|
||||
* @return mixed
|
||||
*/
|
||||
private function callParent($function, $args) {
|
||||
return call_user_func_array(array('parent', $function), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param literal-string
|
||||
* @param mixed[]
|
||||
* @return mixed
|
||||
*/
|
||||
private function applyPlugin($function, $params) {
|
||||
$args = array();
|
||||
foreach ($params as $key => $val) {
|
||||
@@ -63,6 +73,11 @@ class Plugins extends Adminer {
|
||||
return $this->callParent($function, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param literal-string
|
||||
* @param mixed[]
|
||||
* @return mixed
|
||||
*/
|
||||
private function appendPlugin($function, $args) {
|
||||
$return = $this->callParent($function, $args);
|
||||
foreach ($this->plugins as $plugin) {
|
||||
|
@@ -2,18 +2,23 @@
|
||||
namespace Adminer;
|
||||
|
||||
class TmpFile {
|
||||
private $handler;
|
||||
public $size; ///< @visibility protected(set)
|
||||
/** @var resource */ private $handler;
|
||||
/** @var int @visibility protected(set) */ public $size;
|
||||
|
||||
function __construct() {
|
||||
$this->handler = tmpfile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function write($contents) {
|
||||
$this->size += strlen($contents);
|
||||
fwrite($this->handler, $contents);
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
function send() {
|
||||
fseek($this->handler, 0);
|
||||
fpassthru($this->handler);
|
||||
|
@@ -6,6 +6,10 @@ namespace Adminer;
|
||||
* @link http://www.coolcode.cn/?action=show&id=128
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param int
|
||||
* @return int
|
||||
*/
|
||||
function int32($n) {
|
||||
while ($n >= 2147483648) {
|
||||
$n -= 4294967296;
|
||||
@@ -16,6 +20,11 @@ function int32($n) {
|
||||
return (int) $n;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[]
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
function long2str($v, $w) {
|
||||
$s = '';
|
||||
foreach ($v as $val) {
|
||||
@@ -27,6 +36,11 @@ function long2str($v, $w) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @param bool
|
||||
* @return int[]
|
||||
*/
|
||||
function str2long($s, $w) {
|
||||
$v = array_values(unpack('V*', str_pad($s, 4 * ceil(strlen($s) / 4), "\0")));
|
||||
if ($w) {
|
||||
@@ -35,6 +49,13 @@ function str2long($s, $w) {
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int
|
||||
* @param int
|
||||
* @param int
|
||||
* @param int
|
||||
* @return int
|
||||
*/
|
||||
function xxtea_mx($z, $y, $sum, $k) {
|
||||
return int32((($z >> 5 & 0x7FFFFFF) ^ $y << 2) + (($y >> 3 & 0x1FFFFFFF) ^ $z << 4)) ^ int32(($sum ^ $y) + ($k ^ $z));
|
||||
}
|
||||
|
Reference in New Issue
Block a user