mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 13:24:01 -07:00
Return type hint can be used.
This commit is contained in:
parent
b43b0d359d
commit
54a1c9142f
27 changed files with 100 additions and 100 deletions
2
ajax.php
2
ajax.php
|
@ -247,7 +247,7 @@ class ajax_common
|
|||
/**
|
||||
* OB Handler
|
||||
*/
|
||||
public function ob_handler($contents)
|
||||
public function ob_handler($contents): string
|
||||
{
|
||||
if (DBG_USER) {
|
||||
if ($contents) {
|
||||
|
|
|
@ -152,7 +152,7 @@ class TorrentFileList
|
|||
}
|
||||
}
|
||||
|
||||
private function build_file_item($name, $length)
|
||||
private function build_file_item($name, $length): string
|
||||
{
|
||||
global $bb_cfg, $images, $lang;
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ class attach_parent
|
|||
* Handle all modes... (intern)
|
||||
* @private
|
||||
*/
|
||||
public function handle_attachments($mode)
|
||||
public function handle_attachments($mode): bool
|
||||
{
|
||||
global $is_auth, $attach_config, $refresh, $post_id, $submit, $preview, $error, $error_msg, $lang;
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ class bbcode
|
|||
* bbcode2html
|
||||
* $text должен быть уже обработан htmlCHR($text, false, ENT_NOQUOTES);
|
||||
*/
|
||||
public function bbcode2html($text)
|
||||
public function bbcode2html($text): string
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -636,7 +636,7 @@ class bbcode
|
|||
/**
|
||||
* [code] callback
|
||||
*/
|
||||
public function code_callback($m)
|
||||
public function code_callback($m): string
|
||||
{
|
||||
$code = trim($m[2]);
|
||||
$code = str_replace(' ', ' ', $code);
|
||||
|
@ -649,7 +649,7 @@ class bbcode
|
|||
/**
|
||||
* [url] callback
|
||||
*/
|
||||
public function url_callback($m)
|
||||
public function url_callback($m): string
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -672,7 +672,7 @@ class bbcode
|
|||
/**
|
||||
* Escape tags inside tiltes in [quote="tilte"]
|
||||
*/
|
||||
public function escape_tiltes_callback($m)
|
||||
public function escape_tiltes_callback($m): string
|
||||
{
|
||||
$tilte = substr($m[3], 0, 250);
|
||||
$tilte = str_replace(array('[', ']', ':', ')', '"'), array('[', ']', ':', ')', '"'), $tilte);
|
||||
|
@ -714,7 +714,7 @@ class bbcode
|
|||
/**
|
||||
* make_url_clickable_callback
|
||||
*/
|
||||
public function make_url_clickable_callback($m)
|
||||
public function make_url_clickable_callback($m): string
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -762,7 +762,7 @@ class bbcode
|
|||
/**
|
||||
* tidy
|
||||
*/
|
||||
public function tidy($text)
|
||||
public function tidy($text): string
|
||||
{
|
||||
$text = tidy_repair_string($text, $this->tidy_cfg, 'utf8');
|
||||
return $text;
|
||||
|
@ -808,7 +808,7 @@ class words_rate
|
|||
/**
|
||||
* возвращает "показатель полезности" сообщения используемый для автоудаления коротких сообщений типа "спасибо", "круто" и т.д.
|
||||
*/
|
||||
public function get_words_rate($text)
|
||||
public function get_words_rate($text): int
|
||||
{
|
||||
$this->words_rate = 127; // максимальное значение по умолчанию
|
||||
$this->deleted_words = array();
|
||||
|
|
2
library/includes/cache/apc.php
vendored
2
library/includes/cache/apc.php
vendored
|
@ -79,7 +79,7 @@ class cache_apc extends cache_common
|
|||
return apc_clear_cache();
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
public function is_installed(): bool
|
||||
{
|
||||
return function_exists('apc_fetch');
|
||||
}
|
||||
|
|
6
library/includes/cache/common.php
vendored
6
library/includes/cache/common.php
vendored
|
@ -45,7 +45,7 @@ class cache_common
|
|||
/**
|
||||
* Store value of variable
|
||||
*/
|
||||
public function set($name, $value, $ttl = 604800)
|
||||
public function set($name, $value, $ttl = 604800): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class cache_common
|
|||
/**
|
||||
* Remove variable
|
||||
*/
|
||||
public function rm($name = '')
|
||||
public function rm($name = ''): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class cache_common
|
|||
}
|
||||
}
|
||||
|
||||
public function debug_find_source($mode = '')
|
||||
public function debug_find_source($mode = ''): string
|
||||
{
|
||||
foreach (debug_backtrace() as $trace) {
|
||||
if ($trace['file'] !== __FILE__) {
|
||||
|
|
6
library/includes/cache/file.php
vendored
6
library/includes/cache/file.php
vendored
|
@ -58,7 +58,7 @@ class cache_file extends cache_common
|
|||
return (!empty($filecache['value'])) ? $filecache['value'] : false;
|
||||
}
|
||||
|
||||
public function set($name, $value, $ttl = 86400)
|
||||
public function set($name, $value, $ttl = 86400): bool
|
||||
{
|
||||
if (!function_exists('var_export')) {
|
||||
return false;
|
||||
|
@ -86,7 +86,7 @@ class cache_file extends cache_common
|
|||
return (bool)file_write($filecache, $filename, false, true, true);
|
||||
}
|
||||
|
||||
public function rm($name = '')
|
||||
public function rm($name = ''): bool
|
||||
{
|
||||
$clear = false;
|
||||
if ($name) {
|
||||
|
@ -119,7 +119,7 @@ class cache_file extends cache_common
|
|||
return $clear;
|
||||
}
|
||||
|
||||
public function gc($expire_time = TIMENOW)
|
||||
public function gc($expire_time = TIMENOW): bool
|
||||
{
|
||||
$clear = false;
|
||||
|
||||
|
|
4
library/includes/cache/memcache.php
vendored
4
library/includes/cache/memcache.php
vendored
|
@ -86,7 +86,7 @@ class cache_memcache extends cache_common
|
|||
return ($this->connected) ? $this->memcache->get($this->prefix . $name) : false;
|
||||
}
|
||||
|
||||
public function set($name, $value, $ttl = 0)
|
||||
public function set($name, $value, $ttl = 0): bool
|
||||
{
|
||||
if (!$this->connected) {
|
||||
$this->connect();
|
||||
|
@ -120,7 +120,7 @@ class cache_memcache extends cache_common
|
|||
return ($this->connected) ? $this->memcache->flush() : false;
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
public function is_installed(): bool
|
||||
{
|
||||
return class_exists('Memcache');
|
||||
}
|
||||
|
|
2
library/includes/cache/redis.php
vendored
2
library/includes/cache/redis.php
vendored
|
@ -123,7 +123,7 @@ class cache_redis extends cache_common
|
|||
return ($this->connected) ? $this->redis->flushdb() : false;
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
public function is_installed(): bool
|
||||
{
|
||||
return class_exists('Redis');
|
||||
}
|
||||
|
|
20
library/includes/cache/sqlite.php
vendored
20
library/includes/cache/sqlite.php
vendored
|
@ -95,7 +95,7 @@ class cache_sqlite extends cache_common
|
|||
return isset($cached_items[$name]) ? $cached_items[$name] : false;
|
||||
}
|
||||
|
||||
public function set($name, $value, $ttl = 604800)
|
||||
public function set($name, $value, $ttl = 604800): bool
|
||||
{
|
||||
$this->db->shard($this->prefix . $name);
|
||||
$name_sql = SQLite3::escapeString($this->prefix . $name);
|
||||
|
@ -106,7 +106,7 @@ class cache_sqlite extends cache_common
|
|||
return (bool)$result;
|
||||
}
|
||||
|
||||
public function rm($name = '')
|
||||
public function rm($name = ''): bool
|
||||
{
|
||||
if ($name) {
|
||||
$this->db->shard($this->prefix . $name);
|
||||
|
@ -117,7 +117,7 @@ class cache_sqlite extends cache_common
|
|||
return (bool)$result;
|
||||
}
|
||||
|
||||
public function gc($expire_time = TIMENOW)
|
||||
public function gc($expire_time = TIMENOW): int
|
||||
{
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
|
||||
return ($result) ? $this->db->changes() : 0;
|
||||
|
@ -238,13 +238,13 @@ class sqlite_common extends cache_common
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function fetch_row($query)
|
||||
public function fetch_row($query): bool
|
||||
{
|
||||
$result = $this->query($query);
|
||||
return is_resource($result) ? $result->fetchArray(SQLITE3_ASSOC) : false;
|
||||
}
|
||||
|
||||
public function fetch_rowset($query)
|
||||
public function fetch_rowset($query): array
|
||||
{
|
||||
$result = $this->query($query);
|
||||
$rowset = array();
|
||||
|
@ -254,22 +254,22 @@ class sqlite_common extends cache_common
|
|||
return $rowset;
|
||||
}
|
||||
|
||||
public function changes()
|
||||
public function changes(): int
|
||||
{
|
||||
return is_resource($this->dbh) ? $this->dbh->changes() : 0;
|
||||
}
|
||||
|
||||
public function escape($str)
|
||||
public function escape($str): string
|
||||
{
|
||||
return SQLite3::escapeString($str);
|
||||
}
|
||||
|
||||
public function get_error_msg()
|
||||
public function get_error_msg(): string
|
||||
{
|
||||
return 'SQLite error #' . ($err_code = $this->dbh->lastErrorCode()) . ': ' . $this->dbh->lastErrorMsg();
|
||||
}
|
||||
|
||||
public function rm($name = '')
|
||||
public function rm($name = ''): bool
|
||||
{
|
||||
if ($name) {
|
||||
$this->db->shard($this->prefix . $name);
|
||||
|
@ -280,7 +280,7 @@ class sqlite_common extends cache_common
|
|||
return (bool)$result;
|
||||
}
|
||||
|
||||
public function gc($expire_time = TIMENOW)
|
||||
public function gc($expire_time = TIMENOW): int
|
||||
{
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
|
||||
return ($result) ? sqlite_changes($this->db->dbh) : 0;
|
||||
|
|
4
library/includes/cache/xcache.php
vendored
4
library/includes/cache/xcache.php
vendored
|
@ -53,7 +53,7 @@ class cache_xcache extends cache_common
|
|||
return xcache_get($this->prefix . $name);
|
||||
}
|
||||
|
||||
public function set($name, $value, $ttl = 0)
|
||||
public function set($name, $value, $ttl = 0): bool
|
||||
{
|
||||
$this->cur_query = "cache->set('$name')";
|
||||
$this->debug('start');
|
||||
|
@ -81,7 +81,7 @@ class cache_xcache extends cache_common
|
|||
return;
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
public function is_installed(): bool
|
||||
{
|
||||
return function_exists('xcache_get');
|
||||
}
|
||||
|
|
|
@ -2926,7 +2926,7 @@ class Text_LangCorrect
|
|||
~sxSX', array($this, '_entry'), $s);
|
||||
}
|
||||
|
||||
private function _entry(array &$a)
|
||||
private function _entry(array &$a): string
|
||||
{
|
||||
$entry =& $a[0];
|
||||
$s = strtr($entry, $this->table[0]);
|
||||
|
@ -3079,13 +3079,13 @@ class Text_LangCorrect
|
|||
return $word;
|
||||
}
|
||||
|
||||
private function _strtr(array $a)
|
||||
private function _strtr(array $a): string
|
||||
{
|
||||
$word =& $a[0];
|
||||
return strtr($word, $this->is_flip ? $this->table_flip[$this->method] : $this->table[$this->method]);
|
||||
}
|
||||
|
||||
private function _is_mixed($word)
|
||||
private function _is_mixed($word): bool
|
||||
{
|
||||
return preg_match('/(?:' . $this->en . ')/sxSX', $word) &&
|
||||
preg_match('/(?:' . $this->tt_f . ')/sxSX', $word);
|
||||
|
@ -3135,7 +3135,7 @@ class Text_LangCorrect
|
|||
}
|
||||
|
||||
#анализ на основе N-грамм русского и английского языка
|
||||
private function _bigram_exists($word, $lang)
|
||||
private function _bigram_exists($word, $lang): bool
|
||||
{
|
||||
$word = ($lang === 'en') ? strtolower($word) : UTF8::lowercase($word);
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ class emailer
|
|||
$this->extra_headers .= trim($headers) . "\n";
|
||||
}
|
||||
|
||||
public function use_template($template_file, $template_lang = '')
|
||||
public function use_template($template_file, $template_lang = ''): bool
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -150,7 +150,7 @@ class emailer
|
|||
}
|
||||
|
||||
// Send the mail out to the recipients set previously in var $this->address
|
||||
public function send($email_format = 'text')
|
||||
public function send($email_format = 'text'): bool
|
||||
{
|
||||
global $bb_cfg, $userdata;
|
||||
|
||||
|
@ -221,7 +221,7 @@ class emailer
|
|||
return true;
|
||||
}
|
||||
|
||||
public function encode($str)
|
||||
public function encode($str): string
|
||||
{
|
||||
if ($this->encoding == '') {
|
||||
return $str;
|
||||
|
|
|
@ -84,7 +84,7 @@ class ReflectionTypeHint
|
|||
{
|
||||
}
|
||||
|
||||
public static function isValid()
|
||||
public static function isValid(): bool
|
||||
{
|
||||
if (!assert_options(ASSERT_ACTIVE)) {
|
||||
return true;
|
||||
|
@ -152,7 +152,7 @@ class ReflectionTypeHint
|
|||
* @param int|null $return_frame
|
||||
* @return array
|
||||
*/
|
||||
public static function debugBacktrace($re_ignore = null, $return_frame = null)
|
||||
public static function debugBacktrace($re_ignore = null, $return_frame = null): array
|
||||
{
|
||||
$trace = debug_backtrace();
|
||||
|
||||
|
@ -206,7 +206,7 @@ class ReflectionTypeHint
|
|||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkValueTypes(array $types, $value)
|
||||
public static function checkValueTypes(array $types, $value): bool
|
||||
{
|
||||
foreach ($types as $type) {
|
||||
$type = strtolower($type);
|
||||
|
|
|
@ -41,7 +41,7 @@ class sitemap
|
|||
$this->home = make_url();
|
||||
}
|
||||
|
||||
public function build_map()
|
||||
public function build_map(): string
|
||||
{
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_static();
|
||||
|
@ -52,7 +52,7 @@ class sitemap
|
|||
return $map;
|
||||
}
|
||||
|
||||
public function build_index($count)
|
||||
public function build_index($count): string
|
||||
{
|
||||
$lm = date('c');
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
|
@ -66,7 +66,7 @@ class sitemap
|
|||
return $map;
|
||||
}
|
||||
|
||||
public function build_stat()
|
||||
public function build_stat(): string
|
||||
{
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_static();
|
||||
|
@ -76,7 +76,7 @@ class sitemap
|
|||
return $map;
|
||||
}
|
||||
|
||||
public function build_map_topic($n)
|
||||
public function build_map_topic($n): string
|
||||
{
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_topic($n);
|
||||
|
@ -85,7 +85,7 @@ class sitemap
|
|||
return $map;
|
||||
}
|
||||
|
||||
public function get_forum()
|
||||
public function get_forum(): string
|
||||
{
|
||||
global $datastore;
|
||||
|
||||
|
@ -115,7 +115,7 @@ class sitemap
|
|||
return $xml;
|
||||
}
|
||||
|
||||
public function get_topic($page = false)
|
||||
public function get_topic($page = false): string
|
||||
{
|
||||
global $datastore;
|
||||
|
||||
|
@ -159,7 +159,7 @@ class sitemap
|
|||
return $xml;
|
||||
}
|
||||
|
||||
public function get_static()
|
||||
public function get_static(): string
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -183,7 +183,7 @@ class sitemap
|
|||
return $xml;
|
||||
}
|
||||
|
||||
public function get_xml($loc, $lm)
|
||||
public function get_xml($loc, $lm): string
|
||||
{
|
||||
$xml = "\t<url>\n";
|
||||
$xml .= "\t\t<loc>$loc</loc>\n";
|
||||
|
|
|
@ -2584,7 +2584,7 @@ class utf8
|
|||
* @param array|scalar|null $data
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_ascii($data)
|
||||
public static function is_ascii($data): bool
|
||||
{
|
||||
if (!ReflectionTypeHint::isValid()) {
|
||||
return false;
|
||||
|
@ -2623,7 +2623,7 @@ class utf8
|
|||
* @param bool $is_strict strict the range of ASCII?
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_utf8($data, $is_strict = true)
|
||||
public static function is_utf8($data, $is_strict = true): bool
|
||||
{
|
||||
if (!ReflectionTypeHint::isValid()) {
|
||||
return false;
|
||||
|
@ -2665,7 +2665,7 @@ class utf8
|
|||
* @param bool $is_strict строгая проверка диапазона ASCII?
|
||||
* @return bool
|
||||
*/
|
||||
public static function check($s, $is_strict = true)
|
||||
public static function check($s, $is_strict = true): bool
|
||||
{
|
||||
if (!ReflectionTypeHint::isValid()) {
|
||||
return false;
|
||||
|
@ -2734,7 +2734,7 @@ class utf8
|
|||
* @return bool Возвращает TRUE, если все символы из текста принадлежат указанным диапазонам
|
||||
* и FALSE в противном случае или для разбитого UTF-8.
|
||||
*/
|
||||
public static function blocks_check($data, $blocks)
|
||||
public static function blocks_check($data, $blocks): bool
|
||||
{
|
||||
if (!ReflectionTypeHint::isValid()) {
|
||||
return false;
|
||||
|
@ -2825,7 +2825,7 @@ class utf8
|
|||
* @return bool Возвращает TRUE, если все значения элементов массивов в кодировке UTF-8
|
||||
* и FALSE + E_USER_WARNING в противном случае.
|
||||
*/
|
||||
public static function autoconvert_request($is_hex2bin = false, $charset = 'cp1251')
|
||||
public static function autoconvert_request($is_hex2bin = false, $charset = 'cp1251'): bool
|
||||
{
|
||||
if (!ReflectionTypeHint::isValid()) {
|
||||
return false;
|
||||
|
@ -4179,7 +4179,7 @@ class utf8
|
|||
return preg_replace('~[' . $charlist_re . ']+$~suSX', '', $s);
|
||||
}
|
||||
|
||||
private static function _preg_quote_class($charlist, $delimiter = null)
|
||||
private static function _preg_quote_class($charlist, $delimiter = null): string
|
||||
{
|
||||
#return preg_quote($charlist, $delimiter); #DEPRECATED
|
||||
$quote_table = array(
|
||||
|
@ -4430,7 +4430,7 @@ class utf8
|
|||
return strtr($s, $table);
|
||||
}
|
||||
|
||||
public static function tests()
|
||||
public static function tests(): bool
|
||||
{
|
||||
assert_options(ASSERT_ACTIVE, true);
|
||||
assert_options(ASSERT_BAIL, true);
|
||||
|
|
|
@ -121,7 +121,7 @@ class caches
|
|||
return $this->cfg['db_dir'] . $name . $ext;
|
||||
}
|
||||
|
||||
public function get_table_schema($cfg)
|
||||
public function get_table_schema($cfg): string
|
||||
{
|
||||
return "CREATE TABLE {$cfg['table_name']} ( {$cfg['columns']} )";
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ class sql_db
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function affected_rows()
|
||||
public function affected_rows(): int
|
||||
{
|
||||
return mysqli_affected_rows($this->link);
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ class sql_db
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sql_fetchrowset($result, $field_name = '')
|
||||
public function sql_fetchrowset($result, $field_name = ''): array
|
||||
{
|
||||
$rowset = [];
|
||||
|
||||
|
@ -333,7 +333,7 @@ class sql_db
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_rowset($query, $field_name = '')
|
||||
public function fetch_rowset($query, $field_name = ''): array
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -350,7 +350,7 @@ class sql_db
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_all($query, $field_name = '')
|
||||
public function fetch_all($query, $field_name = ''): array
|
||||
{
|
||||
if (!$result = $this->sql_query($query)) {
|
||||
$this->trigger_error();
|
||||
|
@ -426,7 +426,7 @@ class sql_db
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escape_string($str)
|
||||
public function escape_string($str): string
|
||||
{
|
||||
if (!$this->link) {
|
||||
$this->init();
|
||||
|
@ -446,7 +446,7 @@ class sql_db
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function build_array($query_type, $input_ary, $data_already_escaped = false, $check_data_type_in_escape = true)
|
||||
public function build_array($query_type, $input_ary, $data_already_escaped = false, $check_data_type_in_escape = true): string
|
||||
{
|
||||
$fields = $values = $ary = $query = [];
|
||||
$dont_escape = $data_already_escaped;
|
||||
|
@ -501,7 +501,7 @@ class sql_db
|
|||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get_empty_sql_array()
|
||||
public function get_empty_sql_array(): array
|
||||
{
|
||||
return [
|
||||
'SELECT' => [],
|
||||
|
@ -521,7 +521,7 @@ class sql_db
|
|||
* @param $sql_ary
|
||||
* @return string
|
||||
*/
|
||||
public function build_sql($sql_ary)
|
||||
public function build_sql($sql_ary): string
|
||||
{
|
||||
$sql = '';
|
||||
array_deep($sql_ary, 'array_unique', false, true);
|
||||
|
@ -655,7 +655,7 @@ class sql_db
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function unlock()
|
||||
public function unlock(): bool
|
||||
{
|
||||
if ($this->locked && $this->sql_query("UNLOCK TABLES")) {
|
||||
$this->locked = false;
|
||||
|
@ -725,7 +725,7 @@ class sql_db
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_lock_name($name)
|
||||
public function get_lock_name($name): string
|
||||
{
|
||||
if (!$this->selected_db) {
|
||||
$this->init();
|
||||
|
@ -869,7 +869,7 @@ class sql_db
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function debug_find_source($mode = '')
|
||||
public function debug_find_source($mode = ''): string
|
||||
{
|
||||
foreach (debug_backtrace() as $trace) {
|
||||
if (!empty($trace['file']) && $trace['file'] !== __FILE__) {
|
||||
|
|
|
@ -85,7 +85,7 @@ class datastore_apc extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
public function is_installed(): bool
|
||||
{
|
||||
return function_exists('apc_fetch');
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ class datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
public function debug_find_source($mode = '')
|
||||
public function debug_find_source($mode = ''): string
|
||||
{
|
||||
foreach (debug_backtrace() as $trace) {
|
||||
if ($trace['file'] !== __FILE__) {
|
||||
|
|
|
@ -123,7 +123,7 @@ class datastore_memcache extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
public function is_installed(): bool
|
||||
{
|
||||
return class_exists('Memcache');
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class datastore_redis extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
public function is_installed(): bool
|
||||
{
|
||||
return class_exists('Redis');
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class datastore_xcache extends datastore_common
|
|||
}
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
public function is_installed(): bool
|
||||
{
|
||||
return function_exists('xcache_get');
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ class ads_common
|
|||
/**
|
||||
* Get ads to show for each block
|
||||
*/
|
||||
public function get($block_types)
|
||||
public function get($block_types): array
|
||||
{
|
||||
$ads = array();
|
||||
|
||||
|
@ -188,7 +188,7 @@ class ads_common
|
|||
/**
|
||||
* Get block_ids for specified block_types
|
||||
*/
|
||||
public function get_block_ids($block_types)
|
||||
public function get_block_ids($block_types): array
|
||||
{
|
||||
$block_ids = array();
|
||||
|
||||
|
@ -204,7 +204,7 @@ class ads_common
|
|||
/**
|
||||
* Get ad_ids for specified blocks
|
||||
*/
|
||||
public function get_ad_ids($block_ids)
|
||||
public function get_ad_ids($block_ids): array
|
||||
{
|
||||
$ad_ids = array();
|
||||
|
||||
|
@ -539,7 +539,7 @@ class Date_Delta
|
|||
}
|
||||
|
||||
// Makes the spellable phrase.
|
||||
public function spellDelta($first, $last, $from = 'auto')
|
||||
public function spellDelta($first, $last, $from = 'auto'): string
|
||||
{
|
||||
if ($last < $first) {
|
||||
$old_first = $first;
|
||||
|
@ -631,7 +631,7 @@ class Date_Delta
|
|||
}
|
||||
|
||||
// Returns the length (in days) of the specified month.
|
||||
public function monthLength($year, $mon)
|
||||
public function monthLength($year, $mon): int
|
||||
{
|
||||
$l = 28;
|
||||
while (checkdate($mon, $l + 1, $year)) {
|
||||
|
@ -680,7 +680,7 @@ class html_common
|
|||
public $max_length = HTML_SELECT_MAX_LENGTH;
|
||||
public $selected = array();
|
||||
|
||||
public function build_select($name, $params, $selected = null, $max_length = HTML_SELECT_MAX_LENGTH, $multiple_size = null, $js = '')
|
||||
public function build_select($name, $params, $selected = null, $max_length = HTML_SELECT_MAX_LENGTH, $multiple_size = null, $js = ''): string
|
||||
{
|
||||
if (empty($params)) {
|
||||
return '';
|
||||
|
@ -738,7 +738,7 @@ class html_common
|
|||
}
|
||||
}
|
||||
|
||||
public function array2html($array, $ul = 'ul', $li = 'li')
|
||||
public function array2html($array, $ul = 'ul', $li = 'li'): string
|
||||
{
|
||||
$this->out = '';
|
||||
$this->_array2html_rec($array, $ul, $li);
|
||||
|
@ -759,7 +759,7 @@ class html_common
|
|||
}
|
||||
|
||||
// all arguments should be already htmlspecialchar()d (if needed)
|
||||
public function build_checkbox($name, $title, $checked = false, $disabled = false, $class = null, $id = null, $value = 1)
|
||||
public function build_checkbox($name, $title, $checked = false, $disabled = false, $class = null, $id = null, $value = 1): string
|
||||
{
|
||||
$name = ' name="' . $name . '" ';
|
||||
$value = ' value="' . $value . '" ';
|
||||
|
|
|
@ -59,7 +59,7 @@ class upload_common
|
|||
8 => 'tiff',
|
||||
);
|
||||
|
||||
public function init($cfg = array(), $post_params = array(), $uploaded_only = true)
|
||||
public function init($cfg = array(), $post_params = array(), $uploaded_only = true): bool
|
||||
{
|
||||
global $bb_cfg, $lang;
|
||||
|
||||
|
@ -145,7 +145,7 @@ class upload_common
|
|||
}
|
||||
}
|
||||
|
||||
public function _move($file_path)
|
||||
public function _move($file_path): bool
|
||||
{
|
||||
$dir = dirname($file_path);
|
||||
if (!file_exists($dir)) {
|
||||
|
|
|
@ -220,7 +220,7 @@ class user_common
|
|||
/**
|
||||
* Create new session for the given user
|
||||
*/
|
||||
public function session_create($userdata, $auto_created = false)
|
||||
public function session_create($userdata, $auto_created = false): array
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -364,7 +364,7 @@ class user_common
|
|||
/**
|
||||
* Login
|
||||
*/
|
||||
public function login($args, $mod_admin_login = false)
|
||||
public function login($args, $mod_admin_login = false): array
|
||||
{
|
||||
$username = !empty($args['login_username']) ? clean_username($args['login_username']) : '';
|
||||
$password = !empty($args['login_password']) ? $args['login_password'] : '';
|
||||
|
@ -630,7 +630,7 @@ class user_common
|
|||
/**
|
||||
* Get not auth forums
|
||||
*/
|
||||
public function get_not_auth_forums($auth_type)
|
||||
public function get_not_auth_forums($auth_type): string
|
||||
{
|
||||
global $datastore;
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ class template
|
|||
* Returns empty string if non-cachable (for tpl files outside of root dir).
|
||||
* $filename should be absolute filename
|
||||
*/
|
||||
public function make_filename_cache($filename)
|
||||
public function make_filename_cache($filename): string
|
||||
{
|
||||
$filename = clean_filename(str_replace(TEMPLATES_DIR, '', $filename));
|
||||
|
||||
|
@ -206,7 +206,7 @@ class template
|
|||
/**
|
||||
* Assigns template filename for handle.
|
||||
*/
|
||||
public function set_filename($handle, $filename, $xs_include = false, $quiet = false)
|
||||
public function set_filename($handle, $filename, $xs_include = false, $quiet = false): bool
|
||||
{
|
||||
$can_cache = $this->use_cache;
|
||||
$this->files[$handle] = $this->make_filename($filename, $xs_include);
|
||||
|
@ -269,7 +269,7 @@ class template
|
|||
* and run the compiled code. This will print out
|
||||
* the results of executing the template.
|
||||
*/
|
||||
public function pparse($handle)
|
||||
public function pparse($handle): bool
|
||||
{
|
||||
// parsing header if there is one
|
||||
if ($this->preparse || $this->postparse) {
|
||||
|
@ -322,7 +322,7 @@ class template
|
|||
/**
|
||||
* Precompile file
|
||||
*/
|
||||
public function precompile($template, $filename)
|
||||
public function precompile($template, $filename): bool
|
||||
{
|
||||
global $precompile_num;
|
||||
if (empty($precompile_num)) {
|
||||
|
@ -377,7 +377,7 @@ class template
|
|||
* Note that all desired assignments to the variables in $handle should be done
|
||||
* BEFORE calling this function.
|
||||
*/
|
||||
public function assign_var_from_handle($varname, $handle)
|
||||
public function assign_var_from_handle($varname, $handle): bool
|
||||
{
|
||||
ob_start();
|
||||
$res = $this->pparse($handle);
|
||||
|
@ -391,7 +391,7 @@ class template
|
|||
* variable assignments. Note that this should only be called once per block
|
||||
* iteration.
|
||||
*/
|
||||
public function assign_block_vars($blockname, $vararray)
|
||||
public function assign_block_vars($blockname, $vararray): bool
|
||||
{
|
||||
if (strstr($blockname, '.')) {
|
||||
// Nested block.
|
||||
|
@ -453,7 +453,7 @@ class template
|
|||
* If not already done, load the file for the given handle and populate
|
||||
* the uncompiled_code[] hash with its code. Do not compile.
|
||||
*/
|
||||
public function loadfile($handle)
|
||||
public function loadfile($handle): bool
|
||||
{
|
||||
// If cached file exists do nothing - it will be included via include()
|
||||
if (!empty($this->files_cache[$handle])) {
|
||||
|
@ -488,7 +488,7 @@ class template
|
|||
* It's ready to be inserted into an "echo" line in one of the templates.
|
||||
* NOTE: expects a trailing "." on the namespace.
|
||||
*/
|
||||
public function generate_block_varref($namespace, $varname)
|
||||
public function generate_block_varref($namespace, $varname): string
|
||||
{
|
||||
// Strip the trailing period.
|
||||
$namespace = substr($namespace, 0, strlen($namespace) - 1);
|
||||
|
@ -525,7 +525,7 @@ class template
|
|||
return '$' . $blocks[$blockcount - 1] . '_item[\'' . $blocks[$blockcount] . '.\']';
|
||||
}
|
||||
|
||||
public function compile_code($filename, $code)
|
||||
public function compile_code($filename, $code): string
|
||||
{
|
||||
// $filename - file to load code from. used if $code is empty
|
||||
// $code - tpl code
|
||||
|
@ -846,7 +846,7 @@ class template
|
|||
// Compile IF tags - much of this is from Smarty with
|
||||
// some adaptions for our block level methods
|
||||
//
|
||||
public function compile_tag_if($tag_args, $elseif)
|
||||
public function compile_tag_if($tag_args, $elseif): string
|
||||
{
|
||||
/* Tokenize args for 'if' tag. */
|
||||
preg_match_all('/(?:
|
||||
|
@ -1014,7 +1014,7 @@ class template
|
|||
/**
|
||||
* Compiles code and writes to cache if needed
|
||||
*/
|
||||
public function compile2($code, $handle, $cache_file)
|
||||
public function compile2($code, $handle, $cache_file): string
|
||||
{
|
||||
$code = $this->compile_code('', $code, XS_USE_ISSET);
|
||||
if ($cache_file && !empty($this->use_cache) && !empty($this->auto_compile)) {
|
||||
|
@ -1035,7 +1035,7 @@ class template
|
|||
* for use in assign_code_from_handle().
|
||||
* This function isn't used and kept only for compatibility with original template.php
|
||||
*/
|
||||
public function compile($code, $do_not_echo = false, $retvar = '')
|
||||
public function compile($code, $do_not_echo = false, $retvar = ''): string
|
||||
{
|
||||
$code = ' ?' . '>' . $this->compile_code('', $code, true) . '<' . "?php \n";
|
||||
if ($do_not_echo) {
|
||||
|
@ -1071,7 +1071,7 @@ class template
|
|||
}
|
||||
}
|
||||
|
||||
public function lang_error($var)
|
||||
public function lang_error($var): string
|
||||
{
|
||||
trigger_error(basename($this->cur_tpl) . " : undefined language variable {L_{$var}}", E_USER_WARNING);
|
||||
return "Undefined: {L_{$var}}";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue