1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-07 23:27:17 +02:00

Explicitly mark nullable params (thanks to @dg)

This commit is contained in:
Jakub Vrana
2025-04-01 19:14:44 +02:00
parent 01ea001f22
commit 04ed73be26
3 changed files with 7 additions and 7 deletions

View File

@@ -535,7 +535,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get table indexes /** Get table indexes
* @return Index[] * @return Index[]
*/ */
function indexes(string $table, Db $connection2 = null): array { function indexes(string $table, ?Db $connection2 = null): array {
$return = array(); $return = array();
foreach (get_rows("SHOW INDEX FROM " . table($table), $connection2) as $row) { foreach (get_rows("SHOW INDEX FROM " . table($table), $connection2) as $row) {
$name = $row["Key_name"]; $name = $row["Key_name"];
@@ -1065,7 +1065,7 @@ if (!defined('Adminer\DRIVER')) {
/** Set current schema /** Set current schema
*/ */
function set_schema(string $schema, Db $connection2 = null): bool { function set_schema(string $schema, ?Db $connection2 = null): bool {
return true; return true;
} }
} }

View File

@@ -9,7 +9,7 @@ namespace Adminer;
* @param int|numeric-string $limit * @param int|numeric-string $limit
* @return string[] $orgtables * @return string[] $orgtables
*/ */
function print_select_result($result, Db $connection2 = null, array $orgtables = array(), $limit = 0): array { function print_select_result($result, ?Db $connection2 = null, array $orgtables = array(), $limit = 0): array {
$links = array(); // colno => orgtable - create links from these columns $links = array(); // colno => orgtable - create links from these columns
$indexes = array(); // orgtable => array(column => colno) - primary keys $indexes = array(); // orgtable => array(column => colno) - primary keys
$columns = array(); // orgtable => array(column => ) - not selected columns in primary key $columns = array(); // orgtable => array(column => ) - not selected columns in primary key

View File

@@ -7,7 +7,7 @@ namespace Adminer;
* @param ?Db $connection2 custom connection to use instead of the default * @param ?Db $connection2 custom connection to use instead of the default
* @return Db * @return Db
*/ */
function connection(Db $connection2 = null) { function connection(?Db $connection2 = null) {
// can be used in customization, Db::$instance is minified // can be used in customization, Db::$instance is minified
return ($connection2 ?: Db::$instance); return ($connection2 ?: Db::$instance);
} }
@@ -108,7 +108,7 @@ function bracket_escape(string $idf, bool $back = false): string {
* @param string|float $version required version * @param string|float $version required version
* @param string|float $maria_db required MariaDB version * @param string|float $maria_db required MariaDB version
*/ */
function min_version($version, $maria_db = "", Db $connection2 = null): bool { function min_version($version, $maria_db = "", ?Db $connection2 = null): bool {
$connection2 = connection($connection2); $connection2 = connection($connection2);
$server_info = $connection2->server_info; $server_info = $connection2->server_info;
if ($maria_db && preg_match('~([\d.]+)-MariaDB~', $server_info, $match)) { if ($maria_db && preg_match('~([\d.]+)-MariaDB~', $server_info, $match)) {
@@ -191,7 +191,7 @@ function get_vals(string $query, $column = 0): array {
/** Get keys from first column and values from second /** Get keys from first column and values from second
* @return string[] * @return string[]
*/ */
function get_key_vals(string $query, Db $connection2 = null, bool $set_keys = true): array { function get_key_vals(string $query, ?Db $connection2 = null, bool $set_keys = true): array {
$connection2 = connection($connection2); $connection2 = connection($connection2);
$return = array(); $return = array();
$result = $connection2->query($query); $result = $connection2->query($query);
@@ -210,7 +210,7 @@ function get_key_vals(string $query, Db $connection2 = null, bool $set_keys = tr
/** Get all rows of result /** Get all rows of result
* @return list<string[]> of associative arrays * @return list<string[]> of associative arrays
*/ */
function get_rows(string $query, Db $connection2 = null, string $error = "<p class='error'>"): array { function get_rows(string $query, ?Db $connection2 = null, string $error = "<p class='error'>"): array {
$conn = connection($connection2); $conn = connection($connection2);
$return = array(); $return = array();
$result = $conn->query($query); $result = $conn->query($query);