Files
adminer/plugins/table-indexes-structure.php
Jakub Vrana 2ee325183b 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<string> means an array of strings with sequential integer keys starting at 0
list<string>[] means an arbitrary array of string lists
list<string[]> 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
2025-03-25 14:31:27 +01:00

34 lines
1.2 KiB
PHP

<?php
/** Expanded table indexes structure output
* @link https://www.adminer.org/plugins/#use
* @author Matthew Gamble, https://www.matthewgamble.net/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerTableIndexesStructure {
/** Print table structure in tabular format
* @param array[] data about all indexes on a table
* @return bool
*/
function tableIndexesPrint($indexes) {
echo "<table>\n";
echo "<thead><tr><th>" . Adminer\lang('Name') . "<th>" . Adminer\lang('Type') . "<th>" . Adminer\lang('Columns') . "</thead>\n";
foreach ($indexes as $name => $index) {
echo "<tr><th>" . Adminer\h($name) . "<td>" . $index['type'];
ksort($index["columns"]); // enforce correct columns order
$print = array();
foreach ($index["columns"] as $key => $val) {
$print[] = "<i>" . Adminer\h($val) . "</i>"
. ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
. ($index["descs"][$key] ? " DESC" : "")
;
}
echo "<td>" . implode(", ", $print) . "\n";
}
echo "</table>\n";
return true;
}
}