Typos and a few type hints.

This commit is contained in:
Markus Birth 2022-02-13 16:16:18 +01:00
parent 50c89e2bad
commit 12e9df52de
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
4 changed files with 18 additions and 22 deletions

View File

@ -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);

View File

@ -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':

View File

@ -363,7 +363,7 @@ abstract class DbAbstract
*
* @return boolean Whether the database could support utf8mb4
*/
public function isUtf8mb4Ready()
public function isUtf8mb4Ready(): bool
{
return false;
}

View File

@ -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;