From 2ee325183b0789c80570a82777bbe2f997411d22 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 25 Mar 2025 14:31:27 +0100 Subject: [PATCH] Doc-comment: Improve array @param This uses syntax from https://phpstan.org/writing-php-code/phpdoc-types#general-arrays. int[] means an array of ints with arbitrary keys (usually strings) list means an array of strings with sequential integer keys starting at 0 list[] means an arbitrary array of string lists list means list of arbitrary string arrays string[][] means two dimensional array with arbitrary keys in both dimensions array was left in the comments for https://phpstan.org/writing-php-code/phpdoc-types#array-shapes --- adminer/drivers/mysql.inc.php | 26 ++++++------ adminer/drivers/sqlite.inc.php | 6 +-- adminer/include/adminer.inc.php | 64 ++++++++++++++--------------- adminer/include/driver.inc.php | 16 ++++---- adminer/include/editing.inc.php | 26 ++++++------ adminer/include/functions.inc.php | 24 +++++------ adminer/include/html.inc.php | 10 ++--- adminer/include/plugins.inc.php | 2 +- editor/include/editing.inc.php | 2 +- plugins/database-hide.php | 2 +- plugins/designs.php | 2 +- plugins/login-ip.php | 4 +- plugins/login-servers.php | 2 +- plugins/master-slave.php | 2 +- plugins/table-indexes-structure.php | 2 +- plugins/table-structure.php | 2 +- plugins/wymeditor.php | 2 +- 17 files changed, 97 insertions(+), 97 deletions(-) diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 9bca85a7..fb487369 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -505,7 +505,7 @@ if (!defined('Adminer\DRIVER')) { /** Get database collation * @param string - * @param array result of collations() + * @param list[] result of collations() * @return string */ function db_collation($db, $collations) { @@ -535,7 +535,7 @@ if (!defined('Adminer\DRIVER')) { } /** Count tables in all databases - * @param array + * @param list * @return int[] [$db => $tables] */ function count_tables($databases) { @@ -752,7 +752,7 @@ if (!defined('Adminer\DRIVER')) { } /** Drop databases - * @param array + * @param list * @return bool */ function drop_databases($databases) { @@ -809,7 +809,7 @@ if (!defined('Adminer\DRIVER')) { * @param string "" to create * @param string new name * @param array of [$orig, $process_field, $after] - * @param array of strings + * @param list * @param string * @param string * @param string @@ -853,7 +853,7 @@ if (!defined('Adminer\DRIVER')) { /** Run commands to alter indexes * @param string escaped table name - * @param array of ["index type", "name", ["column definition", ...]] or ["index type", "name", "DROP"] + * @param array[] of ["index type", "name", ["column definition", ...]] or ["index type", "name", "DROP"] * @return bool */ function alter_indexes($table, $alter) { @@ -867,7 +867,7 @@ if (!defined('Adminer\DRIVER')) { } /** Run commands to truncate tables - * @param array + * @param list * @return bool */ function truncate_tables($tables) { @@ -875,7 +875,7 @@ if (!defined('Adminer\DRIVER')) { } /** Drop views - * @param array + * @param list * @return bool */ function drop_views($views) { @@ -883,7 +883,7 @@ if (!defined('Adminer\DRIVER')) { } /** Drop tables - * @param array + * @param list * @return bool */ function drop_tables($tables) { @@ -891,8 +891,8 @@ if (!defined('Adminer\DRIVER')) { } /** Move tables to other schema - * @param array - * @param array + * @param list + * @param list * @param string * @return bool */ @@ -921,8 +921,8 @@ if (!defined('Adminer\DRIVER')) { } /** Copy tables to other schema - * @param array - * @param array + * @param list + * @param list * @param string * @return bool */ @@ -1073,7 +1073,7 @@ if (!defined('Adminer\DRIVER')) { /** Get approximate number of rows * @param array - * @param array + * @param list * @return int or null if approximate number can't be retrieved */ function found_rows($table_status, $where) { diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index dc1be09c..9d9f984c 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -467,11 +467,11 @@ if (isset($_GET["sqlite"])) { /** Recreate table * @param string original name * @param string new name - * @param array [process_field()], empty to preserve - * @param array [$original => idf_escape($new_column)], empty to preserve + * @param list> [process_field()], empty to preserve + * @param string[] [$original => idf_escape($new_column)], empty to preserve * @param string [format_foreign_key()], empty to preserve * @param int set auto_increment to this value, 0 to preserve - * @param array [[$type, $name, $columns]], empty to preserve + * @param array[] [[$type, $name, $columns]], empty to preserve * @param string CHECK constraint to drop * @param string CHECK constraint to add * @return bool diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 98ca1439..35331a97 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -227,8 +227,8 @@ class Adminer { } /** Print backward keys for row - * @param array result of $this->backwardKeys() - * @param array + * @param array[] result of $this->backwardKeys() + * @param string[] * @return null */ function backwardKeysPrint($backwardKeys, $row) { @@ -277,8 +277,8 @@ class Adminer { } /** Get descriptions of selected data - * @param array all data to print - * @param array + * @param list all data to print + * @param array[] * @return list */ function rowDescriptions($rows, $foreignKeys) { @@ -297,7 +297,7 @@ class Adminer { * @param string HTML-escaped value to print * @param string link to foreign key * @param array single field returned from fields() - * @param array original value before applying editVal() and escaping + * @param string original value before applying editVal() and escaping * @return string */ function selectVal($val, $link, $field, $original) { @@ -322,7 +322,7 @@ class Adminer { } /** Print table structure in tabular format - * @param array data about individual fields + * @param array[] data about individual fields * @param array * @return null */ @@ -354,7 +354,7 @@ class Adminer { } /** Print list of indexes on table in tabular format - * @param array data about all indexes on a table + * @param array[] data about all indexes on a table * @return null */ function tableIndexesPrint($indexes) { @@ -374,8 +374,8 @@ class Adminer { } /** Print columns box in select - * @param array result of selectColumnsProcess()[0] - * @param array selectable columns + * @param list result of selectColumnsProcess()[0] + * @param string[] selectable columns * @return null */ function selectColumnsPrint($select, $columns) { @@ -401,9 +401,9 @@ class Adminer { } /** Print search box in select - * @param array result of selectSearchProcess() - * @param array selectable columns - * @param array + * @param list result of selectSearchProcess() + * @param string[] selectable columns + * @param array[] * @return null */ function selectSearchPrint($where, $columns, $indexes) { @@ -437,9 +437,9 @@ class Adminer { } /** Print order box in select - * @param array result of selectOrderProcess() - * @param array selectable columns - * @param array + * @param list result of selectOrderProcess() + * @param string[] selectable columns + * @param array[] * @return null */ function selectOrderPrint($order, $columns, $indexes) { @@ -481,7 +481,7 @@ class Adminer { } /** Print action box in select - * @param array + * @param array[] * @return null */ function selectActionPrint($indexes) { @@ -522,16 +522,16 @@ class Adminer { } /** Print extra text in the end of a select form - * @param array fields holding e-mails - * @param array selectable columns + * @param string[] fields holding e-mails + * @param string[] selectable columns * @return null */ function selectEmailPrint($emailFields, $columns) { } /** Process columns box in select - * @param array selectable columns - * @param array + * @param string[] selectable columns + * @param array[] * @return list> [[select_expressions], [group_expressions]] */ function selectColumnsProcess($columns, $indexes) { @@ -550,8 +550,8 @@ class Adminer { } /** Process search box in select - * @param array - * @param array + * @param array[] + * @param array[] * @return list expressions to join by AND */ function selectSearchProcess($fields, $indexes) { @@ -604,8 +604,8 @@ class Adminer { } /** Process order box in select - * @param array - * @param array + * @param array[] + * @param array[] * @return list expressions to join by comma */ function selectOrderProcess($fields, $indexes) { @@ -635,8 +635,8 @@ class Adminer { } /** Process extras in select form - * @param array AND conditions - * @param array + * @param string[] AND conditions + * @param array[] * @return bool true if processed, false to process other parts of form */ function selectEmailProcess($where, $foreignKeys) { @@ -644,10 +644,10 @@ class Adminer { } /** Build SQL query used in select - * @param array result of selectColumnsProcess()[0] - * @param array result of selectSearchProcess() - * @param array result of selectColumnsProcess()[1] - * @param array result of selectOrderProcess() + * @param list result of selectColumnsProcess()[0] + * @param list result of selectSearchProcess() + * @param list result of selectColumnsProcess()[1] + * @param list result of selectOrderProcess() * @param int result of selectLimitProcess() * @param int index of page starting at zero * @return string empty string to use default query @@ -689,7 +689,7 @@ class Adminer { /** Print before edit form * @param string - * @param array + * @param array[] * @param mixed * @param bool * @return null @@ -1051,7 +1051,7 @@ class Adminer { } /** Set up syntax highlight for code and