From d3b53d9d9cc74fb2e3cbc644755d2c41a38724a1 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 26 Mar 2025 21:06:01 +0100 Subject: [PATCH] PHPStan: Fix level 6 errors --- adminer/call.inc.php | 5 ++++ adminer/drivers/mysql.inc.php | 41 ++++++++++++++++--------------- adminer/include/adminer.inc.php | 8 +++--- adminer/include/auth.inc.php | 3 +++ adminer/include/coverage.inc.php | 1 + adminer/include/driver.inc.php | 26 ++++++++++---------- adminer/include/functions.inc.php | 16 ++++++++---- adminer/include/html.inc.php | 2 +- adminer/include/lang.inc.php | 1 + adminer/include/plugins.inc.php | 17 ++++++++++++- adminer/include/tmpfile.inc.php | 9 +++++-- adminer/include/xxtea.inc.php | 21 ++++++++++++++++ compile.php | 2 +- phpstan.neon | 13 ++++++---- 14 files changed, 114 insertions(+), 51 deletions(-) diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 236ae3b4..e43241de 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -91,9 +91,14 @@ if ($in) {
 ', preg_replace('~\|~', '', preg_replace('~\|$~m', "", rtrim($s))));
 }
+
 $table = '(\+--[-+]+\+\n)';
 $row = '(\| .* \|\n)';
 echo preg_replace_callback(
diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php
index 313cf7bd..d8e55807 100644
--- a/adminer/drivers/mysql.inc.php
+++ b/adminer/drivers/mysql.inc.php
@@ -61,16 +61,16 @@ 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 {
-			public
-				$extension = "MySQL", ///< @var string extension name
-				$flavor = '', ///< @var string different vendor with the same API, e.g. MariaDB, usually stays empty
-				$server_info, ///< @var string server version
-				$affected_rows, ///< @var int number of affected rows
-				$info, ///< @var string see https://php.net/mysql_info
-				$errno, ///< @var int last error code
-				$error ///< @var string last error message
-			;
-			private $link, $result;
+			/** @var string */ public $extension = "MySQL"; // 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
+
+			/** @var \mysqli */ private $link;
+			/** @var Result */ private $result;
 
 			/** Connect to server
 			* @param string
@@ -132,7 +132,7 @@ if (!defined('Adminer\DRIVER')) {
 			/** Send query
 			* @param string
 			* @param bool
-			* @return mixed bool or Result
+			* @return Result|bool
 			*/
 			function query($query, $unbuffered = false) {
 				$result = @($unbuffered ? mysql_unbuffered_query($query, $this->link) : mysql_query($query, $this->link)); // @ - mute mysql.trace_mode
@@ -152,7 +152,7 @@ if (!defined('Adminer\DRIVER')) {
 
 			/** Send query with more resultsets
 			* @param string
-			* @return bool
+			* @return Result|bool
 			*/
 			function multi_query($query) {
 				return $this->result = $this->query($query);
@@ -185,8 +185,9 @@ if (!defined('Adminer\DRIVER')) {
 		}
 
 		class Result {
-			public $num_rows; ///< @var int number of rows in the result
-			private $result, $offset = 0;
+			/** @var int */ public $num_rows; // number of rows in the result
+			/** @var resource */ private $result;
+			/** @var int */ private $offset = 0;
 
 			/** Constructor
 			* @param resource
@@ -286,13 +287,13 @@ if (!defined('Adminer\DRIVER')) {
 
 
 	class Driver extends SqlDriver {
-		static $possibleDrivers = array("MySQLi", "MySQL", "PDO_MySQL");
-		static $jush = "sql"; ///< @var string JUSH identifier
+		/** @var list */ static $possibleDrivers = array("MySQLi", "MySQL", "PDO_MySQL");
+		/** @var string */ static $jush = "sql"; // JUSH identifier
 
-		public $unsigned = array("unsigned", "zerofill", "unsigned zerofill");
-		public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL");
-		public $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper");
-		public $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
+		/** @var list */ public $unsigned = array("unsigned", "zerofill", "unsigned zerofill");
+		/** @var list */ public $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "REGEXP", "IN", "FIND_IN_SET", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL", "SQL");
+		/** @var list */ public $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper");
+		/** @var list */ public $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
 
 		function __construct($connection) {
 			parent::__construct($connection);
diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index 869533e7..e91d8b22 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -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 operators used in select, null for all operators
-	public $error = ''; ///< @var string @visibility protected(set) string HTML
+	/** @var list */ 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