1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-09 16:17:48 +02:00

Doc-comments: Use array shapes in @return

This uses https://phpstan.org/writing-php-code/phpdoc-types#array-shapes
I'm not going to do this in @param, it would be better to use https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
This commit is contained in:
Jakub Vrana
2025-03-25 15:08:13 +01:00
parent 4d2b5144b1
commit 01e2fe4234
4 changed files with 15 additions and 15 deletions

View File

@@ -549,7 +549,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get table status /** Get table status
* @param string * @param string
* @param bool return only "Name", "Engine" and "Comment" fields * @param bool return only "Name", "Engine" and "Comment" fields
* @return array[] [$name => ["Name" => , "Engine" => , "Comment" => , "Oid" => , "Rows" => , "Collation" => , "Auto_increment" => , "Data_length" => , "Index_length" => , "Data_free" => ]] or only inner array with $name * @return array{Name:string, Engine:string, Comment:string, Oid:int, Rows:int, Collation:string, Auto_increment:int, Data_length:int, Index_length:int, Data_free:int}[] or only inner array with $name
*/ */
function table_status($name = "", $fast = false) { function table_status($name = "", $fast = false) {
$return = array(); $return = array();
@@ -596,7 +596,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get information about fields /** Get information about fields
* @param string * @param string
* @return array[] [$name => ["field" =>, "full_type" =>, "type" =>, "length" =>, "unsigned" =>, "default" =>, "null" =>, "auto_increment" =>, "on_update" =>, "collation" =>, "privileges" =>, "comment" =>, "primary" =>, "generated" =>]] * @return array{field:string, full_type:string, type:string, length:int, unsigned:string, default:string, null:bool, auto_increment:bool, on_update:string, collation:string, privileges:int[], comment:string, primary:bool, generated:string}[]
*/ */
function fields($table) { function fields($table) {
global $connection; global $connection;
@@ -652,7 +652,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get table indexes /** Get table indexes
* @param string * @param string
* @param string Db to use * @param string Db to use
* @return array[] [$key_name => ["type" => , "columns" => [], "lengths" => [], "descs" => []]] * @return array{type:string, columns:list<string>, lengths:list<int>, descs:list<bool>}[]
*/ */
function indexes($table, $connection2 = null) { function indexes($table, $connection2 = null) {
$return = array(); $return = array();
@@ -668,7 +668,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get foreign keys in table /** Get foreign keys in table
* @param string * @param string
* @return array[] [$name => ["db" => , "ns" => , "table" => , "source" => [], "target" => [], "on_delete" => , "on_update" => ]] * @return array{db:string, ns:string, table:string, source:list<string>, target:list<string>, on_delete:string, on_update:string}[]
*/ */
function foreign_keys($table) { function foreign_keys($table) {
global $driver; global $driver;
@@ -700,7 +700,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get view SELECT /** Get view SELECT
* @param string * @param string
* @return array ["select" => ] * @return array{select:string}
*/ */
function view($name) { function view($name) {
return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)*\s+AS\s+~isU', '', get_val("SHOW CREATE VIEW " . table($name), 1))); return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)*\s+AS\s+~isU', '', get_val("SHOW CREATE VIEW " . table($name), 1)));
@@ -959,7 +959,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get information about trigger /** Get information about trigger
* @param string trigger name * @param string trigger name
* @return array ["Trigger" => , "Timing" => , "Event" => , "Of" => , "Type" => , "Statement" => ] * @return array{Trigger:string, Timing:string, Event:string, Of:string, Type:string, Statement:string}
*/ */
function trigger($name) { function trigger($name) {
if ($name == "") { if ($name == "") {
@@ -971,7 +971,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get defined triggers /** Get defined triggers
* @param string * @param string
* @return array[] [$name => [$timing, $event]] * @return array{string, string}[]4
*/ */
function triggers($table) { function triggers($table) {
$return = array(); $return = array();
@@ -982,7 +982,7 @@ if (!defined('Adminer\DRIVER')) {
} }
/** Get trigger options /** Get trigger options
* @return list<string>[] ["Timing" => [], "Event" => [], "Type" => []] * @return array{Timing: list<string>, Event: list<string>, Type: list<string>}
*/ */
function trigger_options() { function trigger_options() {
return array( return array(
@@ -995,7 +995,7 @@ if (!defined('Adminer\DRIVER')) {
/** Get information about stored routine /** Get information about stored routine
* @param string * @param string
* @param string "FUNCTION" or "PROCEDURE" * @param string "FUNCTION" or "PROCEDURE"
* @return array ["fields" => ["field" => , "type" => , "length" => , "unsigned" => , "inout" => , "collation" => ], "returns" => , "definition" => , "language" => ] * @return array{fields:list<array{field:string, type:string, length:string, unsigned:string, null:bool, full_type:string, inout:string, collation:string}>, comment:string, returns:array, definition:string, language:string}
*/ */
function routine($name, $type) { function routine($name, $type) {
global $driver; global $driver;

View File

@@ -15,14 +15,14 @@ class Adminer {
} }
/** Connection parameters /** Connection parameters
* @return array [$server, $username, $password] * @return array{string, string, string}
*/ */
function credentials() { function credentials() {
return array(SERVER, $_GET["username"], get_password()); return array(SERVER, $_GET["username"], get_password());
} }
/** Get SSL connection options /** Get SSL connection options
* @return array ["key" => filename, "cert" => filename, "ca" => filename] or null * @return string[] or null
*/ */
function connectSsl() { function connectSsl() {
} }
@@ -220,7 +220,7 @@ class Adminer {
/** Find backward keys for table /** Find backward keys for table
* @param string * @param string
* @param string * @param string
* @return array[] $return[$target_table]["keys"][$key_name][$target_column] = $source_column; $return[$target_table]["name"] = $this->tableName($target_table); * @return array{keys:string[][], name:string}[]
*/ */
function backwardKeys($table, $tableName) { function backwardKeys($table, $tableName) {
return array(); return array();

View File

@@ -218,7 +218,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array(), $extra_ty
/** Get partition info /** Get partition info
* @param string * @param string
* @return array * @return array{partition_by:string, partition:string, partitions:string, partition_names:list<string>, partition_values:list<string>}
*/ */
function get_partitions_info($table) { function get_partitions_info($table) {
global $connection; global $connection;

View File

@@ -701,7 +701,7 @@ function friendly_url($val) {
/** Get status of a single table and fall back to name on error /** Get status of a single table and fall back to name on error
* @param string * @param string
* @param bool * @param bool
* @return array[] * @return array[] same as table_status()
*/ */
function table_status1($table, $fast = false) { function table_status1($table, $fast = false) {
$return = table_status($table, $fast); $return = table_status($table, $fast);
@@ -724,7 +724,7 @@ function column_foreign_keys($table) {
} }
/** Compute fields() from $_POST edit data /** Compute fields() from $_POST edit data
* @return array[] * @return array[] same as fields()
*/ */
function fields_from_edit() { function fields_from_edit() {
global $driver; global $driver;