]> git.joonet.de Git - adminer.git/commitdiff
Doc-comments: Use array shapes in @return
authorJakub Vrana <jakub@vrana.cz>
Tue, 25 Mar 2025 14:08:13 +0000 (15:08 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 25 Mar 2025 14:08:13 +0000 (15:08 +0100)
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

adminer/drivers/mysql.inc.php
adminer/include/adminer.inc.php
adminer/include/editing.inc.php
adminer/include/functions.inc.php

index fb4873691117ef26558a9be95ebe95b7db3bc495..ef0c6a74ae29c4da47c50ef1c48acbe06209ef2b 100644 (file)
@@ -549,7 +549,7 @@ if (!defined('Adminer\DRIVER')) {
        /** Get table status
        * @param string
        * @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) {
                $return = array();
@@ -596,7 +596,7 @@ if (!defined('Adminer\DRIVER')) {
 
        /** Get information about fields
        * @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) {
                global $connection;
@@ -652,7 +652,7 @@ if (!defined('Adminer\DRIVER')) {
        /** Get table indexes
        * @param string
        * @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) {
                $return = array();
@@ -668,7 +668,7 @@ if (!defined('Adminer\DRIVER')) {
 
        /** Get foreign keys in table
        * @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) {
                global $driver;
@@ -700,7 +700,7 @@ if (!defined('Adminer\DRIVER')) {
 
        /** Get view SELECT
        * @param string
-       * @return array ["select" => ]
+       * @return array{select:string}
        */
        function view($name) {
                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
        * @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) {
                if ($name == "") {
@@ -971,7 +971,7 @@ if (!defined('Adminer\DRIVER')) {
 
        /** Get defined triggers
        * @param string
-       * @return array[] [$name => [$timing, $event]]
+       * @return array{string, string}[]4
        */
        function triggers($table) {
                $return = array();
@@ -982,7 +982,7 @@ if (!defined('Adminer\DRIVER')) {
        }
 
        /** Get trigger options
-       * @return list<string>[] ["Timing" => [], "Event" => [], "Type" => []]
+       * @return array{Timing: list<string>, Event: list<string>, Type: list<string>}
        */
        function trigger_options() {
                return array(
@@ -995,7 +995,7 @@ if (!defined('Adminer\DRIVER')) {
        /** Get information about stored routine
        * @param string
        * @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) {
                global $driver;
index 4c5923bef09ecfeb3367de5cb4145fbbca05a4d8..dc1b70971ff992126a1a350188e532707b37172c 100644 (file)
@@ -15,14 +15,14 @@ class Adminer {
        }
 
        /** Connection parameters
-       * @return array [$server, $username, $password]
+       * @return array{string, string, string}
        */
        function credentials() {
                return array(SERVER, $_GET["username"], get_password());
        }
 
        /** Get SSL connection options
-       * @return array ["key" => filename, "cert" => filename, "ca" => filename] or null
+       * @return string[] or null
        */
        function connectSsl() {
        }
@@ -220,7 +220,7 @@ class Adminer {
        /** Find backward keys for table
        * @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) {
                return array();
index 3d1e9bf5684c90a4d5b280a5e4717af209c14382..8ef7277267dc8add2d80dbe5658910b545d8d101 100644 (file)
@@ -218,7 +218,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array(), $extra_ty
 
 /** Get partition info
 * @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) {
        global $connection;
index b1a2647d533f24d5bb405f29f23fbe2f6611b609..0af3f0702db3e0d97de86c5d531e494070548a3a 100644 (file)
@@ -701,7 +701,7 @@ function friendly_url($val) {
 /** Get status of a single table and fall back to name on error
 * @param string
 * @param bool
-* @return array[]
+* @return array[] same as table_status()
 */
 function table_status1($table, $fast = false) {
        $return = table_status($table, $fast);
@@ -724,7 +724,7 @@ function column_foreign_keys($table) {
 }
 
 /** Compute fields() from $_POST edit data
-* @return array[]
+* @return array[] same as fields()
 */
 function fields_from_edit() {
        global $driver;