]> git.joonet.de Git - adminer.git/commitdiff
Code style: Fix
authorJakub Vrana <jakub@vrana.cz>
Tue, 8 Apr 2025 19:16:09 +0000 (21:16 +0200)
committerJakub Vrana <jakub@vrana.cz>
Tue, 8 Apr 2025 19:26:08 +0000 (21:26 +0200)
adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/oracle.inc.php
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
adminer/file.inc.php
adminer/include/driver.inc.php
adminer/include/functions.inc.php
compile.php
phpcs.xml
tests/screenshots.php

index 46279062f33543daee5b6a3eefdc4d082a872693..ddb80ea5c334a6f4d51f631ba2f834a1f2ce2c5a 100644 (file)
@@ -11,6 +11,7 @@ add_driver("mssql", "MS SQL");
 
 if (isset($_GET["mssql"])) {
        define('Adminer\DRIVER', "mssql");
+
        if (extension_loaded("sqlsrv") && $_GET["ext"] != "pdo") {
                class Db extends SqlDb {
                        public $extension = "sqlsrv";
index 0daed0dc08e486f4d53a68cf64f89a4230bc3f8a..33f5ef4b7f6ac7182594a04f9e785d53adba1459 100644 (file)
@@ -5,6 +5,7 @@ SqlDriver::$drivers = array("server" => "MySQL / MariaDB") + SqlDriver::$drivers
 
 if (!defined('Adminer\DRIVER')) {
        define('Adminer\DRIVER', "server"); // server - backwards compatibility
+
        // MySQLi supports everything, MySQL doesn't support multiple result sets, PDO_MySQL doesn't support orgtable
        if (extension_loaded("mysqli") && $_GET["ext"] != "pdo") {
                class Db extends \MySQLi {
index b173949e93d106e72a8e066f6bb3d303bd34d2bb..59a445b079a3ae9dcef2610905b0337110a57db2 100644 (file)
@@ -5,6 +5,7 @@ add_driver("oracle", "Oracle (beta)");
 
 if (isset($_GET["oracle"])) {
        define('Adminer\DRIVER', "oracle");
+
        if (extension_loaded("oci8") && $_GET["ext"] != "pdo") {
                class Db extends SqlDb {
                        public $extension = "oci8";
index a9a423f37f6beba8c2360e68295391d44b040be9..003622f665e9b80eeb4a9895dc250b0c2ec3e1be 100644 (file)
@@ -5,6 +5,7 @@ add_driver("pgsql", "PostgreSQL");
 
 if (isset($_GET["pgsql"])) {
        define('Adminer\DRIVER', "pgsql");
+
        if (extension_loaded("pgsql") && $_GET["ext"] != "pdo") {
                class PgsqlDb extends SqlDb {
                        public $extension = "PgSQL";
@@ -94,8 +95,9 @@ if (isset($_GET["pgsql"])) {
                        */
                        function copyFrom(string $table, array $rows): bool {
                                $this->error = '';
-                               set_error_handler(function ($errno, $error) {
+                               set_error_handler(function (int $errno, string $error): bool {
                                        $this->error = (ini_bool('html_errors') ? html_entity_decode($error) : $error);
+                                       return true;
                                });
                                $return = pg_copy_from($this->link, $table, $rows);
                                restore_error_handler();
index 9daaedef83c5e151ac925c17e1b4148bd2886514..dd7c06ad9e31865f5da8ab463b95d667c126868c 100644 (file)
@@ -5,8 +5,8 @@ add_driver("sqlite", "SQLite");
 
 if (isset($_GET["sqlite"])) {
        define('Adminer\DRIVER', "sqlite");
-       if (class_exists("SQLite3") && $_GET["ext"] != "pdo") {
 
+       if (class_exists("SQLite3") && $_GET["ext"] != "pdo") {
                abstract class SqliteDb extends SqlDb {
                        public $extension = "SQLite3";
                        private $link;
index c46e279c638c935d4d00d278aafccc7cff5d827c..e33abe9df25a140e06384cef50a87a9ae3332ee0 100644 (file)
@@ -11,7 +11,7 @@ if (substr(VERSION, -4) != '-dev') {
        header("Cache-Control: immutable");
 }
 
-@ini_set("zlib.output_compression", 1); // @ - may be disabled
+@ini_set("zlib.output_compression", '1'); // @ - may be disabled
 
 if ($_GET["file"] == "default.css") {
        header("Content-Type: text/css; charset=utf-8");
index 41fb7582dafe46d9abc7c84aa9b5b1469292c912..dd87c80d2c458bcb580b95f2041b5082b75dcc6b 100644 (file)
@@ -257,10 +257,12 @@ AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'", $this->conn); // ignore default IS N
        */
        function allFields(): array {
                $return = array();
-               foreach (get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . "
+               foreach (
+                       get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . "
 FROM INFORMATION_SCHEMA.COLUMNS
 WHERE TABLE_SCHEMA = " . q($_GET["ns"] != "" ? $_GET["ns"] : DB) . "
-ORDER BY TABLE_NAME, ORDINAL_POSITION", $this->conn) as $row) {
+ORDER BY TABLE_NAME, ORDINAL_POSITION", $this->conn) as $row
+               ) {
                        $row["null"] = ($row["nullable"] == "YES");
                        $return[$row["tab"]][] = $row;
                }
index 52999519c1b93575f4d6e5cd7c9047e58d9fdf2e..b4aeb6a9c86a399d314003567ad37b4af7d41951 100644 (file)
@@ -595,10 +595,10 @@ function column_foreign_keys(string $table): array {
        return $return;
 }
 
-/** Compute fields() from $_POST edit data
+/** Compute fields() from $_POST edit data; used by Mongo and SimpleDB
 * @return Field[] same as fields()
 */
-function fields_from_edit(): array { // used by Mongo and SimpleDB
+function fields_from_edit(): array {
        $return = array();
        foreach ((array) $_POST["field_keys"] as $key => $val) {
                if ($val != "") {
index 969dcffdfe7024060298bc3e411d461c0c8ae88d..561005fb950b23967a5d4e42bf9b315833bfd979 100755 (executable)
@@ -199,10 +199,10 @@ function minify_css($file) {
 }
 
 function minify_js($file) {
-       $file = preg_replace_callback("~'use strict';~", function ($match) { // keep only the first one
+       $file = preg_replace_callback("~'use strict';~", function ($match) {
                static $count = 0;
                $count++;
-               return ($count == 1 ? $match[0] : '');
+               return ($count == 1 ? $match[0] : ''); // keep only the first one
        }, $file);
        if (function_exists('jsShrink')) {
                $file = jsShrink($file);
@@ -210,7 +210,8 @@ function minify_js($file) {
        return lzw_compress($file);
 }
 
-function compile_file($match, $callback = '') { // $callback only to match signature
+// $callback only to match signature
+function compile_file($match, $callback = '') {
        global $project;
        $file = "";
        list(, $filenames, $callback) = $match;
@@ -303,7 +304,12 @@ if ($vendor) {
                }
        }
        if ($project != "editor" && count(Adminer\SqlDriver::$drivers) == 1) {
-               $file = str_replace('html_select("auth[driver]", SqlDriver::$drivers, DRIVER, "loginDriver(this);")', 'input_hidden("auth[driver]", "' . ($vendor == "mysql" ? "server" : $vendor) . '") . "' . reset(Adminer\SqlDriver::$drivers) . '"', $file, $count);
+               $file = str_replace(
+                       'html_select("auth[driver]", SqlDriver::$drivers, DRIVER, "loginDriver(this);")',
+                       'input_hidden("auth[driver]", "' . ($vendor == "mysql" ? "server" : $vendor) . '") . "' . reset(Adminer\SqlDriver::$drivers) . '"',
+                       $file,
+                       $count
+               );
                if (!$count) {
                        echo "auth[driver] form field not found\n";
                }
index 76288eee0f8b1cb53c56fda9e60192de1c2a62f1..0ec493c005b3479772832a72a866920869840fd5 100644 (file)
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -47,7 +47,9 @@
 
        <rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
                <exclude-pattern>adminer/drivers/</exclude-pattern>
+               <exclude-pattern>adminer/include/db.inc.php</exclude-pattern>
                <exclude-pattern>adminer/include/pdo.inc.php</exclude-pattern>
+               <exclude-pattern>adminer/plugins/foreign-system.php</exclude-pattern>
                <exclude-pattern>adminer/plugins/drivers/</exclude-pattern>
        </rule>
 
index 00b90b0188710cba848c662784caee73a4b52ad1..cf56eb4bea7ab0e4083b73d6a2b7da8b066ae60a 100755 (executable)
@@ -1,18 +1,20 @@
 #!/usr/bin/env php
 <?php
-foreach (array(
-       'create' => array(1106, 412),
-       'dark' => array(816, 750),
-       'database' => array(896, 666),
-       'db' => array(1258, 752),
-       'dump' => array(784, 450),
-       'edit' => array(1006, 336),
-       'login' => array(628, 326),
-       'select' => array(924, 810),
-       'schema' => array(690, 406),
-       'sql' => array(870, 788),
-       'table' => array(816, 750),
-) as $filename => list($w, $h)) {
+foreach (
+       array(
+               'create' => array(1106, 412),
+               'dark' => array(816, 750),
+               'database' => array(896, 666),
+               'db' => array(1258, 752),
+               'dump' => array(784, 450),
+               'edit' => array(1006, 336),
+               'login' => array(628, 326),
+               'select' => array(924, 810),
+               'schema' => array(690, 406),
+               'sql' => array(870, 788),
+               'table' => array(816, 750),
+       ) as $filename => list($w, $h)
+) {
        $im = imagecreatefrompng("screenshots/$filename.png");
        $im2 = imagecreatetruecolor($w, $h);
        imagecopy($im2, $im, 0, 0, 0, 0, $w, $h);