diff --git a/system/Helpers/date_helper.php b/system/Helpers/date_helper.php index 7a950883ef90..1eebabb6091b 100644 --- a/system/Helpers/date_helper.php +++ b/system/Helpers/date_helper.php @@ -47,7 +47,7 @@ * * @return integer */ - function now(string $timezone = null) + function now(string $timezone = null): int { $timezone = empty($timezone) ? app_timezone() : $timezone; diff --git a/system/Helpers/number_helper.php b/system/Helpers/number_helper.php index 7511cb049706..805f8a9f9e12 100644 --- a/system/Helpers/number_helper.php +++ b/system/Helpers/number_helper.php @@ -45,7 +45,7 @@ * @param integer $precision * @param string $locale * - * @return string + * @return boolean|string */ function number_to_size($num, int $precision = 1, string $locale = null) { @@ -178,7 +178,7 @@ function number_to_amount($num, int $precision = 0, string $locale = null) * * @return string */ - function number_to_currency($num, string $currency, string $locale = null) + function number_to_currency($num, string $currency, string $locale = null): string { return format_number($num, 1, $locale, [ 'type' => NumberFormatter::CURRENCY, @@ -202,7 +202,7 @@ function number_to_currency($num, string $currency, string $locale = null) * * @return string */ - function format_number($num, int $precision = 1, string $locale = null, array $options = []) + function format_number($num, int $precision = 1, string $locale = null, array $options = []): string { // Locale is either passed in here, negotiated with client, or grabbed from our config file. $locale = $locale ?? \CodeIgniter\Config\Services::request()->getLocale(); @@ -259,14 +259,14 @@ function format_number($num, int $precision = 1, string $locale = null, array $o * * @param integer $num it will convert to int * - * @return string + * @return string|null */ function number_to_roman($num) { $num = (int) $num; if ($num < 1 || $num > 3999) { - return; + return null; } $_number_to_roman = function ($num, $th) use (&$_number_to_roman) { diff --git a/system/Helpers/security_helper.php b/system/Helpers/security_helper.php index 047ea7facee1..7e67cf29b78c 100644 --- a/system/Helpers/security_helper.php +++ b/system/Helpers/security_helper.php @@ -45,7 +45,7 @@ * * @return string */ - function sanitize_filename(string $filename) + function sanitize_filename(string $filename): string { return Services::security()->sanitizeFilename($filename); } @@ -61,7 +61,7 @@ function sanitize_filename(string $filename) * @param string $str * @return string */ - function strip_image_tags(string $str) + function strip_image_tags(string $str): string { return preg_replace([ '##i', diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php index 962f4d2ceb4c..52f61b2afc56 100755 --- a/system/Helpers/text_helper.php +++ b/system/Helpers/text_helper.php @@ -150,7 +150,7 @@ function ascii_to_entities(string $str): string { /* If the $temp array has a value but we have moved on, then it seems only - fair that we output that entity and restart $temp before continuing. -Paul + fair that we output that entity and restart $temp before continuing. */ if (count($temp) === 1) { @@ -281,7 +281,7 @@ function word_censor(string $str, $censored, string $replacement = ''): string // \w, \b and a few others do not match on a unicode character // set for performance reasons. As a result words like über // will not match on a word boundary. Instead, we'll assume that - // a bad word will be bookeneded by any of these characters. + // a bad word will be bookended by any of these characters. $delim = '[-_\'\"`(){}<>\[\]|!?@#%&,.:;^~*+=\/ 0-9\n\r\t]'; foreach ($censored as $badword) @@ -402,7 +402,7 @@ function highlight_code(string $str): string * * @param string $str the text string * @param string $phrase the phrase you'd like to highlight - * @param string $tag_open the openging tag to precede the phrase with + * @param string $tag_open the opening tag to precede the phrase with * @param string $tag_close the closing tag to end the phrase with * * @return string @@ -460,7 +460,7 @@ function convert_accented_characters(string $str): string * Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor * will URLs. * - * @param string $str the text string + * @param string $str the text string * @param integer $charlim = 76 the number of characters to wrap at * * @return string @@ -604,9 +604,9 @@ function ellipsize(string $str, int $max_length, $position = 1, string $ellipsis * * Removes slashes contained in a string or in an array * - * @param mixed string or array + * @param mixed $str string or array * - * @return mixed string or array + * @return mixed string or array */ function strip_slashes($str) { @@ -632,7 +632,7 @@ function strip_slashes($str) * * Removes single and double quotes from a string * - * @param string + * @param string $str * * @return string */ @@ -651,7 +651,7 @@ function strip_quotes(string $str): string * * Converts single and double quotes to entities * - * @param string + * @param string $str * * @return string */ @@ -677,7 +677,7 @@ function quotes_to_entities(string $str): string * * http://www.some-site.com/index.php * - * @param string + * @param string $str * * @return string */ @@ -712,7 +712,7 @@ function reduce_multiples(string $str, string $character = ',', bool $trim = fal { $str = preg_replace('#' . preg_quote($character, '#') . '{2,}#', $character, $str); - return ($trim === true) ? trim($str, $character) : $str; + return ($trim) ? trim($str, $character) : $str; } } @@ -814,7 +814,7 @@ function alternator(): string $args = func_get_args(); - return $args[($i ++ % count($args))]; + return $args[($i++ % count($args))]; } } @@ -829,13 +829,13 @@ function alternator(): string * * @param string $text String to search the phrase * @param string $phrase Phrase that will be searched for. - * @param integer $radius The amount of characters returned arround the phrase. + * @param integer $radius The amount of characters returned around the phrase. * @param string $ellipsis Ending that will be appended * * @return string * * If no $phrase is passed, will generate an excerpt of $radius characters - * from the begining of $text. + * from the beginning of $text. */ function excerpt(string $text, string $phrase = null, int $radius = 100, string $ellipsis = '...'): string { diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 399f0f5c6341..4fbaaaedc70c 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -334,7 +334,7 @@ function anchor_popup($uri = '', string $title = '', $attributes = false, \Confi */ function mailto($email, string $title = '', $attributes = ''): string { - if ($title === '') + if (trim($title) === '') { $title = $email; } @@ -360,7 +360,7 @@ function mailto($email, string $title = '', $attributes = ''): string */ function safe_mailto($email, string $title = '', $attributes = ''): string { - if ($title === '') + if (trim($title) === '') { $title = $email; } diff --git a/user_guide_src/source/helpers/number_helper.rst b/user_guide_src/source/helpers/number_helper.rst index 77842e525e74..7e36c9e16558 100644 --- a/user_guide_src/source/helpers/number_helper.rst +++ b/user_guide_src/source/helpers/number_helper.rst @@ -109,7 +109,7 @@ The following functions are available: :param string $num: The number want to convert :returns: The roman number converted from given parameter - :rtype: string + :rtype: string|null Converts a number into roman::