From 1810ce8b079204da2b7d8c65ab2e04422bcf59c8 Mon Sep 17 00:00:00 2001 From: Marcus Nightingale Date: Wed, 15 Oct 2025 12:20:57 +0100 Subject: [PATCH 1/9] * removed rules removed in phpcs4 from phpcs.xml, * ran phpcs auto fix to correct violations, * added make commands from phpcs --- Makefile | 16 +++++++ adminer/call.inc.php | 1 + adminer/check.inc.php | 1 + adminer/create.inc.php | 1 + adminer/database.inc.php | 1 + adminer/db.inc.php | 1 + adminer/designs.php | 1 + adminer/download.inc.php | 1 + adminer/drivers/mssql.inc.php | 1 + adminer/drivers/mysql.inc.php | 1 + adminer/drivers/oracle.inc.php | 1 + adminer/drivers/pgsql.inc.php | 1 + adminer/drivers/sqlite.inc.php | 1 + adminer/dump.inc.php | 1 + adminer/edit.inc.php | 1 + adminer/elastic.php | 1 + adminer/event.inc.php | 1 + adminer/file.inc.php | 1 + adminer/foreign.inc.php | 1 + adminer/include/auth.inc.php | 1 + adminer/include/bootstrap.inc.php | 1 + adminer/include/connect.inc.php | 1 + adminer/include/coverage.inc.php | 1 + adminer/include/db.inc.php | 1 + adminer/include/design.inc.php | 73 ++++++++++++++++--------------- adminer/include/driver.inc.php | 1 + adminer/include/editing.inc.php | 1 + adminer/include/errors.inc.php | 1 + adminer/include/functions.inc.php | 1 + adminer/include/html.inc.php | 1 + adminer/include/lang.inc.php | 1 + adminer/include/pdo.inc.php | 1 + adminer/include/plugin.inc.php | 1 + adminer/include/plugins.inc.php | 1 + adminer/include/tmpfile.inc.php | 1 + adminer/include/version.inc.php | 1 + adminer/include/xxtea.inc.php | 1 + adminer/index.php | 2 + adminer/indexes.inc.php | 1 + adminer/lang/ar.inc.php | 1 + adminer/lang/bg.inc.php | 1 + adminer/lang/bn.inc.php | 1 + adminer/lang/bs.inc.php | 1 + adminer/lang/ca.inc.php | 1 + adminer/lang/cs.inc.php | 1 + adminer/lang/da.inc.php | 1 + adminer/lang/de.inc.php | 1 + adminer/lang/el.inc.php | 1 + adminer/lang/en.inc.php | 1 + adminer/lang/es.inc.php | 1 + adminer/lang/et.inc.php | 1 + adminer/lang/fa.inc.php | 1 + adminer/lang/fi.inc.php | 1 + adminer/lang/fr.inc.php | 1 + adminer/lang/gl.inc.php | 1 + adminer/lang/he.inc.php | 1 + adminer/lang/hi.inc.php | 1 + adminer/lang/hu.inc.php | 1 + adminer/lang/id.inc.php | 1 + adminer/lang/it.inc.php | 1 + adminer/lang/ja.inc.php | 1 + adminer/lang/ka.inc.php | 1 + adminer/lang/ko.inc.php | 1 + adminer/lang/lt.inc.php | 1 + adminer/lang/lv.inc.php | 1 + adminer/lang/ms.inc.php | 1 + adminer/lang/nl.inc.php | 1 + adminer/lang/no.inc.php | 1 + adminer/lang/pl.inc.php | 1 + adminer/lang/pt-br.inc.php | 1 + adminer/lang/pt.inc.php | 1 + adminer/lang/ro.inc.php | 1 + adminer/lang/ru.inc.php | 1 + adminer/lang/sk.inc.php | 1 + adminer/lang/sl.inc.php | 1 + adminer/lang/sr.inc.php | 1 + adminer/lang/sv.inc.php | 1 + adminer/lang/ta.inc.php | 1 + adminer/lang/th.inc.php | 1 + adminer/lang/tr.inc.php | 1 + adminer/lang/uk.inc.php | 1 + adminer/lang/uz.inc.php | 1 + adminer/lang/vi.inc.php | 1 + adminer/lang/xx.inc.php | 1 + adminer/lang/zh-tw.inc.php | 1 + adminer/lang/zh.inc.php | 1 + adminer/privileges.inc.php | 1 + adminer/procedure.inc.php | 1 + adminer/processlist.inc.php | 1 + adminer/schema.inc.php | 1 + adminer/scheme.inc.php | 1 + adminer/script.inc.php | 1 + adminer/select.inc.php | 1 + adminer/sequence.inc.php | 1 + adminer/sql.inc.php | 1 + adminer/sqlite.php | 1 + adminer/table.inc.php | 1 + adminer/trigger.inc.php | 1 + adminer/type.inc.php | 1 + adminer/user.inc.php | 1 + adminer/variables.inc.php | 1 + adminer/view.inc.php | 1 + editor/db.inc.php | 1 + editor/example.php | 1 + editor/include/connect.inc.php | 1 + editor/include/editing.inc.php | 1 + editor/index.php | 1 + editor/script.inc.php | 1 + editor/sqlite.php | 1 + phpcs.xml | 14 +----- plugins/drivers/clickhouse.php | 1 + plugins/drivers/elastic.php | 1 + plugins/drivers/firebird.php | 1 + plugins/drivers/imap.php | 1 + plugins/drivers/mongo.php | 1 + plugins/drivers/simpledb.php | 1 + plugins/file-upload.php | 1 + plugins/login-table.php | 1 + plugins/translation.php | 1 + 119 files changed, 171 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index 8c5dcfbf6..7d6764439 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +PHPCS_BIN := $(HOME)/.composer/vendor/bin/phpcs +PHPCBF_BIN := $(HOME)/.composer/vendor/bin/phpcbf + ROOT_DIRECTORY = $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))") PHP := $(shell which php) PORT := 8000 @@ -37,3 +40,16 @@ clean: .PHONY: clean.all clean.all: clean + +.PHONY: get-phpcs +get-phpcs: + @echo "Global PHPCS path: $(PHPCS_BIN)" + @$(PHPCS_BIN) --version || echo "PHPCS not installed globally" + +.PHONY: phpcs +phpcs: + $(PHPCS_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml + +.PHONY: phpcbf +phpcbf: + $(PHPCBF_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 4658e6619..bbedb3882 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -1,4 +1,5 @@ "MySQL / MariaDB") + SqlDriver::$drivers; diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 831effc9d..45a682240 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -1,4 +1,5 @@ css(); if (is_int(key($css))) { // legacy return value - $css = array_fill_keys($css, 'light'); + $css = array_fill_keys($css, 'light'); } $has_light = in_array('light', $css) || in_array('', $css); $has_dark = in_array('dark', $css) || in_array('', $css); @@ -40,7 +41,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s ); $media = " media='(prefers-color-scheme: dark)'"; if ($dark !== false) { - echo "\n"; + echo "\n"; } echo "\n"; @@ -48,23 +49,23 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s echo script_src("../adminer/static/functions.js"); echo script_src("static/editing.js"); if (adminer()->head($dark)) { - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; } foreach ($css as $url => $mode) { - $attrs = ($mode == 'dark' && !$dark - ? $media - : ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "") - ); - echo "\n"; + $attrs = ($mode == 'dark' && !$dark + ? $media + : ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "") +); +echo "\n"; } echo "\nbodyClass(); echo "'>\n"; $filename = get_temp_dir() . "/adminer.version"; if (!$_COOKIE["adminer_version"] && function_exists('openssl_verify') && file_exists($filename) && filemtime($filename) + 86400 > time()) { // 86400 - 1 day in seconds - $version = unserialize(file_get_contents($filename)); - $public = "-----BEGIN PUBLIC KEY----- + $version = unserialize(file_get_contents($filename)); + $public = "-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8 @@ -74,9 +75,9 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s fQIDAQAB -----END PUBLIC KEY----- "; - if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) { - $_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser - } + if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) { + $_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser + } } echo script("mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick" . (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '" . VERSION . "', '" . js_escape(ME) . "', '" . get_token() . "')") @@ -90,31 +91,31 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s echo "
\n"; echo "" . icon("move", "", "menu", "") . "" . script("qs('#menuopen').onclick = event => { qs('#foot').classList.toggle('foot'); event.stopPropagation(); }"); if ($breadcrumb !== null) { - $link = substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1); - echo '

$title_all

\n"; echo "\n"; @@ -122,7 +123,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s page_messages($error); $databases = &get_session("dbs"); if (DB != "" && $databases && !in_array(DB, $databases, true)) { - $databases = null; + $databases = null; } stop_session(); define('Adminer\PAGE_HEADER', 1); diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php index 61a7d3953..ffac3be35 100644 --- a/adminer/include/driver.inc.php +++ b/adminer/include/driver.inc.php @@ -1,4 +1,5 @@ element */ diff --git a/adminer/include/lang.inc.php b/adminer/include/lang.inc.php index d648cea3c..4d5d24e30 100644 --- a/adminer/include/lang.inc.php +++ b/adminer/include/lang.inc.php @@ -1,4 +1,5 @@ select_db(adminer()->database()); diff --git a/editor/include/editing.inc.php b/editor/include/editing.inc.php index f0fdc494e..fb5659a70 100644 --- a/editor/include/editing.inc.php +++ b/editor/include/editing.inc.php @@ -1,4 +1,5 @@ /externals/ /designs/ /(adminer|editor)[-.] + /vendor @@ -79,7 +80,6 @@ - @@ -93,19 +93,7 @@ - - - - - - - - - - - - diff --git a/plugins/drivers/clickhouse.php b/plugins/drivers/clickhouse.php index 7fa1d5fc8..191ca2ff3 100644 --- a/plugins/drivers/clickhouse.php +++ b/plugins/drivers/clickhouse.php @@ -1,4 +1,5 @@ and link to the uploaded files from select diff --git a/plugins/login-table.php b/plugins/login-table.php index 3fa4a979f..cfe6f4ed5 100644 --- a/plugins/login-table.php +++ b/plugins/login-table.php @@ -1,4 +1,5 @@ Date: Wed, 15 Oct 2025 12:25:37 +0100 Subject: [PATCH 2/9] Small changes --- Makefile | 2 +- phpcs.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7d6764439..325d034be 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ get-phpcs: .PHONY: phpcs phpcs: - $(PHPCS_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml + $(PHPCS_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml --report=full .PHONY: phpcbf phpcbf: diff --git a/phpcs.xml b/phpcs.xml index 800ea242c..b438f5b00 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -52,6 +52,7 @@ adminer/include/pdo.inc.php adminer/plugins/foreign-system.php adminer/plugins/drivers/ + plugins/* From 4c3a7039b566946e03122cd1c7ac3fb7aba4bd28 Mon Sep 17 00:00:00 2001 From: Marcus Nightingale Date: Wed, 15 Oct 2025 12:39:15 +0100 Subject: [PATCH 3/9] * Fixing file that autofixed incorrectly --- adminer/include/design.inc.php | 98 +++++++++++++++++----------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index c2534dba9..3c27314c1 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -31,7 +31,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s $css = adminer()->css(); if (is_int(key($css))) { // legacy return value - $css = array_fill_keys($css, 'light'); + $css = array_fill_keys($css, 'light'); } $has_light = in_array('light', $css) || in_array('', $css); $has_dark = in_array('dark', $css) || in_array('', $css); @@ -41,7 +41,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s ); $media = " media='(prefers-color-scheme: dark)'"; if ($dark !== false) { - echo "\n"; + echo "\n"; } echo "\n"; @@ -49,35 +49,35 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s echo script_src("../adminer/static/functions.js"); echo script_src("static/editing.js"); if (adminer()->head($dark)) { - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; } foreach ($css as $url => $mode) { - $attrs = ($mode == 'dark' && !$dark - ? $media - : ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "") -); -echo "\n"; + $attrs = ($mode == 'dark' && !$dark + ? $media + : ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "") + ); + echo "\n"; } echo "\nbodyClass(); echo "'>\n"; $filename = get_temp_dir() . "/adminer.version"; if (!$_COOKIE["adminer_version"] && function_exists('openssl_verify') && file_exists($filename) && filemtime($filename) + 86400 > time()) { // 86400 - 1 day in seconds - $version = unserialize(file_get_contents($filename)); - $public = "-----BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK -RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs -DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8 -h7FIx3jEaw5ckVPVTeo5JRm/1DZzJxjyDenXvBQ/6o9DgZKeNDgxwKzH+sw9/YCO -jHnq1cFpOIISzARlrHMa/43YfeNRAm/tsBXjSxembBPo7aQZLAWHmaj5+K19H10B -nCpz9Y++cipkVEiKRGih4ZEvjoFysEOdRLj6WiD/uUNky4xGeA6LaJqh5XpkFkcQ -fQIDAQAB ------END PUBLIC KEY----- -"; - if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) { - $_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser - } + $version = unserialize(file_get_contents($filename)); + $public = "-----BEGIN PUBLIC KEY----- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK + RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs + DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8 + h7FIx3jEaw5ckVPVTeo5JRm/1DZzJxjyDenXvBQ/6o9DgZKeNDgxwKzH+sw9/YCO + jHnq1cFpOIISzARlrHMa/43YfeNRAm/tsBXjSxembBPo7aQZLAWHmaj5+K19H10B + nCpz9Y++cipkVEiKRGih4ZEvjoFysEOdRLj6WiD/uUNky4xGeA6LaJqh5XpkFkcQ + fQIDAQAB + -----END PUBLIC KEY----- + "; + if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) { + $_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser + } } echo script("mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick" . (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '" . VERSION . "', '" . js_escape(ME) . "', '" . get_token() . "')") @@ -91,31 +91,31 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s echo "
\n"; echo "" . icon("move", "", "menu", "") . "" . script("qs('#menuopen').onclick = event => { qs('#foot').classList.toggle('foot'); event.stopPropagation(); }"); if ($breadcrumb !== null) { - $link = substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1); - echo '

$title_all

\n"; echo "\n"; @@ -123,7 +123,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s page_messages($error); $databases = &get_session("dbs"); if (DB != "" && $databases && !in_array(DB, $databases, true)) { - $databases = null; + $databases = null; } stop_session(); define('Adminer\PAGE_HEADER', 1); From 15d35c79bf064619ced86d99a3fce42892619d79 Mon Sep 17 00:00:00 2001 From: Marcus Nightingale Date: Wed, 15 Oct 2025 12:41:05 +0100 Subject: [PATCH 4/9] * Fixing file that autofixed incorrectly --- adminer/include/design.inc.php | 98 +++++++++++++++++----------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 3c27314c1..44e706f13 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -31,7 +31,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s $css = adminer()->css(); if (is_int(key($css))) { // legacy return value - $css = array_fill_keys($css, 'light'); + $css = array_fill_keys($css, 'light'); } $has_light = in_array('light', $css) || in_array('', $css); $has_dark = in_array('dark', $css) || in_array('', $css); @@ -41,7 +41,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s ); $media = " media='(prefers-color-scheme: dark)'"; if ($dark !== false) { - echo "\n"; + echo "\n"; } echo "\n"; @@ -49,35 +49,35 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s echo script_src("../adminer/static/functions.js"); echo script_src("static/editing.js"); if (adminer()->head($dark)) { - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; } foreach ($css as $url => $mode) { - $attrs = ($mode == 'dark' && !$dark - ? $media - : ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "") - ); - echo "\n"; + $attrs = ($mode == 'dark' && !$dark + ? $media + : ($mode == 'light' && $has_dark ? " media='(prefers-color-scheme: light)'" : "") + ); + echo "\n"; } echo "\nbodyClass(); echo "'>\n"; $filename = get_temp_dir() . "/adminer.version"; if (!$_COOKIE["adminer_version"] && function_exists('openssl_verify') && file_exists($filename) && filemtime($filename) + 86400 > time()) { // 86400 - 1 day in seconds - $version = unserialize(file_get_contents($filename)); - $public = "-----BEGIN PUBLIC KEY----- - MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK - RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs - DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8 - h7FIx3jEaw5ckVPVTeo5JRm/1DZzJxjyDenXvBQ/6o9DgZKeNDgxwKzH+sw9/YCO - jHnq1cFpOIISzARlrHMa/43YfeNRAm/tsBXjSxembBPo7aQZLAWHmaj5+K19H10B - nCpz9Y++cipkVEiKRGih4ZEvjoFysEOdRLj6WiD/uUNky4xGeA6LaJqh5XpkFkcQ - fQIDAQAB - -----END PUBLIC KEY----- - "; - if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) { - $_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser - } + $version = unserialize(file_get_contents($filename)); + $public = "-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK +RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs +DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8 +h7FIx3jEaw5ckVPVTeo5JRm/1DZzJxjyDenXvBQ/6o9DgZKeNDgxwKzH+sw9/YCO +jHnq1cFpOIISzARlrHMa/43YfeNRAm/tsBXjSxembBPo7aQZLAWHmaj5+K19H10B +nCpz9Y++cipkVEiKRGih4ZEvjoFysEOdRLj6WiD/uUNky4xGeA6LaJqh5XpkFkcQ +fQIDAQAB +-----END PUBLIC KEY----- +"; + if (openssl_verify($version["version"], base64_decode($version["signature"]), $public) == 1) { + $_COOKIE["adminer_version"] = $version["version"]; // doesn't need to send to the browser + } } echo script("mixin(document.body, {onkeydown: bodyKeydown, onclick: bodyClick" . (isset($_COOKIE["adminer_version"]) ? "" : ", onload: partial(verifyVersion, '" . VERSION . "', '" . js_escape(ME) . "', '" . get_token() . "')") @@ -91,31 +91,31 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s echo "
\n"; echo "" . icon("move", "", "menu", "") . "" . script("qs('#menuopen').onclick = event => { qs('#foot').classList.toggle('foot'); event.stopPropagation(); }"); if ($breadcrumb !== null) { - $link = substr(preg_replace('~\b(username|db|ns)=[^&]*&~', '', ME), 0, -1); - echo '

$title_all

\n"; echo "\n"; @@ -123,7 +123,7 @@ function page_header(string $title, string $error = "", $breadcrumb = array(), s page_messages($error); $databases = &get_session("dbs"); if (DB != "" && $databases && !in_array(DB, $databases, true)) { - $databases = null; + $databases = null; } stop_session(); define('Adminer\PAGE_HEADER', 1); From 3847250b199068f9ab0a32fa2dab60670293c620 Mon Sep 17 00:00:00 2001 From: Marcus Nightingale Date: Wed, 15 Oct 2025 12:46:48 +0100 Subject: [PATCH 5/9] * adding missed command to get phpcs via composer --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 325d034be..02ce49349 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ clean.all: clean .PHONY: get-phpcs get-phpcs: + composer global require "squizlabs/php_codesniffer=*" @echo "Global PHPCS path: $(PHPCS_BIN)" @$(PHPCS_BIN) --version || echo "PHPCS not installed globally" From de23b08bfa1c572872fa3f92fdeb3e26ae095d50 Mon Sep 17 00:00:00 2001 From: Marcus Nightingale Date: Mon, 29 Jun 2026 18:12:14 +0100 Subject: [PATCH 6/9] updating composer.json --- .github/workflows/ci.yml | 2 +- Makefile | 56 ---------------------------------------- README.md | 8 ++++++ composer.json | 13 +++++++--- phpstan.neon | 3 +-- 5 files changed, 20 insertions(+), 62 deletions(-) delete mode 100644 Makefile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 113ec42be..492ff4d59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: php-actions/composer@v6 - uses: php-actions/phpcs@v1 with: diff --git a/Makefile b/Makefile deleted file mode 100644 index 02ce49349..000000000 --- a/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -PHPCS_BIN := $(HOME)/.composer/vendor/bin/phpcs -PHPCBF_BIN := $(HOME)/.composer/vendor/bin/phpcbf - -ROOT_DIRECTORY = $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))") -PHP := $(shell which php) -PORT := 8000 - - -.DEFAULT_GOAL := default - - -.PHONY: default -default: compile - -.PHONY: compile -compile: - $(PHP) $(ROOT_DIRECTORY)/compile.php - -.PHONY: server -server: - php \ - --server 127.0.0.1:$(PORT) \ - --docroot $(ROOT_DIRECTORY) - -.PHONY: initialize -initialize: - git \ - -C $(ROOT_DIRECTORY) \ - submodule \ - update \ - --init \ - --recursive - -.PHONY: clean -clean: - rm \ - --recursive \ - --force \ - $(ROOT_DIRECTORY)/adminer.php - -.PHONY: clean.all -clean.all: clean - -.PHONY: get-phpcs -get-phpcs: - composer global require "squizlabs/php_codesniffer=*" - @echo "Global PHPCS path: $(PHPCS_BIN)" - @$(PHPCS_BIN) --version || echo "PHPCS not installed globally" - -.PHONY: phpcs -phpcs: - $(PHPCS_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml --report=full - -.PHONY: phpcbf -phpcbf: - $(PHPCBF_BIN) $(ROOT_DIRECTORY) --standard=$(ROOT_DIRECTORY)/phpcs.xml diff --git a/README.md b/README.md index 856aab018..863bbaf41 100644 --- a/README.md +++ b/README.md @@ -22,5 +22,13 @@ If downloaded from Git then run: `git submodule update --init` - `lang.php` - Update translations - `tests/*.html` - Katalon Recorder test suites +## Composer Scripts +Install the development tools first with `composer install`. + +- `composer initialize` - Update Git submodules +- `composer phpcs` - Run the coding standard check using [phpcs.xml](/phpcs.xml) +- `composer phpcbf` - Automatically fix coding standard issues where possible using [phpcs.xml](/phpcs.xml) +- `composer phpstan` - Run PHPStan using `phpstan.neon` + ## Plugins There are several plugins distributed with Adminer, as well as many user-contributed plugins listed on the [Adminer Plugins page](https://www.adminer.org/plugins/). diff --git a/composer.json b/composer.json index 7c70f84fc..443b1f360 100644 --- a/composer.json +++ b/composer.json @@ -32,12 +32,19 @@ "require": { "php": ">=7.4" }, + "require-dev": { + "squizlabs/php_codesniffer": "^3.11" + }, "scripts": { "check": [ - "phpcs", - "phpstan analyse -c phpstan.neon" + "@phpcs", + "@phpstan" ], "compile": "@php compile.php", - "clean": "rm -f adminer*.php editor*.php" + "clean": "rm -f adminer*.php editor*.php", + "initialize": "git submodule update --init --recursive", + "phpcbf": "sh -c 'if [ -x vendor/bin/phpcbf ]; then exec vendor/bin/phpcbf --standard=phpcs.xml .; fi; bin=\"$(composer global config bin-dir --absolute 2>/dev/null)/phpcbf\"; if [ -x \"$bin\" ]; then exec \"$bin\" --standard=phpcs.xml .; fi; exec phpcbf --standard=phpcs.xml .'", + "phpcs": "sh -c 'if [ -x vendor/bin/phpcs ]; then exec vendor/bin/phpcs --standard=phpcs.xml --report=full .; fi; bin=\"$(composer global config bin-dir --absolute 2>/dev/null)/phpcs\"; if [ -x \"$bin\" ]; then exec \"$bin\" --standard=phpcs.xml --report=full .; fi; exec phpcs --standard=phpcs.xml --report=full .'", + "phpstan": "sh -c 'if [ -x vendor/bin/phpstan ]; then exec vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=512M; fi; bin=\"$(composer global config bin-dir --absolute 2>/dev/null)/phpstan\"; if [ -x \"$bin\" ]; then exec \"$bin\" analyse -c phpstan.neon --memory-limit=512M; fi; exec phpstan analyse -c phpstan.neon --memory-limit=512M'" } } diff --git a/phpstan.neon b/phpstan.neon index 1b2253aea..988712a9a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -60,8 +60,7 @@ parameters: - adminer/sqlite.php phpVersion: - min: 70100 - max: 80499 + 70400 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}" From 66d785930ef736e6e91ffc6c80937bc6bdd5d0b0 Mon Sep 17 00:00:00 2001 From: Marcus Nightingale Date: Mon, 29 Jun 2026 18:14:06 +0100 Subject: [PATCH 7/9] fixing phpcs violations --- adminer/lang/hr.inc.php | 1 + plugins/drivers/igdb.php | 1 + 2 files changed, 2 insertions(+) diff --git a/adminer/lang/hr.inc.php b/adminer/lang/hr.inc.php index 184c770ad..7c99db474 100644 --- a/adminer/lang/hr.inc.php +++ b/adminer/lang/hr.inc.php @@ -1,4 +1,5 @@ Date: Mon, 29 Jun 2026 18:16:30 +0100 Subject: [PATCH 8/9] Adding phpstan dev dependency --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 443b1f360..517844e69 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "php": ">=7.4" }, "require-dev": { + "phpstan/phpstan": "^1.12", "squizlabs/php_codesniffer": "^3.11" }, "scripts": { From 4e703e8af02a13ee2b1f7dcb612ee5248fa9465b Mon Sep 17 00:00:00 2001 From: Marcus Nightingale Date: Mon, 29 Jun 2026 19:53:55 +0100 Subject: [PATCH 9/9] PHPStan fixes --- .github/workflows/ci.yml | 7 ++----- adminer/create.inc.php | 2 +- adminer/drivers/mysql.inc.php | 2 +- adminer/drivers/pgsql.inc.php | 3 ++- adminer/file.inc.php | 2 +- adminer/include/bootstrap.inc.php | 2 +- adminer/include/html.inc.php | 2 +- phpstan.neon | 14 ++++++++------ 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 492ff4d59..faa801277 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,5 @@ jobs: steps: - uses: actions/checkout@v4 - uses: php-actions/composer@v6 - - uses: php-actions/phpcs@v1 - with: - path: . - standard: phpcs.xml - - uses: php-actions/phpstan@v3 + - run: composer phpcs + - run: composer phpstan diff --git a/adminer/create.inc.php b/adminer/create.inc.php index b9a9fdf4f..e8154375f 100644 --- a/adminer/create.inc.php +++ b/adminer/create.inc.php @@ -45,7 +45,7 @@ foreach ($row["fields"] as $key => $field) { $foreign_key = $foreign_keys[$field["type"]]; - $type_field = ($foreign_key !== null ? $referencable_primary[$foreign_key] : $field); //! can collide with user defined type + $type_field = (isset($referencable_primary[$foreign_key]) ? $referencable_primary[$foreign_key] : $field); //! can collide with user defined type if ($field["field"] != "") { if (!$field["generated"]) { $field["default"] = null; diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 9a2e54de5..5af63a017 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -31,7 +31,7 @@ function attach(string $server, string $username, string $password): string { null, (is_numeric($port) ? intval($port) : ini_get("mysqli.default_port")), (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) + ($ssl ? (isset($ssl['verify']) && $ssl['verify'] === false ? 64 : 2048) : 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, 0); return ($return ? '' : $this->error); diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index fa8d9c8d6..3630f6ba9 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -90,7 +90,8 @@ function query(string $query, bool $unbuffered = false) { function warnings() { if (PHP_VERSION_ID >= 70100) { - $return = implode("\n", pg_last_notice($this->link, 2)); // 2 - PGSQL_NOTICE_ALL + $notice = pg_last_notice($this->link, 2); // 2 - PGSQL_NOTICE_ALL + $return = implode("\n", (array) $notice); pg_last_notice($this->link, 3); // 3 - PGSQL_NOTICE_CLEAR } else { $return = pg_last_notice($this->link); diff --git a/adminer/file.inc.php b/adminer/file.inc.php index 8c62dac00..2d771d684 100644 --- a/adminer/file.inc.php +++ b/adminer/file.inc.php @@ -2,7 +2,7 @@ namespace Adminer; -if (substr(VERSION, -4) != '-dev') { +if (defined('Adminer\VERSION') && substr(VERSION, -4) != '-dev') { if ($_SERVER["HTTP_IF_MODIFIED_SINCE"]) { header("HTTP/1.1 304 Not Modified"); exit; diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 51990bd77..1d45128d8 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -92,7 +92,7 @@ 'Adminer\ME', preg_replace('~\?.*~', '', relative_uri()) . '?' . (sid() ? SID . '&' : '') - . (SERVER !== null ? DRIVER . "=" . urlencode(SERVER) . '&' : '') + . DRIVER . "=" . urlencode(SERVER) . '&' . ($_GET["ext"] ? "ext=" . urlencode($_GET["ext"]) . '&' : '') . (isset($_GET["username"]) ? "username=" . urlencode($_GET["username"]) . '&' : '') . (DB != "" ? 'db=' . urlencode(DB) . '&' . (isset($_GET["ns"]) ? "ns=" . urlencode($_GET["ns"]) . "&" : "") : '') diff --git a/adminer/include/html.inc.php b/adminer/include/html.inc.php index 067cfcfda..eb2999b0c 100644 --- a/adminer/include/html.inc.php +++ b/adminer/include/html.inc.php @@ -173,7 +173,7 @@ function hidden_fields(array $process, array $ignore = array(), string $prefix = /** Print hidden fields for GET forms */ function hidden_fields_get(): void { echo (sid() ? input_hidden(session_name(), session_id()) : ''); - echo (SERVER !== null ? input_hidden(DRIVER, SERVER) : ""); + echo input_hidden(DRIVER, SERVER); echo input_hidden("username", $_GET["username"]); } diff --git a/phpstan.neon b/phpstan.neon index 988712a9a..8c6394b05 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -9,7 +9,6 @@ parameters: - "~Function Adminer\\\\queries\\(\\) never returns Adminer\\\\Result~" # mysqli_result # not real problems - - identifier: include.fileNotFound # includes in include/ relative from index.php - "~^Function (set_magic_quotes_runtime|mysql_)~" # PHP < 7 functions - "~an unknown class OCI-?Lob~" # this looks like PHPStan bug - "~^Variable \\$error might not be defined~" # declared in bootstrap.inc.php @@ -22,7 +21,6 @@ parameters: - "~expects bool~" # truthy values - "~fread expects int<1, max>, 100000~" # 1e6 - "~'strlen' given~" # used as a bool callback - - "~between int<70100~" # PHP_VERSION_ID check - message: "~ type specified~" # duplicate functions and methods @@ -31,9 +29,6 @@ parameters: - adminer/drivers/* # it probably doesn't like $ar[$key] instead of isset($ar[$key]) and thinks that $ar[$key] is always set - - identifier: identical.alwaysFalse - - identifier: notEqual.alwaysFalse - - identifier: notIdentical.alwaysTrue - identifier: booleanNot.alwaysTrue - identifier: booleanNot.alwaysFalse - identifier: booleanAnd.alwaysFalse @@ -46,7 +41,7 @@ parameters: - identifier: isset.offset - identifier: deadCode.unreachable - "~Function Adminer\\\\get_driver\\(\\) never returns null~" - - "~on array\\{}~" + - "~Strict comparison using === between .* will always evaluate to false\\.~" paths: - adminer/drivers/mysql.inc.php # other drivers inherit the annotations so we take them from here @@ -59,6 +54,13 @@ parameters: - adminer/elastic.php - adminer/sqlite.php + parallel: + jobSize: 20 + processTimeout: 600.0 + maximumNumberOfProcesses: 1 + minimumNumberOfJobsPerProcess: 2 + buffer: 134217728 + phpVersion: 70400