mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
Doc-comments: Move param types to declaration
This commit is contained in:
@@ -12,7 +12,7 @@ class AdminerDatabaseHide {
|
||||
/**
|
||||
* @param list<string> $disabled case insensitive database names in values
|
||||
*/
|
||||
function __construct($disabled) {
|
||||
function __construct(array $disabled) {
|
||||
$this->disabled = array_map('strtolower', $disabled);
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ class AdminerDesigns {
|
||||
/**
|
||||
* @param list<string> $designs URL in key, name in value
|
||||
*/
|
||||
function __construct($designs) {
|
||||
function __construct(array $designs) {
|
||||
$this->designs = $designs;
|
||||
}
|
||||
|
||||
|
@@ -13,12 +13,9 @@ if (isset($_GET["elastic"])) {
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param ?array $content
|
||||
* @param string $method
|
||||
* @return array|false
|
||||
*/
|
||||
function rootQuery($path, array $content = null, $method = 'GET') {
|
||||
function rootQuery(string $path, ?array $content = null, string $method = 'GET') {
|
||||
$file = @file_get_contents("$this->url/" . ltrim($path, '/'), false, stream_context_create(array('http' => array(
|
||||
'method' => $method,
|
||||
'content' => $content !== null ? json_encode($content) : null,
|
||||
@@ -53,12 +50,9 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
|
||||
/** Perform query relative to actual selected DB
|
||||
* @param string $path
|
||||
* @param ?array $content
|
||||
* @param string $method
|
||||
* @return array|false
|
||||
*/
|
||||
function query($path, array $content = null, $method = 'GET') {
|
||||
function query(string $path, ?array $content = null, string $method = 'GET') {
|
||||
// Support for global search through all tables
|
||||
if ($path != "" && $path[0] == "S" && preg_match('/SELECT 1 FROM ([^ ]+) WHERE (.+) LIMIT ([0-9]+)/', $path, $matches)) {
|
||||
$driver = driver();
|
||||
@@ -72,12 +66,9 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $server
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*/
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password) {
|
||||
preg_match('~^(https?://)?(.*)~', $server, $match);
|
||||
$this->url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]";
|
||||
$return = $this->query('');
|
||||
@@ -531,10 +522,9 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
|
||||
/** Alter type
|
||||
* @param array $table
|
||||
* @return mixed
|
||||
*/
|
||||
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
||||
function alter_table(array $table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
||||
$properties = array();
|
||||
foreach ($fields as $f) {
|
||||
$field_name = trim($f[1][0]);
|
||||
@@ -555,7 +545,7 @@ if (isset($_GET["elastic"])) {
|
||||
* @param list<string> $tables
|
||||
* @return bool
|
||||
*/
|
||||
function drop_tables($tables) {
|
||||
function drop_tables(array $tables) {
|
||||
$return = true;
|
||||
foreach ($tables as $table) { //! convert to bulk api
|
||||
$return = $return && connection()->query(urlencode($table), null, 'DELETE');
|
||||
|
@@ -15,7 +15,7 @@ class AdminerEditCalendar {
|
||||
* @param string $prepend text to append before first calendar usage
|
||||
* @param string $langPath path to language file, %s stands for language code
|
||||
*/
|
||||
function __construct($prepend = null, $langPath = "jquery-ui/i18n/jquery.ui.datepicker-%s.js") {
|
||||
function __construct(string $prepend = null, string $langPath = "jquery-ui/i18n/jquery.ui.datepicker-%s.js") {
|
||||
$this->prepend = $prepend;
|
||||
$this->langPath = $langPath;
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class AdminerEmailTable {
|
||||
* @param string $subject quoted column name
|
||||
* @param string $message quoted column name
|
||||
*/
|
||||
function __construct($table = "email", $id = "id", $title = "subject", $subject = "subject", $message = "message") {
|
||||
function __construct(string $table = "email", string $id = "id", string $title = "subject", string $subject = "subject", string $message = "message") {
|
||||
$this->table = $table;
|
||||
$this->id = $id;
|
||||
$this->title = $title;
|
||||
|
@@ -15,7 +15,7 @@ class AdminerFileUpload {
|
||||
* @param string $displayPath prefix for displaying data, null stands for $uploadPath
|
||||
* @param string $extensions regular expression with allowed file extensions
|
||||
*/
|
||||
function __construct($uploadPath = "../static/data/", $displayPath = null, $extensions = "[a-zA-Z0-9]+") {
|
||||
function __construct(string $uploadPath = "../static/data/", string $displayPath = null, string $extensions = "[a-zA-Z0-9]+") {
|
||||
$this->uploadPath = $uploadPath;
|
||||
$this->displayPath = ($displayPath !== null ? $displayPath : $uploadPath);
|
||||
$this->extensions = $extensions;
|
||||
|
@@ -12,7 +12,7 @@ class AdminerFrames {
|
||||
/**
|
||||
* @param bool $sameOrigin allow running from the same origin only
|
||||
*/
|
||||
function __construct($sameOrigin = false) {
|
||||
function __construct(bool $sameOrigin = false) {
|
||||
$this->sameOrigin = $sameOrigin;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ class AdminerLoginIp {
|
||||
* @param list<string> $ips IP address prefixes
|
||||
* @param list<string> $forwarded_for X-Forwarded-For prefixes if IP address matches, empty array means anything
|
||||
*/
|
||||
function __construct($ips, $forwarded_for = array()) {
|
||||
function __construct(array $ips, array $forwarded_for = array()) {
|
||||
$this->ips = $ips;
|
||||
$this->forwarded_for= $forwarded_for;
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ class AdminerLoginOtp {
|
||||
/**
|
||||
* @param string $secret decoded secret, e.g. base64_decode("SECRET")
|
||||
*/
|
||||
function __construct($secret) {
|
||||
function __construct(string $secret) {
|
||||
$this->secret = $secret;
|
||||
if ($_POST["auth"]) {
|
||||
$_SESSION["otp"] = (string) $_POST["auth"]["otp"];
|
||||
|
@@ -12,7 +12,7 @@ class AdminerLoginPasswordLess {
|
||||
/** Set allowed password
|
||||
* @param string $password_hash result of password_hash
|
||||
*/
|
||||
function __construct($password_hash) {
|
||||
function __construct(string $password_hash) {
|
||||
$this->password_hash = $password_hash;
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ class AdminerLoginServers {
|
||||
/** Set supported servers
|
||||
* @param array{server:string, driver:string}[] $servers [$description => ["server" => , "driver" => "server|pgsql|sqlite|..."]]
|
||||
*/
|
||||
function __construct($servers) {
|
||||
function __construct(array $servers) {
|
||||
$this->servers = $servers;
|
||||
if ($_POST["auth"]) {
|
||||
$key = $_POST["auth"]["server"];
|
||||
|
@@ -10,12 +10,11 @@ class AdminerLoginSsl {
|
||||
protected $ssl;
|
||||
|
||||
/**
|
||||
* @param array{ssl?:string, cert?:string, verify?:bool, mode?:string, Encrypt?:bool, TrustServerCertificate?:bool} $ssl
|
||||
* MySQL: ["key" => filename, "cert" => filename, "ca" => filename, "verify" => bool]
|
||||
* PostgresSQL: ["mode" => sslmode] (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLMODE)
|
||||
* MSSQL: ["Encrypt" => true, "TrustServerCertificate" => true] (https://learn.microsoft.com/en-us/sql/connect/php/connection-options)
|
||||
*/
|
||||
function __construct($ssl) {
|
||||
function __construct(array $ssl) {
|
||||
$this->ssl = $ssl;
|
||||
}
|
||||
|
||||
|
@@ -19,9 +19,8 @@ class AdminerLoginTable {
|
||||
protected $database;
|
||||
|
||||
/** Set database of login table
|
||||
* @param string $database
|
||||
*/
|
||||
function __construct($database) {
|
||||
function __construct(string $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ class AdminerMasterSlave {
|
||||
/**
|
||||
* @param string[] $masters [$slave => $master]
|
||||
*/
|
||||
function __construct($masters) {
|
||||
function __construct(array $masters) {
|
||||
$this->masters = $masters;
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ class AdminerSlugify {
|
||||
* @param string $from find these characters ...
|
||||
* @param string $to ... and replace them by these
|
||||
*/
|
||||
function __construct($from = 'áčďéěíňóřšťúůýž', $to = 'acdeeinorstuuyz') {
|
||||
function __construct(string $from = 'áčďéěíňóřšťúůýž', string $to = 'acdeeinorstuuyz') {
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ class AdminerSqlGemini {
|
||||
* @param string $apiKey Get API key at: https://aistudio.google.com/apikey
|
||||
* @param string $model Available models: https://ai.google.dev/gemini-api/docs/models#available-models
|
||||
*/
|
||||
function __construct($apiKey, $model = "gemini-2.0-flash") {
|
||||
function __construct(string $apiKey, string $model = "gemini-2.0-flash") {
|
||||
$this->apiKey = $apiKey;
|
||||
$this->model = $model;
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ class AdminerSqlLog {
|
||||
/**
|
||||
* @param string $filename defaults to "$database.sql"
|
||||
*/
|
||||
function __construct($filename = "") {
|
||||
function __construct(string $filename = "") {
|
||||
$this->filename = $filename;
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ class AdminerTableIndexesStructure {
|
||||
* @param Index[] $indexes data about all indexes on a table
|
||||
* @return bool
|
||||
*/
|
||||
function tableIndexesPrint($indexes) {
|
||||
function tableIndexesPrint(array $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) {
|
||||
|
@@ -12,7 +12,7 @@ class AdminerTableStructure {
|
||||
* @param Field[] $fields data about individual fields
|
||||
* @return bool
|
||||
*/
|
||||
function tableStructurePrint($fields, $tableStatus = null) {
|
||||
function tableStructurePrint(array $fields, $tableStatus = null) {
|
||||
echo "<div class='scrollable'>\n";
|
||||
echo "<table class='nowrap odds'>\n";
|
||||
echo "<thead><tr>"
|
||||
|
@@ -11,9 +11,8 @@ class AdminerTinymce {
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
function __construct($path = "tiny_mce/tiny_mce.js") {
|
||||
function __construct(string $path = "tiny_mce/tiny_mce.js") {
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user