mirror of
https://github.com/vrana/adminer.git
synced 2025-08-06 06:37:33 +02:00
PHPStan: Fix level 1 errors
This commit is contained in:
@@ -19,6 +19,7 @@ foreach ($routine["fields"] as $i => $field) {
|
||||
if (!$error && $_POST) {
|
||||
$call = array();
|
||||
foreach ($routine["fields"] as $key => $field) {
|
||||
$val = "";
|
||||
if (in_array($key, $in)) {
|
||||
$val = process_input($field);
|
||||
if ($val === false) {
|
||||
|
@@ -316,7 +316,7 @@ if (isset($_GET["mssql"])) {
|
||||
return $connection->error;
|
||||
}
|
||||
|
||||
function get_databases() {
|
||||
function get_databases($flush) {
|
||||
return get_vals("SELECT name FROM sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')");
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row
|
||||
return apply_queries("ALTER SCHEMA " . idf_escape($target) . " TRANSFER", array_merge($tables, $views));
|
||||
}
|
||||
|
||||
function trigger($name) {
|
||||
function trigger($name, $table) {
|
||||
if ($name == "") {
|
||||
return array();
|
||||
}
|
||||
@@ -707,7 +707,7 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)) as $row
|
||||
function trigger_sql($table) {
|
||||
$return = "";
|
||||
foreach (triggers($table) as $name => $trigger) {
|
||||
$return .= create_trigger(" ON " . table($table), trigger($name)) . ";";
|
||||
$return .= create_trigger(" ON " . table($table), trigger($name, $table)) . ";";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
@@ -961,10 +961,11 @@ if (!defined('Adminer\DRIVER')) {
|
||||
|
||||
/** Get information about trigger
|
||||
* @param string trigger name
|
||||
* @param string
|
||||
* @return Trigger
|
||||
* @phpstan-type Trigger array{Trigger:string, Timing:string, Event:string, Of:string, Type:string, Statement:string}
|
||||
*/
|
||||
function trigger($name) {
|
||||
function trigger($name, $table) {
|
||||
if ($name == "") {
|
||||
return array();
|
||||
}
|
||||
|
@@ -221,7 +221,7 @@ if (isset($_GET["oracle"])) {
|
||||
return $connection->error;
|
||||
}
|
||||
|
||||
function get_databases() {
|
||||
function get_databases($flush) {
|
||||
return get_vals(
|
||||
"SELECT DISTINCT tablespace_name FROM (
|
||||
SELECT tablespace_name FROM user_tablespaces
|
||||
|
@@ -338,7 +338,7 @@ if (isset($_GET["pgsql"])) {
|
||||
return $connection->error;
|
||||
}
|
||||
|
||||
function get_databases() {
|
||||
function get_databases($flush) {
|
||||
return get_vals("SELECT datname FROM pg_database
|
||||
WHERE datallowconn = TRUE AND has_database_privilege(datname, 'CONNECT')
|
||||
ORDER BY datname");
|
||||
|
@@ -200,7 +200,7 @@ if (isset($_GET["sqlite"])) {
|
||||
return new Db;
|
||||
}
|
||||
|
||||
function get_databases() {
|
||||
function get_databases($flush) {
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -567,7 +567,7 @@ if (isset($_GET["sqlite"])) {
|
||||
}
|
||||
$triggers = array();
|
||||
foreach (triggers($table) as $trigger_name => $timing_event) {
|
||||
$trigger = trigger($trigger_name);
|
||||
$trigger = trigger($trigger_name, $table);
|
||||
$triggers[] = "CREATE TRIGGER " . idf_escape($trigger_name) . " " . implode(" ", $timing_event) . " ON " . table($name) . "\n$trigger[Statement]";
|
||||
}
|
||||
$auto_increment = $auto_increment ? 0 : get_val("SELECT seq FROM sqlite_sequence WHERE name = " . q($table)); // if $auto_increment is set then it will be updated later
|
||||
@@ -633,7 +633,7 @@ if (isset($_GET["sqlite"])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function trigger($name) {
|
||||
function trigger($name, $table) {
|
||||
if ($name == "") {
|
||||
return array("Statement" => "BEGIN\n\t;\nEND");
|
||||
}
|
||||
|
@@ -93,6 +93,7 @@ SET foreign_key_checks = 0;
|
||||
$table = (DB == "" || in_array($name, (array) $_POST["tables"]));
|
||||
$data = (DB == "" || in_array($name, (array) $_POST["data"]));
|
||||
if ($table || $data) {
|
||||
$tmp_file = null;
|
||||
if ($ext == "tar") {
|
||||
$tmp_file = new TmpFile;
|
||||
ob_start(array($tmp_file, 'write'), 1e5);
|
||||
|
@@ -1050,8 +1050,10 @@ function lzw_decompress($binary) {
|
||||
}
|
||||
}
|
||||
// decompression
|
||||
/** @var list<?string> */
|
||||
$dictionary = range("\0", "\xFF");
|
||||
$return = "";
|
||||
$word = "";
|
||||
foreach ($codes as $i => $code) {
|
||||
$element = $dictionary[$code];
|
||||
if (!isset($element)) {
|
||||
|
@@ -118,9 +118,7 @@ if ($_POST && !$error) {
|
||||
}
|
||||
}
|
||||
if ($_POST["delete"] || $set) {
|
||||
if ($_POST["clone"]) {
|
||||
$query = "INTO " . table($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . table($TABLE);
|
||||
}
|
||||
$query = ($_POST["clone"] ? "INTO " . table($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . table($TABLE) : "");
|
||||
if ($_POST["all"] || ($primary && is_array($_POST["check"])) || $is_group) {
|
||||
$result = ($_POST["delete"]
|
||||
? $driver->delete($TABLE, $where_check)
|
||||
@@ -484,6 +482,7 @@ if (!$columns && support("table")) {
|
||||
if (!is_ajax()) {
|
||||
if ($rows || $page) {
|
||||
$exact_count = true;
|
||||
$found_rows = null;
|
||||
if ($_GET["page"] != "last") {
|
||||
if ($limit == "" || (count($rows) < $limit && ($rows || !$page))) {
|
||||
$found_rows = ($page ? $page * $limit : 0) + count($rows);
|
||||
@@ -507,10 +506,8 @@ if (!$columns && support("table")) {
|
||||
);
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "<div class='footer'><div>\n";
|
||||
if ($rows || $page) {
|
||||
if ($pagination) {
|
||||
// display first, previous 4, next 4 and last page
|
||||
$max_page = ($found_rows === false
|
||||
@@ -578,9 +575,8 @@ if (!$columns && support("table")) {
|
||||
}
|
||||
|
||||
$adminer->selectEmailPrint(array_filter($email_fields, 'strlen'), $columns);
|
||||
}
|
||||
|
||||
echo "</div></div>\n";
|
||||
}
|
||||
|
||||
if ($adminer->selectImportPrint()) {
|
||||
echo "<div>";
|
||||
|
@@ -152,6 +152,7 @@ if (!$error && $_POST) {
|
||||
$time .= ", <a href='#$warnings_id'>" . lang('Warnings') . "</a>" . script("qsl('a').onclick = partial(toggle, '$warnings_id');", "");
|
||||
}
|
||||
$explain = null;
|
||||
$orgtables = null;
|
||||
$explain_id = "explain-$commands";
|
||||
if (is_object($result)) {
|
||||
$limit = $_POST["limit"];
|
||||
|
@@ -219,7 +219,7 @@ function minify_js($file) {
|
||||
return lzw_compress($file);
|
||||
}
|
||||
|
||||
function compile_file($match) {
|
||||
function compile_file($match, $callback) { // $callback only to match signature
|
||||
global $project;
|
||||
$file = "";
|
||||
list(, $filenames, $callback) = $match;
|
||||
|
@@ -1,10 +1,11 @@
|
||||
parameters:
|
||||
level: 0
|
||||
level: 1
|
||||
ignoreErrors:
|
||||
- identifier: include.fileNotFound # relative includes
|
||||
- identifier: includeOnce.fileNotFound # ./adminer-plugins.php
|
||||
- "~^Function (set_magic_quotes_runtime|mysql_)~" # PHP < 7 functions
|
||||
- "~^Instantiated class Adminer\\w~" # no support for classes defined inside function
|
||||
- "~^Variable \\$(adminer|connection|driver|drivers|error|HTTPS|LANG|langs|permanent|has_token|token|translations|VERSION) might not be defined~" # declared in bootstrap.inc.php
|
||||
paths:
|
||||
- .
|
||||
phpVersion:
|
||||
|
@@ -207,9 +207,7 @@ if (isset($_GET["elastic"])) {
|
||||
if (empty($search)) {
|
||||
return false;
|
||||
}
|
||||
if ($select == array("*")) {
|
||||
$tableFields = array_keys(fields($table));
|
||||
}
|
||||
$tableFields = ($select == array("*") ? array_keys(fields($table)) : array());
|
||||
|
||||
$return = array();
|
||||
foreach ($search["hits"]["hits"] as $hit) {
|
||||
@@ -332,7 +330,7 @@ if (isset($_GET["elastic"])) {
|
||||
return $credentials[1];
|
||||
}
|
||||
|
||||
function get_databases() {
|
||||
function get_databases($flush) {
|
||||
return array("elastic");
|
||||
}
|
||||
|
||||
@@ -445,7 +443,7 @@ if (isset($_GET["elastic"])) {
|
||||
return h(connection()->error);
|
||||
}
|
||||
|
||||
function information_schema() {
|
||||
function information_schema($db) {
|
||||
//
|
||||
}
|
||||
|
||||
|
@@ -478,7 +478,7 @@ if (isset($_GET["mongo"])) {
|
||||
function db_collation($db, $collations) {
|
||||
}
|
||||
|
||||
function information_schema() {
|
||||
function information_schema($db) {
|
||||
}
|
||||
|
||||
function is_view($table_status) {
|
||||
|
@@ -274,7 +274,7 @@ if (isset($_GET["simpledb"])) {
|
||||
return $credentials[1];
|
||||
}
|
||||
|
||||
function get_databases() {
|
||||
function get_databases($flush) {
|
||||
return array("domain");
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ if (isset($_GET["simpledb"])) {
|
||||
return h($connection->error);
|
||||
}
|
||||
|
||||
function information_schema() {
|
||||
function information_schema($db) {
|
||||
}
|
||||
|
||||
function indexes($table, $connection2 = null) {
|
||||
|
Reference in New Issue
Block a user