1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-07 23:27:17 +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"))) { } elseif (extension_loaded("mysql") && !((ini_bool("sql.safe_mode") || ini_bool("mysql.allow_local_infile")) && extension_loaded("pdo_mysql"))) {
class Db extends SqlDb { class Db extends SqlDb {
/** @var resource */ private $link; private resource $link;
function connect($server, $username, $password) { function connect($server, $username, $password) {
if (ini_bool("mysql.allow_local_infile")) { if (ini_bool("mysql.allow_local_infile")) {
@@ -121,9 +121,9 @@ if (!defined('Adminer\DRIVER')) {
} }
class Result { class Result {
/** @var int */ public $num_rows; // number of rows in the result public int $num_rows; // number of rows in the result
/** @var resource */ private $result; private resource $result;
/** @var int */ private $offset = 0; private int $offset = 0;
function __construct(resource $result) { function __construct(resource $result) {
$this->result = $result; $this->result = $result;
@@ -211,13 +211,13 @@ if (!defined('Adminer\DRIVER')) {
class Driver extends SqlDriver { class Driver extends SqlDriver {
/** @var list<string> */ static $possibleDrivers = array("MySQLi", "MySQL", "PDO_MySQL"); /** @var list<string> */ static array $possibleDrivers = array("MySQLi", "MySQL", "PDO_MySQL");
/** @var string */ static $jush = "sql"; // JUSH identifier static string $jush = "sql"; // JUSH identifier
/** @var list<string> */ public $unsigned = array("unsigned", "zerofill", "unsigned zerofill"); /** @var list<string> */ public array $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 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 $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper"); /** @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 $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum"); /** @var list<string> */ public array $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
function __construct($connection) { function __construct($connection) {
parent::__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 // any method change in this file should be transferred to editor/include/adminer.inc.php and plugins.inc.php
class Adminer { class Adminer {
/** @var list<string> */ public $operators; // operators used in select, null for all operators /** @var list<string> */ public array $operators; // operators used in select, null for all operators
/** @var string @visibility protected(set) */ public $error = ''; // HTML /** @visibility protected(set) */ public string $error = ''; // HTML
/** Name in title and navigation /** Name in title and navigation
* @return string HTML code * @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) // this could be interface when "Db extends \mysqli" can have compatible type declarations (PHP 7)
// interfaces can include properties only since PHP 8.4 // interfaces can include properties only since PHP 8.4
abstract class SqlDb { abstract class SqlDb {
/** @var string */ public $extension; // extension name public string $extension; // extension name
/** @var string */ public $flavor; // different vendor with the same API, e.g. MariaDB; usually stays empty public string $flavor; // different vendor with the same API, e.g. MariaDB; usually stays empty
/** @var string */ public $server_info; // server version public string $server_info; // server version
/** @var int */ public $affected_rows; // number of affected rows public int $affected_rows; // number of affected rows
/** @var string */ public $info; // see https://php.net/mysql_info public string $info; // see https://php.net/mysql_info
/** @var int */ public $errno; // last error code public int $errno; // last error code
/** @var string */ public $error; // last error message public string $error; // last error message
/** @var Result|bool */ protected $multi; // used for multiquery /** @var Result|bool */ protected $multi; // used for multiquery
/** Connect to server */ /** Connect to server */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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