1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-11 00:54:08 +02:00

PHPStan: Fix more errors

This commit is contained in:
Jakub Vrana
2025-03-27 18:27:51 +01:00
parent e2deed9a02
commit b23bf6c055
11 changed files with 54 additions and 43 deletions

View File

@@ -783,17 +783,18 @@ if (!defined('Adminer\DRIVER')) {
/** Run commands to alter indexes
* @param string escaped table name
* @param array{string, string, 'DROP'|list<string>} of ["index type", "name", ["column definition", ...]] or ["index type", "name", "DROP"]
* @param list<array{string, string, 'DROP'|list<string>}> of ["index type", "name", ["column definition", ...]] or ["index type", "name", "DROP"]
* @return Result|bool
*/
function alter_indexes($table, $alter) {
foreach ($alter as $key => $val) {
$alter[$key] = ($val[2] == "DROP"
$changes = array();
foreach ($alter as $val) {
$changes[] = ($val[2] == "DROP"
? "\nDROP INDEX " . idf_escape($val[1])
: "\nADD $val[0] " . ($val[0] == "PRIMARY" ? "KEY " : "") . ($val[1] != "" ? idf_escape($val[1]) . " " : "") . "(" . implode(", ", $val[2]) . ")"
);
}
return queries("ALTER TABLE " . table($table) . implode(",", $alter));
return queries("ALTER TABLE " . table($table) . implode(",", $changes));
}
/** Run commands to truncate tables
@@ -925,7 +926,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get information about stored routine
* @param string
* @param string "FUNCTION" or "PROCEDURE"
* @param 'FUNCTION'|'PROCEDURE'
* @return Routine
*/
function routine($name, $type) {

View File

@@ -844,7 +844,7 @@ AND typelem = 0"
foreach ($fields as $field) {
$part = idf_escape($field['field']) . ' ' . $field['full_type']
. default_value($field)
. ($field['attnotnull'] ? " NOT NULL" : "");
. ($field['null'] ? "" : " NOT NULL");
$return_parts[] = $part;
// sequences for fields

View File

@@ -521,23 +521,24 @@ if (isset($_GET["sqlite"])) {
}
queries("BEGIN");
}
foreach ($fields as $key => $field) {
$changes = array();
foreach ($fields as $field) {
if (preg_match('~GENERATED~', $field[3])) {
unset($originals[array_search($field[0], $originals)]);
}
$fields[$key] = " " . implode($field);
$changes[] = " " . implode($field);
}
$fields = array_merge($fields, array_filter($foreign));
$changes = array_merge($changes, array_filter($foreign));
foreach ($driver->checkConstraints($table) as $check) {
if ($check != $drop_check) {
$fields[] = " CHECK ($check)";
$changes[] = " CHECK ($check)";
}
}
if ($add_check) {
$fields[] = " CHECK ($add_check)";
$changes[] = " CHECK ($add_check)";
}
$temp_name = ($table == $name ? "adminer_$name" : $name);
if (!queries("CREATE TABLE " . table($temp_name) . " (\n" . implode(",\n", $fields) . "\n)")) {
if (!queries("CREATE TABLE " . table($temp_name) . " (\n" . implode(",\n", $changes) . "\n)")) {
// implicit ROLLBACK to not overwrite $connection->error
return false;
}