1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-12 09:34:10 +02:00

Doc-comments: Fix type errors

This commit is contained in:
Jakub Vrana
2025-03-28 10:25:11 +01:00
parent 54f8d731b3
commit b948f77af4
16 changed files with 97 additions and 89 deletions

View File

@@ -13,7 +13,7 @@ if (isset($_GET["mssql"])) {
define('Adminer\DRIVER', "mssql");
if (extension_loaded("sqlsrv") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
public $extension = "sqlsrv";
public string $extension = "sqlsrv";
private $link, $result;
private function get_error() {
@@ -124,7 +124,7 @@ if (isset($_GET["mssql"])) {
return $this->convert(sqlsrv_fetch_array($this->result, SQLSRV_FETCH_NUMERIC));
}
function fetch_field(): object {
function fetch_field(): \stdClass {
if (!$this->fields) {
$this->fields = sqlsrv_field_metadata($this->result);
}
@@ -180,7 +180,7 @@ if (isset($_GET["mssql"])) {
if (extension_loaded("pdo_sqlsrv")) {
class Db extends MssqlDb {
public $extension = "PDO_SQLSRV";
public string $extension = "PDO_SQLSRV";
function connect(string $server, string $username, string $password): bool {
$this->dsn("sqlsrv:Server=" . str_replace(":", ",", $server), $username, $password);
@@ -190,7 +190,7 @@ if (isset($_GET["mssql"])) {
} elseif (extension_loaded("pdo_dblib")) {
class Db extends MssqlDb {
public $extension = "PDO_DBLIB";
public string $extension = "PDO_DBLIB";
function connect(string $server, string $username, string $password): bool {
$this->dsn("dblib:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\d)~', ';port=\1', $server)), $username, $password);
@@ -202,10 +202,10 @@ if (isset($_GET["mssql"])) {
class Driver extends SqlDriver {
static $possibleDrivers = array("SQLSRV", "PDO_SQLSRV", "PDO_DBLIB");
static $jush = "mssql";
static array $possibleDrivers = array("SQLSRV", "PDO_SQLSRV", "PDO_DBLIB");
static string $jush = "mssql";
public $editFunctions = array(
public array $editFunctions = array(
array(
"date|time" => "getdate",
), array(
@@ -214,11 +214,11 @@ if (isset($_GET["mssql"])) {
)
);
public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL");
public $functions = array("len", "lower", "round", "upper");
public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
public $onActions = "NO ACTION|CASCADE|SET NULL|SET DEFAULT";
public $generated = array("PERSISTED", "VIRTUAL");
public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL");
public array $functions = array("len", "lower", "round", "upper");
public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
public array $generated = array("PERSISTED", "VIRTUAL");
public string $onActions = "NO ACTION|CASCADE|SET NULL|SET DEFAULT";
function __construct(Db $connection) {
parent::__construct($connection);

View File

@@ -8,7 +8,7 @@ if (!defined('Adminer\DRIVER')) {
// MySQLi supports everything, MySQL doesn't support multiple result sets, PDO_MySQL doesn't support orgtable
if (extension_loaded("mysqli") && $_GET["ext"] != "pdo") {
class Db extends \MySQLi {
public $extension = "MySQLi", $flavor = '';
public string $extension = "MySQLi", $flavor = '';
function __construct() {
parent::init();
@@ -61,7 +61,7 @@ if (!defined('Adminer\DRIVER')) {
} elseif (extension_loaded("mysql") && !((ini_bool("sql.safe_mode") || ini_bool("mysql.allow_local_infile")) && extension_loaded("pdo_mysql"))) {
class Db extends SqlDb {
private resource $link;
/** @var resource */ private $link;
function connect(string $server, string $username, string $password): bool {
if (ini_bool("mysql.allow_local_infile")) {
@@ -122,10 +122,11 @@ if (!defined('Adminer\DRIVER')) {
class Result {
public int $num_rows; // number of rows in the result
private resource $result;
/** @var resource */ private $result;
private int $offset = 0;
function __construct(resource $result) {
/** @param resource $result */
function __construct($result) {
$this->result = $result;
$this->num_rows = mysql_num_rows($result);
}
@@ -145,9 +146,9 @@ if (!defined('Adminer\DRIVER')) {
}
/** Fetch next field
* @return object properties: name, type (0 number, 15 varchar, 254 char), charsetnr (63 binary); optionally: table, orgtable, orgname
* @return \stdClass properties: name, type (0 number, 15 varchar, 254 char), charsetnr (63 binary); optionally: table, orgtable, orgname
*/
function fetch_field(): object {
function fetch_field(): \stdClass {
$return = mysql_fetch_field($this->result, $this->offset++); // offset required under certain conditions
$return->orgtable = $return->table;
$return->charsetnr = ($return->blob ? 63 : 0);
@@ -162,7 +163,7 @@ if (!defined('Adminer\DRIVER')) {
} elseif (extension_loaded("pdo_mysql")) {
class Db extends PdoDb {
public $extension = "PDO_MySQL";
public string $extension = "PDO_MySQL";
function connect(string $server, string $username, string $password): bool {
global $adminer;

View File

@@ -7,7 +7,7 @@ if (isset($_GET["oracle"])) {
define('Adminer\DRIVER', "oracle");
if (extension_loaded("oci8") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
public $extension = "oci8";
public string $extension = "oci8";
public $_current_db;
private $link;
@@ -87,7 +87,7 @@ if (isset($_GET["oracle"])) {
return $this->convert(oci_fetch_row($this->result));
}
function fetch_field(): object {
function fetch_field(): \stdClass {
$column = $this->offset++;
$return = new \stdClass;
$return->name = oci_field_name($this->result, $column);
@@ -103,7 +103,7 @@ if (isset($_GET["oracle"])) {
} elseif (extension_loaded("pdo_oci")) {
class Db extends PdoDb {
public $extension = "PDO_OCI";
public string $extension = "PDO_OCI";
public $_current_db;
function connect(string $server, string $username, string $password): bool {
@@ -122,10 +122,10 @@ if (isset($_GET["oracle"])) {
class Driver extends SqlDriver {
static $possibleDrivers = array("OCI8", "PDO_OCI");
static $jush = "oracle";
static array $possibleDrivers = array("OCI8", "PDO_OCI");
static string $jush = "oracle";
public $editFunctions = array(
public array $editFunctions = array(
array( //! no parentheses
"date" => "current_date",
"timestamp" => "current_timestamp",
@@ -136,9 +136,9 @@ if (isset($_GET["oracle"])) {
)
);
public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
public $functions = array("length", "lower", "round", "upper");
public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
public array $functions = array("length", "lower", "round", "upper");
public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
function __construct(Db $connection) {
parent::__construct($connection);

View File

@@ -7,7 +7,8 @@ if (isset($_GET["pgsql"])) {
define('Adminer\DRIVER', "pgsql");
if (extension_loaded("pgsql") && $_GET["ext"] != "pdo") {
class Db extends SqlDb {
public $extension = "PgSQL", $timeout;
public string $extension = "PgSQL";
public int $timeout;
private $link, $string, $database = true;
function _error($errno, $error) {
@@ -108,7 +109,7 @@ if (isset($_GET["pgsql"])) {
return pg_fetch_row($this->result);
}
function fetch_field(): object {
function fetch_field(): \stdClass {
$column = $this->offset++;
$return = new \stdClass;
$return->orgtable = pg_field_table($this->result, $column);
@@ -125,7 +126,8 @@ if (isset($_GET["pgsql"])) {
} elseif (extension_loaded("pdo_pgsql")) {
class Db extends PdoDb {
public $extension = "PDO_PgSQL", $timeout;
public string $extension = "PDO_PgSQL";
public int $timeout;
function connect(string $server, string $username, string $password): bool {
global $adminer;
@@ -167,12 +169,12 @@ if (isset($_GET["pgsql"])) {
class Driver extends SqlDriver {
static $possibleDrivers = array("PgSQL", "PDO_PgSQL");
static $jush = "pgsql";
static array $possibleDrivers = array("PgSQL", "PDO_PgSQL");
static string $jush = "pgsql";
public $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"); // no "SQL" to avoid CSRF
public $functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper");
public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
public array $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"); // no "SQL" to avoid CSRF
public array $functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper");
public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
function __construct(Db $connection) {
parent::__construct($connection);

View File

@@ -8,7 +8,7 @@ if (isset($_GET["sqlite"])) {
if (class_exists("SQLite3") && $_GET["ext"] != "pdo") {
abstract class SqliteDb extends SqlDb {
public $extension = "SQLite3";
public string $extension = "SQLite3";
private $link;
function connect(string $filename, string $username = '', string $password = ''): bool {
@@ -56,7 +56,7 @@ if (isset($_GET["sqlite"])) {
return $this->result->fetchArray(SQLITE3_NUM);
}
function fetch_field(): object {
function fetch_field(): \stdClass {
$column = $this->offset++;
$type = $this->result->columnType($column);
return (object) array(
@@ -73,7 +73,7 @@ if (isset($_GET["sqlite"])) {
} elseif (extension_loaded("pdo_sqlite")) {
abstract class SqliteDb extends PdoDb {
public $extension = "PDO_SQLite";
public string $extension = "PDO_SQLite";
function connect(string $filename, string $username = '', string $password = ''): bool {
$this->dsn(DRIVER . ":$filename", "", "");
@@ -106,12 +106,12 @@ if (isset($_GET["sqlite"])) {
class Driver extends SqlDriver {
static $possibleDrivers = array("SQLite3", "PDO_SQLite");
static $jush = "sqlite";
static array $possibleDrivers = array("SQLite3", "PDO_SQLite");
static string $jush = "sqlite";
protected $types = array(array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0));
protected array $types = array(array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0));
public $editFunctions = array(
public array $editFunctions = array(
array(
// "text" => "date('now')/time('now')/datetime('now')",
), array(
@@ -121,9 +121,9 @@ if (isset($_GET["sqlite"])) {
)
);
public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"); // REGEXP can be user defined function
public $functions = array("hex", "length", "lower", "round", "unixepoch", "upper");
public $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL"); // REGEXP can be user defined function
public array $functions = array("hex", "length", "lower", "round", "unixepoch", "upper");
public array $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
function __construct(Db $connection) {
parent::__construct($connection);