From 54a1c9142fc6a6a4f3bc8155c6940ffba4477d34 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Fri, 5 May 2017 01:00:05 +0300 Subject: [PATCH] Return type hint can be used. --- ajax.php | 2 +- library/ajax/view_torrent.php | 2 +- library/attach_mod/posting_attachments.php | 2 +- library/includes/bbcode.php | 14 ++++++------ library/includes/cache/apc.php | 2 +- library/includes/cache/common.php | 6 ++--- library/includes/cache/file.php | 6 ++--- library/includes/cache/memcache.php | 4 ++-- library/includes/cache/redis.php | 2 +- library/includes/cache/sqlite.php | 20 ++++++++--------- library/includes/cache/xcache.php | 4 ++-- library/includes/classes/correct.php | 8 +++---- library/includes/classes/emailer.php | 6 ++--- library/includes/classes/reflection.php | 6 ++--- library/includes/classes/sitemap.php | 16 ++++++------- library/includes/classes/utf8.php | 14 ++++++------ library/includes/core/caches.php | 2 +- library/includes/core/mysql.php | 22 +++++++++--------- library/includes/datastore/apc.php | 2 +- library/includes/datastore/common.php | 2 +- library/includes/datastore/memcache.php | 2 +- library/includes/datastore/redis.php | 2 +- library/includes/datastore/xcache.php | 2 +- library/includes/functions.php | 16 ++++++------- library/includes/functions_upload.php | 4 ++-- library/includes/sessions.php | 6 ++--- library/includes/template.php | 26 +++++++++++----------- 27 files changed, 100 insertions(+), 100 deletions(-) diff --git a/ajax.php b/ajax.php index 2f14061d6..6c3f9e7b9 100644 --- a/ajax.php +++ b/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) { diff --git a/library/ajax/view_torrent.php b/library/ajax/view_torrent.php index 5707683ea..6d84e4fc2 100644 --- a/library/ajax/view_torrent.php +++ b/library/ajax/view_torrent.php @@ -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; diff --git a/library/attach_mod/posting_attachments.php b/library/attach_mod/posting_attachments.php index 3046d5aa9..ad38f0784 100644 --- a/library/attach_mod/posting_attachments.php +++ b/library/attach_mod/posting_attachments.php @@ -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; diff --git a/library/includes/bbcode.php b/library/includes/bbcode.php index 0f8346ba8..5d68d0308 100644 --- a/library/includes/bbcode.php +++ b/library/includes/bbcode.php @@ -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(); diff --git a/library/includes/cache/apc.php b/library/includes/cache/apc.php index 69b5544f8..e74692ce0 100644 --- a/library/includes/cache/apc.php +++ b/library/includes/cache/apc.php @@ -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'); } diff --git a/library/includes/cache/common.php b/library/includes/cache/common.php index 42ce97b44..02b3230fd 100644 --- a/library/includes/cache/common.php +++ b/library/includes/cache/common.php @@ -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__) { diff --git a/library/includes/cache/file.php b/library/includes/cache/file.php index d1a4c559e..ca347e5fe 100644 --- a/library/includes/cache/file.php +++ b/library/includes/cache/file.php @@ -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; diff --git a/library/includes/cache/memcache.php b/library/includes/cache/memcache.php index 12c2d0d4c..7459d4772 100644 --- a/library/includes/cache/memcache.php +++ b/library/includes/cache/memcache.php @@ -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'); } diff --git a/library/includes/cache/redis.php b/library/includes/cache/redis.php index 2561981c3..7da101309 100644 --- a/library/includes/cache/redis.php +++ b/library/includes/cache/redis.php @@ -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'); } diff --git a/library/includes/cache/sqlite.php b/library/includes/cache/sqlite.php index c52f68e66..0792ff90a 100644 --- a/library/includes/cache/sqlite.php +++ b/library/includes/cache/sqlite.php @@ -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; diff --git a/library/includes/cache/xcache.php b/library/includes/cache/xcache.php index 6811ff0f9..3dfd04530 100644 --- a/library/includes/cache/xcache.php +++ b/library/includes/cache/xcache.php @@ -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'); } diff --git a/library/includes/classes/correct.php b/library/includes/classes/correct.php index 14ceb602c..c0b9722d2 100644 --- a/library/includes/classes/correct.php +++ b/library/includes/classes/correct.php @@ -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); diff --git a/library/includes/classes/emailer.php b/library/includes/classes/emailer.php index 966a07a40..c648c7c90 100644 --- a/library/includes/classes/emailer.php +++ b/library/includes/classes/emailer.php @@ -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; diff --git a/library/includes/classes/reflection.php b/library/includes/classes/reflection.php index e6c03c38c..73da54abd 100644 --- a/library/includes/classes/reflection.php +++ b/library/includes/classes/reflection.php @@ -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); diff --git a/library/includes/classes/sitemap.php b/library/includes/classes/sitemap.php index 52ba4c8c3..fb500c404 100644 --- a/library/includes/classes/sitemap.php +++ b/library/includes/classes/sitemap.php @@ -41,7 +41,7 @@ class sitemap $this->home = make_url(); } - public function build_map() + public function build_map(): string { $map = "\n\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 = "\n\n"; @@ -66,7 +66,7 @@ class sitemap return $map; } - public function build_stat() + public function build_stat(): string { $map = "\n\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 = "\n\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\n"; $xml .= "\t\t$loc\n"; diff --git a/library/includes/classes/utf8.php b/library/includes/classes/utf8.php index 90d166e3d..d514a4c93 100644 --- a/library/includes/classes/utf8.php +++ b/library/includes/classes/utf8.php @@ -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); diff --git a/library/includes/core/caches.php b/library/includes/core/caches.php index c74a31f0a..cf7374800 100644 --- a/library/includes/core/caches.php +++ b/library/includes/core/caches.php @@ -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']} )"; } diff --git a/library/includes/core/mysql.php b/library/includes/core/mysql.php index e25afd498..9834248df 100644 --- a/library/includes/core/mysql.php +++ b/library/includes/core/mysql.php @@ -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__) { diff --git a/library/includes/datastore/apc.php b/library/includes/datastore/apc.php index b4053b59e..afdbe03a0 100644 --- a/library/includes/datastore/apc.php +++ b/library/includes/datastore/apc.php @@ -85,7 +85,7 @@ class datastore_apc extends datastore_common } } - public function is_installed() + public function is_installed(): bool { return function_exists('apc_fetch'); } diff --git a/library/includes/datastore/common.php b/library/includes/datastore/common.php index 8626718fc..41179c2c4 100644 --- a/library/includes/datastore/common.php +++ b/library/includes/datastore/common.php @@ -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__) { diff --git a/library/includes/datastore/memcache.php b/library/includes/datastore/memcache.php index b31e543f4..c39799ba9 100644 --- a/library/includes/datastore/memcache.php +++ b/library/includes/datastore/memcache.php @@ -123,7 +123,7 @@ class datastore_memcache extends datastore_common } } - public function is_installed() + public function is_installed(): bool { return class_exists('Memcache'); } diff --git a/library/includes/datastore/redis.php b/library/includes/datastore/redis.php index e218bf67f..83b5e7fad 100644 --- a/library/includes/datastore/redis.php +++ b/library/includes/datastore/redis.php @@ -117,7 +117,7 @@ class datastore_redis extends datastore_common } } - public function is_installed() + public function is_installed(): bool { return class_exists('Redis'); } diff --git a/library/includes/datastore/xcache.php b/library/includes/datastore/xcache.php index a0ccb770d..084bbcd95 100644 --- a/library/includes/datastore/xcache.php +++ b/library/includes/datastore/xcache.php @@ -86,7 +86,7 @@ class datastore_xcache extends datastore_common } } - public function is_installed() + public function is_installed(): bool { return function_exists('xcache_get'); } diff --git a/library/includes/functions.php b/library/includes/functions.php index 31c42896b..b946f8d45 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -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 . '" '; diff --git a/library/includes/functions_upload.php b/library/includes/functions_upload.php index df11c5cf0..a20f59ec0 100644 --- a/library/includes/functions_upload.php +++ b/library/includes/functions_upload.php @@ -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)) { diff --git a/library/includes/sessions.php b/library/includes/sessions.php index b7e6442da..0491e881c 100644 --- a/library/includes/sessions.php +++ b/library/includes/sessions.php @@ -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; diff --git a/library/includes/template.php b/library/includes/template.php index 35c9bd617..e337c1bb4 100644 --- a/library/includes/template.php +++ b/library/includes/template.php @@ -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}}";