Fix code style

This commit is contained in:
Jakub Vrana
2025-09-07 11:21:05 +02:00
parent b41699624b
commit 26319460ef
9 changed files with 28 additions and 16 deletions

View File

@@ -164,8 +164,8 @@ if (adminer()->homepage()) {
echo "<input type='hidden' name='all' value=''>"; // 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 "</div></div>\n";
}

View File

@@ -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<string, TableStatus>
*/
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<array{string, list<string>, 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
*/

View File

@@ -452,7 +452,7 @@ if (isset($_GET["sqlite"])) {
* @param list<list<string>> $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<array{string, string, list<string>|'DROP'}> $indexes [[$type, $name, $columns]], empty to preserve
* @param string $drop_check CHECK constraint to drop
* @param string $add_check CHECK constraint to add

View File

@@ -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<list<array{field:string, null:bool, type:string, length:?numeric-string, primary?:numeric-string}>>
* @return array<list<array{field:string, null:bool, type:string, length:?numeric-string}>> optionally also 'primary'
*/
function allFields(): array {
$return = array();

View File

@@ -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<numeric-string, bool> */
$lefts = array();
$all_fields = driver()->allFields();
foreach (table_status('', true) as $table => $table_status) {
if (is_view($table_status)) {

View File

@@ -26,7 +26,10 @@ if ($fields) {
adminer()->tableStructurePrint($fields, $table_status);
}
function tables_links($tables) {
/** Print links to tables
* @param list<string> $tables
*/
function tables_links(array $tables): void {
echo "<ul>\n";
foreach ($tables as $table) {
echo "<li><a href='" . h(ME . "table=" . urlencode($table)) . "'>" . h($table) . "</a>";

View File

@@ -116,7 +116,6 @@
<rule ref="Squiz.PHP.NonExecutableCode"/>
<rule ref="Squiz.Scope.StaticThisUsage"/>
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"/>

View File

@@ -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<string>, lengths:list<numeric-string>, descs:list<?bool>, algorithm?:string, partial?:string}"

View File

@@ -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);