]> git.joonet.de Git - adminer.git/commitdiff
Doc-comments: Declare type properties
authorJakub Vrana <jakub@vrana.cz>
Fri, 28 Mar 2025 08:20:10 +0000 (09:20 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 28 Mar 2025 11:45:02 +0000 (12:45 +0100)
adminer/drivers/mysql.inc.php
adminer/include/adminer.inc.php
adminer/include/db.inc.php
adminer/include/driver.inc.php
adminer/include/functions.inc.php
adminer/include/pdo.inc.php
adminer/include/plugins.inc.php
adminer/include/tmpfile.inc.php
plugins/drivers/mongo.php

index 8198d7f29906bd38157b10884b6a9c6097baa175..6f268874981242fd93744792952bb2684327be6f 100644 (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);
index 8d9b6a4285be58c038f6dc70b4ffa4a12c7b4a74..3aa970bad3924e7124bfb48860ffd8d435360256 100644 (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
index 656cc69c2ffb3856530881555d9b8cdc3f335681..3e0165647cd1f4c820330777aac8205a9ab919cc 100644 (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 */
index 392c501aae480eba3c477a67bb3ac907bdbf6f6b..b8036a65c2ac95b1ce869b9bf2cdf219dae7cf6a 100644 (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 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
+       /** @var list<string> */ static array $possibleDrivers = array();
+       static string $jush; // JUSH identifier
+
+       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) {
index f2504ee0bf7fbf6f60b5db575c840e893cabddf1..5266fcebfe90ee89f79a441b37d3e9ff0abbe2b7 100644 (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
index f37aa31a7a9f80bd86fb8df199255c27c0c1e54e..0b7be4ecd56df420d20eb13a7969e75a2552fe41 100644 (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
index 517931f2fc5184c9d364be1d25ddebdd424a5e3e..cb80175c19824a331e127f452ed17d654a228f98 100644 (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/
index 992e8dcb91c2d0177e44ee88349299e009c968e5..02a0101ddf1f5767ad2aa0dffedc7ea9b4746d64 100644 (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();
index d4b56afa64e297f4293bd6fb395438bb629f2241..5aa6c27e191b78b0270dfa3272af8610ed72aec8 100644 (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) {