1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 14:46:36 +02:00

Doc-comments: Declare type properties

This commit is contained in:
Jakub Vrana
2025-03-28 09:20:10 +01:00
parent 5e88dae4e2
commit ab4208dcb8
9 changed files with 39 additions and 40 deletions

View File

@@ -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 {
/** @var resource */ private $link;
private resource $link;
function connect($server, $username, $password) {
if (ini_bool("mysql.allow_local_infile")) {
@@ -121,9 +121,9 @@ if (!defined('Adminer\DRIVER')) {
}
class Result {
/** @var int */ public $num_rows; // number of rows in the result
/** @var resource */ private $result;
/** @var int */ private $offset = 0;
public int $num_rows; // number of rows in the result
private resource $result;
private int $offset = 0;
function __construct(resource $result) {
$this->result = $result;
@@ -211,13 +211,13 @@ if (!defined('Adminer\DRIVER')) {
class Driver extends SqlDriver {
/** @var list<string> */ static $possibleDrivers = array("MySQLi", "MySQL", "PDO_MySQL");
/** @var string */ static $jush = "sql"; // JUSH identifier
/** @var list<string> */ static array $possibleDrivers = array("MySQLi", "MySQL", "PDO_MySQL");
static string $jush = "sql"; // JUSH identifier
/** @var list<string> */ public $unsigned = array("unsigned", "zerofill", "unsigned zerofill");
/** @var list<string> */ public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL");
/** @var list<string> */ public $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper");
/** @var list<string> */ public $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
/** @var list<string> */ public array $unsigned = array("unsigned", "zerofill", "unsigned zerofill");
/** @var list<string> */ public array $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL");
/** @var list<string> */ public array $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper");
/** @var list<string> */ public array $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
function __construct($connection) {
parent::__construct($connection);

View File

@@ -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 {
/** @var list<string> */ public $operators; // operators used in select, null for all operators
/** @var string @visibility protected(set) */ public $error = ''; // HTML
/** @var list<string> */ public array $operators; // operators used in select, null for all operators
/** @visibility protected(set) */ public string $error = ''; // HTML
/** Name in title and navigation
* @return string HTML code

View File

@@ -4,13 +4,13 @@ namespace Adminer;
// this could be interface when "Db extends \mysqli" can have compatible type declarations (PHP 7)
// interfaces can include properties only since PHP 8.4
abstract class SqlDb {
/** @var string */ public $extension; // extension name
/** @var string */ public $flavor; // different vendor with the same API, e.g. MariaDB; usually stays empty
/** @var string */ public $server_info; // server version
/** @var int */ public $affected_rows; // number of affected rows
/** @var string */ public $info; // see https://php.net/mysql_info
/** @var int */ public $errno; // last error code
/** @var string */ public $error; // last error message
public string $extension; // extension name
public string $flavor; // different vendor with the same API, e.g. MariaDB; usually stays empty
public string $server_info; // server version
public int $affected_rows; // number of affected rows
public string $info; // see https://php.net/mysql_info
public int $errno; // last error code
public string $error; // last error message
/** @var Result|bool */ protected $multi; // used for multiquery
/** Connect to server */

View File

@@ -16,20 +16,20 @@ function get_driver(string $id): string {
}
abstract class SqlDriver {
/** @var list<string> */ static $possibleDrivers = array();
/** @var string */ static $jush; // JUSH identifier
/** @var list<string> */ static array $possibleDrivers = array();
static string $jush; // JUSH identifier
/** @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
protected Db $conn;
/** @var int[][] */ protected array $types = array(); // [$group => [$type => $maximum_unsigned_length, ...], ...]
/** @var array{0?:string[], 1?:string[]} */ public array $editFunctions = array(); // of ["$type|$type2" => "$function/$function2"] functions used in editing, [0] - edit and insert, [1] - edit only
/** @var list<string> */ public array $unsigned = array(); // number variants
/** @var list<string> */ public array $operators = array(); // operators used in select
/** @var list<string> */ public array $functions = array(); // functions used in select
/** @var list<string> */ public array $grouping = array(); // grouping functions used in select
public string $onActions = "RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT"; // used in foreign_keys()
public string $inout = "IN|OUT|INOUT"; // used in routines
public string $enumLength = "'(?:''|[^'\\\\]|\\\\.)*'"; // regular expression for parsing enum lengths
/** @var list<string> */ public array $generated = array(); // allowed types of generated columns
/** Create object for performing database operations */
function __construct(Db $connection) {

View File

@@ -455,8 +455,8 @@ function query_redirect(string $query, string $location, string $message, bool $
}
class Queries {
/** @var string[] */ static $queries = array();
/** @var float */ static $start;
/** @var string[] */ static array $queries = array();
static float $start;
}
/** Execute and remember query

View File

@@ -4,7 +4,7 @@ namespace Adminer;
// PDO can be used in several database drivers
if (extension_loaded('pdo')) {
abstract class PdoDb extends SqlDb {
/** @var \PDO */ protected $pdo;
protected \PDO $pdo;
/** Connect to server using DSN
* @param mixed[] $options

View File

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

View File

@@ -2,8 +2,8 @@
namespace Adminer;
class TmpFile {
/** @var resource */ private $handler;
/** @var int @visibility protected(set) */ public $size;
private resource $handler;
/** @visibility protected(set) */ public int $size;
function __construct() {
$this->handler = tmpfile();

View File

@@ -9,8 +9,7 @@ if (isset($_GET["mongo"])) {
if (class_exists('MongoDB\Driver\Manager')) {
class Db extends SqlDb {
public $extension = "MongoDB", $server_info = MONGODB_VERSION, $last_id;
/** @var \MongoDB\Driver\Manager */
public $_link;
public \MongoDB\Driver\Manager $_link;
public $_db, $_db_name;
function connect($uri, $options) {