From 26319460ef091d6d155b0244af2bebbbcd8231aa Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sun, 7 Sep 2025 11:21:05 +0200 Subject: [PATCH] Fix code style --- adminer/db.inc.php | 4 ++-- adminer/drivers/mysql.inc.php | 6 +++--- adminer/drivers/sqlite.inc.php | 2 +- adminer/include/driver.inc.php | 2 +- adminer/schema.inc.php | 3 ++- adminer/table.inc.php | 5 ++++- phpcs.xml | 1 - phpstan.neon | 9 ++++++--- plugins/timeout.php | 12 +++++++++--- 9 files changed, 28 insertions(+), 16 deletions(-) diff --git a/adminer/db.inc.php b/adminer/db.inc.php index 8336a26b..0807fae2 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -164,8 +164,8 @@ if (adminer()->homepage()) { echo ""; // used by trCheck() echo script("qsl('input').onclick = function () { selectCount('selected', formChecked(this, /^(tables|views)\[/));" . (support("table") ? " selectCount('selected2', formChecked(this, /^tables\[/) || $tables);" : "") - . "$script }" - ); + . "$script }") + ; echo input_token(); echo "\n"; } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index a626b91b..d21b5956 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -32,7 +32,7 @@ if (!defined('Adminer\DRIVER')) { (is_numeric($port) ? null : $port), ($ssl ? ($ssl['verify'] !== false ? 2048 : 64) : 0) // 2048 - MYSQLI_CLIENT_SSL, 64 - MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT (not available before PHP 5.6.16) ); - $this->options(MYSQLI_OPT_LOCAL_INFILE, false); + $this->options(MYSQLI_OPT_LOCAL_INFILE, 0); return ($return ? '' : $this->error); } @@ -457,7 +457,7 @@ if (!defined('Adminer\DRIVER')) { /** Get table status * @param bool $fast return only "Name", "Engine" and "Comment" fields - * @return TableStatus[] + * @return array */ function table_status(string $name = "", bool $fast = false): array { $return = array(); @@ -695,7 +695,7 @@ if (!defined('Adminer\DRIVER')) { * @param string $name new name * @param list, string}> $fields of [$orig, $process_field, $after] * @param string[] $foreign - * @param numeric-string $auto_increment + * @param numeric-string|'' $auto_increment * @param ?Partitions $partitioning null means remove partitioning * @return Result|bool */ diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index dd7c06ad..0b9123f8 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -452,7 +452,7 @@ if (isset($_GET["sqlite"])) { * @param list> $fields [process_field()], empty to preserve * @param string[] $originals [$original => idf_escape($new_column)], empty to preserve * @param string[] $foreign [format_foreign_key()], empty to preserve - * @param numeric-string $auto_increment set auto_increment to this value, "" to preserve + * @param numeric-string|'' $auto_increment set auto_increment to this value, "" to preserve * @param list|'DROP'}> $indexes [[$type, $name, $columns]], empty to preserve * @param string $drop_check CHECK constraint to drop * @param string $add_check CHECK constraint to add diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php index cf13df13..e2b9d873 100644 --- a/adminer/include/driver.inc.php +++ b/adminer/include/driver.inc.php @@ -275,7 +275,7 @@ AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'", $this->conn); // ignore default IS N } /** Get all fields in the current schema - * @return array> + * @return array> optionally also 'primary' */ function allFields(): array { $return = array(); diff --git a/adminer/schema.inc.php b/adminer/schema.inc.php index f14616a2..0eed7aea 100644 --- a/adminer/schema.inc.php +++ b/adminer/schema.inc.php @@ -18,7 +18,8 @@ $base_left = -1; /** @var array{fields:Field[], pos:array{float, float}, references:string[][][]}[] */ $schema = array(); // table => array("fields" => array(name => field), "pos" => array(top, left), "references" => array(table => array(left => array(source, target)))) $referenced = array(); // target_table => array(table => array(left => target_column)) -$lefts = array(); // float => bool +/** @var array */ +$lefts = array(); $all_fields = driver()->allFields(); foreach (table_status('', true) as $table => $table_status) { if (is_view($table_status)) { diff --git a/adminer/table.inc.php b/adminer/table.inc.php index a50eb4a0..b8a98a9f 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -26,7 +26,10 @@ if ($fields) { adminer()->tableStructurePrint($fields, $table_status); } -function tables_links($tables) { +/** Print links to tables +* @param list $tables +*/ +function tables_links(array $tables): void { echo "
    \n"; foreach ($tables as $table) { echo "
  • " . h($table) . ""; diff --git a/phpcs.xml b/phpcs.xml index 56b2e183..0f23738e 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -116,7 +116,6 @@ - diff --git a/phpstan.neon b/phpstan.neon index 516bc5b2..86385335 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -17,7 +17,8 @@ parameters: - "~^Constant LANG not found~" # defined in lang.inc.php - "~ an undefined \\w+ Adminer\\\\Db::~" # defined in that versions of Db - "~^Call to an undefined method Adminer\\\\Result::seek~" # defined in MS SQL - - "~^Call to an undefined method Adminer\\\\Driver::setUserTypes~" # defined in PostgreSQL + - "~^Call to an undefined method Adminer\\\\Driver::(setUserTypes|tableOid)~" # defined in PostgreSQL + - "~^Access to an undefined property Adminer\\\\Driver::\\$nsOid~" # defined in PostgreSQL - "~expects int, float given~" # this will work - "~expects bool~" # truthy values - "~fread expects int<1, max>, 100000~" # 1e6 @@ -39,11 +40,13 @@ parameters: - identifier: booleanAnd.leftAlwaysTrue - identifier: booleanAnd.rightAlwaysTrue - identifier: booleanAnd.rightAlwaysFalse + - identifier: booleanOr.rightAlwaysTrue - identifier: ternary.alwaysTrue - identifier: if.alwaysTrue - - identifier: while.alwaysTrue - identifier: isset.offset - identifier: deadCode.unreachable + - "~Function Adminer\\\\get_driver\\(\\) never returns null~" + - "~on array\\{}~" paths: - adminer/drivers/mysql.inc.php # other drivers inherit the annotations so we take them from here @@ -62,7 +65,7 @@ parameters: typeAliases: TableStatus: "array{Name:string, Engine?:?string, Comment?:string, Oid?:numeric-string, Rows?:?numeric-string, Collation?:string, Auto_increment?:?numeric-string, Data_length?:numeric-string, Index_length?:numeric-string, Data_free?:numeric-string, Create_options?:string, partition?:numeric-string, nspname?:string}" - Field: "array{field?:string, full_type:string, type:string, length:numeric-string, unsigned:string, default?:string, null:bool, auto_increment:bool, collation:string, privileges:int[], comment:string, primary:bool, generated:string, orig?:string, on_update?:string, on_delete?:string, default_constraint?: string}" + Field: "array{field?:string, full_type:string, type:string, length:?numeric-string, unsigned:string, default?:string, null:bool, auto_increment:bool, collation:string, privileges:int[], comment:string, primary:bool, generated:string, orig?:string, on_update?:string, on_delete?:string, default_constraint?: string}" FieldType: "array{type:string, length:numeric-string, unsigned:string, collation:string}" # subset of RoutineField and Field RoutineField: "array{field:string, type:string, length:numeric-string, unsigned:string, null:bool, full_type:string, collation:string, inout?:string}" Index: "array{type:string, columns:list, lengths:list, descs:list, algorithm?:string, partial?:string}" diff --git a/plugins/timeout.php b/plugins/timeout.php index de5eb0d6..59a05024 100644 --- a/plugins/timeout.php +++ b/plugins/timeout.php @@ -22,9 +22,15 @@ class AdminerTimeout extends Adminer\Plugin { $ms = $seconds * 1000; $conn = Adminer\connection(); switch (Adminer\JUSH) { - case 'sql': $conn->query("SET max_execution_time = $ms"); break; - case 'pgsql': $conn->query("SET statement_timeout = $ms"); break; - case 'mssql': $conn->query("SET LOCK_TIMEOUT $ms"); break; + case 'sql': + $conn->query("SET max_execution_time = $ms"); + break; + case 'pgsql': + $conn->query("SET statement_timeout = $ms"); + break; + case 'mssql': + $conn->query("SET LOCK_TIMEOUT $ms"); + break; default: if (method_exists(connection(), 'timeout')) { $conn->timeout($ms);