From 12e9df52debdcad7f6b32ae4e3f0f3fed554b748 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Sun, 13 Feb 2022 16:16:18 +0100 Subject: [PATCH] Typos and a few type hints. --- include/db/db.inc.php | 6 ++--- include/lang.inc.php | 30 +++++++++------------ lib/Serendipity/Database/DbAbstract.php | 2 +- lib/Serendipity/Database/MysqliDatabase.php | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/include/db/db.inc.php b/include/db/db.inc.php index 4ec65612..ed805a33 100644 --- a/include/db/db.inc.php +++ b/include/db/db.inc.php @@ -82,7 +82,7 @@ function serendipity_db_begin_transaction() return $db->beginTransaction(); } -function serendipity_db_end_transaction($commit) +function serendipity_db_end_transaction(bool $commit) { global $serendipity; $db = DbFactory::createFromConfig($serendipity); @@ -96,7 +96,7 @@ function serendipity_db_in_sql($col, &$search_ids, $type = ' OR ') return $db->inSql($col, $search_ids, $type); } -function serendipity_db_escape_string($string) +function serendipity_db_escape_string(string $string): string { global $serendipity; $db = DbFactory::createFromConfig($serendipity); @@ -166,7 +166,7 @@ function serendipity_db_probe($hash, &$errs) return $db->probe($hash, $errs); } -function serendipity_utf8mb4_ready() +function serendipity_utf8mb4_ready(): bool { global $serendipity; $db = DbFactory::createFromConfig($serendipity); diff --git a/include/lang.inc.php b/include/lang.inc.php index 78e435b4..6f8c5ec0 100644 --- a/include/lang.inc.php +++ b/include/lang.inc.php @@ -60,17 +60,17 @@ if (!defined('serendipity_MB_LOADED') && defined('serendipity_LANG_LOADED')) { @mb_internal_encoding(LANG_CHARSET); } -/** - * Wrapper for multibyte string operations - * - * Multibyte string functions wrapper: - * strlen(), strpos(), strrpos(), strtolower(), strtoupper(), substr(), ucfirst() - * - * @access public - * @param mixed Any input array, dynamically evaluated for best emulation - * @return mixed - */ - function serendipity_mb() { + /** + * Wrapper for multibyte string operations + * + * Multibyte string functions wrapper: + * strlen(), strpos(), strrpos(), strtolower(), strtoupper(), substr(), ucfirst() + * + * @access public + * @param mixed Any input array, dynamically evaluated for best emulation + * @return mixed + */ + function serendipity_mb(string $func, ...$args) { static $mbstring = null; if (is_null($mbstring)) { @@ -82,18 +82,14 @@ if (!defined('serendipity_MB_LOADED') && defined('serendipity_LANG_LOADED')) { } } - $args = func_get_args(); - $func = $args[0]; - unset($args[0]); - switch($func) { case 'ucfirst': // there's no mb_ucfirst, so emulate it if ($mbstring === 2) { $enc = LANG_CHARSET; - return mb_strtoupper(mb_substr($args[1], 0, 1, $enc), $enc) . mb_substr($args[1], 1, mb_strlen($args[1], $enc), $enc); + return mb_strtoupper(mb_substr($args[0], 0, 1, $enc), $enc) . mb_substr($args[0], 1, mb_strlen($args[0], $enc), $enc); } else { - return ucfirst($args[1]); + return ucfirst($args[0]); } case 'strtolower': diff --git a/lib/Serendipity/Database/DbAbstract.php b/lib/Serendipity/Database/DbAbstract.php index 0af89ae8..f021ddbf 100644 --- a/lib/Serendipity/Database/DbAbstract.php +++ b/lib/Serendipity/Database/DbAbstract.php @@ -363,7 +363,7 @@ abstract class DbAbstract * * @return boolean Whether the database could support utf8mb4 */ - public function isUtf8mb4Ready() + public function isUtf8mb4Ready(): bool { return false; } diff --git a/lib/Serendipity/Database/MysqliDatabase.php b/lib/Serendipity/Database/MysqliDatabase.php index 29a988fb..e6a56379 100644 --- a/lib/Serendipity/Database/MysqliDatabase.php +++ b/lib/Serendipity/Database/MysqliDatabase.php @@ -328,7 +328,7 @@ class MysqliDatabase extends DbAbstract * * @return boolean Whether the database could support utf8mb4 */ - public function isUtf8mb4Ready() + public function isUtf8mb4Ready(): bool { $mysql_version = mysqli_get_server_info($this->db_conn); $maria = false;