diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index ef96466d0..06d766fec 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -719,9 +719,10 @@ class Context * Append string to browser title * * @param string $title Browser title to be appended + * @param string $delimiter * @return void */ - public static function addBrowserTitle($title) + public static function addBrowserTitle($title, $delimiter = ' - ') { if(!$title) { @@ -729,7 +730,7 @@ class Context } if(self::$_instance->browser_title) { - self::$_instance->browser_title .= ' - ' . $title; + self::$_instance->browser_title .= $delimiter . $title; } else { @@ -741,9 +742,10 @@ class Context * Prepend string to browser title * * @param string $title Browser title to be prepended + * @param string $delimiter * @return void */ - public static function prependBrowserTitle($title) + public static function prependBrowserTitle($title, $delimiter = ' - ') { if(!$title) { @@ -751,7 +753,7 @@ class Context } if(self::$_instance->browser_title) { - self::$_instance->browser_title = $title . ' - ' . self::$_instance->browser_title; + self::$_instance->browser_title = $title . $delimiter . self::$_instance->browser_title; } else { @@ -903,7 +905,7 @@ class Context * Return string accoring to the inputed code * * @param string $code Language variable name - * @return string If string for the code exists returns it, otherwise returns original code + * @return mixed */ public static function getLang($code) { @@ -1020,7 +1022,7 @@ class Context * @param string $key * @param mixed $charset charset * @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5 - * @return void + * @return ?bool */ public static function checkConvertFlag(&$val, $key = null, $charset = null) { @@ -1049,7 +1051,7 @@ class Context * @param string $key * @param string $charset character set * @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5 - * @return object converted object + * @return void */ public static function doConvertEncoding(&$val, $key = null, $charset = 'CP949') { @@ -1315,7 +1317,7 @@ class Context * * @return void */ - private static function setUploadInfo() + public static function setUploadInfo() { if (!isset($_SERVER['REQUEST_METHOD']) || $_SERVER['REQUEST_METHOD'] !== 'POST' || !$_FILES) { @@ -1617,10 +1619,12 @@ class Context } /** - * Display a generic error page and exit. + * Display a generic error page. * * @param string $title * @param string $message + * @param int $status + * @param string $location * @return void */ public static function displayErrorPage($title = 'Error', $message = '', $status = 500, $location = '') @@ -1963,7 +1967,7 @@ class Context * * @param string $key Key * @param mixed $val Value - * @param mixed $replace_request_arg + * @param bool $replace_request_arg * @return void */ public static function set($key, $val, $replace_request_arg = false) @@ -2020,17 +2024,20 @@ class Context /** * Get one more vars in object vars with given arguments(key1, key2, key3,...) * - * @return object + * @return ?object */ public static function gets() { - $num_args = func_num_args(); - if($num_args < 1) + $args_list = func_get_args(); + if (count($args_list) < 1) { return; } + if (count($args_list) === 1 && is_array($args_list[0])) + { + $args_list = $args_list[0]; + } - $args_list = func_get_args(); $output = new stdClass; self::$_user_vars = self::$_user_vars !== null ? self::$_user_vars : new stdClass; foreach($args_list as $key) @@ -3003,7 +3010,7 @@ class Context * Add OpenGraph metadata * * @param string $name - * @param mixed $content + * @param array $content * @return void */ public static function addOpenGraphData($name, $content) @@ -3040,6 +3047,6 @@ class Context */ public static function getCanonicalURL() { - return self::$_instance->canonical_url; + return self::$_instance->canonical_url ?? ''; } } diff --git a/classes/frontendfile/FrontEndFileHandler.class.php b/classes/frontendfile/FrontEndFileHandler.class.php index f98958256..a530ee3ce 100644 --- a/classes/frontendfile/FrontEndFileHandler.class.php +++ b/classes/frontendfile/FrontEndFileHandler.class.php @@ -205,13 +205,13 @@ class FrontEndFileHandler extends Handler * Get file information * * @param string $fileName The file name - * @param string $targetIe Target IE of file + * @param string $unused Formerly targetIe * @param string $media Media of file * @param array $vars Variables for LESS and SCSS * @param bool $forceMinify Whether this file should be minified * @return stdClass The file information */ - protected function getFileInfo($fileName, $targetIe = '', $media = 'all', $vars = array(), $isCommon = false) + protected function getFileInfo($fileName, $unused = '', $media = 'all', $vars = array(), $isCommon = false) { $pathInfo = pathinfo($fileName); @@ -423,13 +423,13 @@ class FrontEndFileHandler extends Handler * Unload front end file * * @param string $fileName The file name to unload - * @param string $targetIe Target IE of file to unload + * @param string $unused Formerly targetIe * @param string $media Media of file to unload. Only use when file is css. * @return void */ - public function unloadFile($fileName, $targetIe = '', $media = 'all') + public function unloadFile($fileName, $unused = '', $media = 'all') { - $file = $this->getFileInfo($fileName, $targetIe, $media); + $file = $this->getFileInfo($fileName, $unused, $media); if($file->fileExtension == 'css') { diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 0a00ad038..b23d108f5 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -49,7 +49,7 @@ class ModuleHandler extends Handler * prepares variables to use in moduleHandler * @param string $module name of module * @param string $act name of action - * @param int $mid + * @param string $mid * @param int $document_srl * @param int $module_srl * @return void diff --git a/classes/module/ModuleObject.class.php b/classes/module/ModuleObject.class.php index f77996e99..a736136f4 100644 --- a/classes/module/ModuleObject.class.php +++ b/classes/module/ModuleObject.class.php @@ -128,7 +128,7 @@ class ModuleObject extends BaseObject * setter to set an url for redirection * * @param string|array $url url for redirection - * @return $this + * @return object */ public function setRedirectUrl($url = './', $output = NULL) { @@ -151,7 +151,7 @@ class ModuleObject extends BaseObject /** * get url for redirection * - * @return string + * @return ?string */ public function getRedirectUrl() { @@ -546,7 +546,7 @@ class ModuleObject extends BaseObject /** * retrieve the directory path of the template directory * - * @return string + * @return ?string */ public function getTemplateFile() { @@ -577,7 +577,7 @@ class ModuleObject extends BaseObject /** * retrieve the directory path of the template directory * - * @return string + * @return ?string */ public function getTemplatePath() { @@ -600,7 +600,7 @@ class ModuleObject extends BaseObject /** * retreived the file name of edited_layout_file * - * @return string + * @return ?string */ public function getEditedLayoutFile() { @@ -622,7 +622,7 @@ class ModuleObject extends BaseObject /** * get the file name of the layout file * - * @return string + * @return ?string */ public function getLayoutFile() { @@ -653,9 +653,9 @@ class ModuleObject extends BaseObject /** * set the directory path of the layout directory * - * @return string + * @return ?string */ - public function getLayoutPath($layout_name = "", $layout_type = "P") + public function getLayoutPath() { return $this->layout_path; } diff --git a/common/functions.php b/common/functions.php index 7ddb59b59..72b3e9e5b 100644 --- a/common/functions.php +++ b/common/functions.php @@ -11,7 +11,7 @@ * * @param string $key * @param string $value (optional) - * @return mixed + * @return string|array|null */ function config(string $key, $value = null) { @@ -256,7 +256,7 @@ function escape_dqstr(string $str): string * @param string $escape_char The escape character (default: backslash) * @return array */ -function explode_with_escape(string $delimiter, string $str, $limit = 0, $escape_char = '\\'): array +function explode_with_escape(string $delimiter, string $str, int $limit = 0, string $escape_char = '\\'): array { if ($limit < 1) $limit = 0; $str = (string)$str; @@ -417,7 +417,7 @@ function base64_decode_urlsafe(string $str): string /** * This function shortens a number using common suffixes. * - * @param int $number The number to shorten + * @param int|float $number The number to shorten * @param int $significant_digits The number of significant digits to retain * @return string */ diff --git a/common/js/common.js b/common/js/common.js index e4c9602f4..4c30996d7 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -279,6 +279,7 @@ Rhymix.redirectToUrl = function(url) { * @param string url * @param string target * @param string features + * @return void */ Rhymix.openWindow = function(url, target, features) { diff --git a/common/legacy.php b/common/legacy.php index f236ae67b..d1499de9d 100644 --- a/common/legacy.php +++ b/common/legacy.php @@ -232,6 +232,7 @@ function getNextSequence(): int /** * Set Sequence number to session * + * @deprecated * @param int $seq sequence number * @return void */ @@ -248,6 +249,7 @@ function setUserSequence($seq): void /** * Check Sequence number grant * + * @deprecated * @param int $seq sequence number * @return bool */ @@ -313,6 +315,7 @@ function getNotEncodedUrl(): string /** * Get a encoded url. If url is encoded, not encode. Otherwise html encode the url. * + * @deprecated * @see getUrl() * @return string */ @@ -386,6 +389,7 @@ function getNotEncodedFullUrl(): string * getSiteUrl() returns the URL by transforming the given argument value of domain * The first argument should consist of domain("http://" not included) and path * + * @deprecated * @return string */ function getSiteUrl(): string @@ -408,6 +412,7 @@ function getSiteUrl(): string * getSiteUrl() returns the not encoded URL by transforming the given argument value of domain * The first argument should consist of domain("http://" not included) and path * + * @deprecated * @return string */ function getNotEncodedSiteUrl(): string @@ -429,6 +434,7 @@ function getNotEncodedSiteUrl(): string /** * Return the value adding request uri to the getSiteUrl() To get the full url * + * @deprecated * @return string */ function getFullSiteUrl(): string @@ -468,6 +474,7 @@ function getCurrentPageUrl($escape = true): string /** * Return if domain of the virtual site is url type or id type * + * @deprecated * @param string $domain * @return bool */ @@ -540,6 +547,7 @@ function cut_str($string, $cut_size = 0, $tail = '...'): string /** * Convert XE legacy time zone format into UTC offset. * + * @deprecated * @param string $time_zone Time zone in '+0900' format * @return int */ @@ -551,6 +559,7 @@ function get_time_zone_offset($timezone): int /** * Get the offset between the current user's time zone and Rhymix's internal time zone. * + * @param ?int $timestamp (optional) * @return int */ function zgap($timestamp = null): int @@ -771,6 +780,7 @@ function getMonthName(int $month, bool $short = true): string /** * Returns encoded value of given email address for email scraping * + * @deprecated * @param string $email The email * @return string */ @@ -804,6 +814,7 @@ function debugPrint($value, ...$values): void /** * Delete the second object vars from the first argument * + * @deprecated * @param object $target_obj An original object * @param object $del_obj Object vars to delete from the original object * @return object @@ -826,6 +837,7 @@ function delObjectVars($target_obj, $del_obj): object /** * Delete variables that are commonly submitted but don't need to be saved. * + * @deprecated * @param array|object $vars * @return array|object */ @@ -871,6 +883,7 @@ function getNumberingPath($no, int $size = 3): string /** * Sanitize HTML content. * + * @deprecated * @param string $content Target content * @return string */ @@ -882,6 +895,7 @@ function removeHackTag($content): string /** * Get whether utf8 or not given string * + * @deprecated * @param string $string * @param bool $return_convert If set, returns converted string * @param bool $urldecode @@ -909,17 +923,18 @@ function detectUTF8($string, $return_convert = FALSE, $urldecode = TRUE) /** * Get is current user crawler * - * @param string $agent if set, use this value instead HTTP_USER_AGENT + * @param ?string $user_agent if set, use this value instead HTTP_USER_AGENT * @return bool */ -function isCrawler($agent = null): bool +function isCrawler($user_agent = null): bool { - return Rhymix\Framework\UA::isRobot($agent); + return Rhymix\Framework\UA::isRobot($user_agent); } /** * Remove embed media for admin * + * @deprecated * @param string $content * @param int $writer_member_srl * @return void @@ -960,6 +975,9 @@ function stripEmbedTagForAdmin(&$content, $writer_member_srl): void /** * Check for CSRF attacks * + * Use Rhymix\Framework\Security::checkCSRF() instead. + * + * @deprecated * @return bool */ function checkCSRF(): bool @@ -969,6 +987,8 @@ function checkCSRF(): bool /** * menu exposure check by isShow column + * + * @deprecated * @param array $menu * @return void */ @@ -994,6 +1014,7 @@ function recurciveExposureCheck(&$menu): void /** * Alias to hex2rgb() * + * @deprecated * @param string $hexstr * @return array */ @@ -1101,7 +1122,7 @@ if(!function_exists('mb_strlen')) */ if(!function_exists('mb_strpos')) { - function mb_strpos($haystack, $needle, $offset, $charset = null) + function mb_strpos($haystack, $needle, $offset = 0, $charset = null) { if(function_exists('iconv_strpos')) { @@ -1239,6 +1260,7 @@ function reload($isOpener = FALSE): void * @param string $errstr * @param string $file * @param int $line + * @param array $context * @return void */ function handleError($errno, $errstr, $file, $line, $context): void diff --git a/tests/unit/functions/FunctionsTest.php b/tests/unit/functions/FunctionsTest.php index 000fe451f..410221fa7 100644 --- a/tests/unit/functions/FunctionsTest.php +++ b/tests/unit/functions/FunctionsTest.php @@ -75,7 +75,7 @@ class FunctionsTest extends \Codeception\Test\Unit $this->assertEquals(array('foo', 'bar,baz'), explode_with_escape(',', 'foo,bar\\,baz')); $this->assertEquals(array('foo', 'bar\\', 'baz'), explode_with_escape(',', 'foo,bar\\ , baz')); $this->assertEquals(array('foo', 'bar,baz', 'rhymix'), explode_with_escape(',', 'foo,bar\\,baz,rhymix')); - $this->assertEquals(array('foo', 'bar,baz'), explode_with_escape(',', 'foo,bar!,baz', null, '!')); + $this->assertEquals(array('foo', 'bar,baz'), explode_with_escape(',', 'foo,bar!,baz', 0, '!')); } public function testStartsEndsContains()