X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FStrings.php;h=84a8b6727a3d4d4383bf22a1c06d5b58d2682f24;hb=b5ad8c3e153976cf3e63753597377f09852d98d7;hp=1be56d0e78f307db5c487ed24d1ab96488e5f73e;hpb=42acc4577207ac2efd61e1a6bb2120da8acbe392;p=friendica.git diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 1be56d0e78..84a8b6727a 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -1,6 +1,6 @@ debug_backtrace()]); - return $s; - } - /* * // Placeholder for new rev of salmon which strips base64 padding. * // PHP base64_decode handles the un-padded input without requiring this step @@ -295,10 +289,9 @@ class Strings * Normalize url * * @param string $url URL to be normalized. - * * @return string Normalized URL. */ - public static function normaliseLink($url) + public static function normaliseLink(string $url): string { $ret = str_replace(['https:', '//www.'], ['http:', '//'], $url); return rtrim($ret, '/'); @@ -308,10 +301,9 @@ class Strings * Normalize OpenID identity * * @param string $s OpenID Identity - * * @return string normalized OpenId Identity */ - public static function normaliseOpenID($s) + public static function normaliseOpenID(string $s): string { return trim(str_replace(['http://', 'https://'], ['', ''], $s), '/'); } @@ -327,7 +319,7 @@ class Strings * @return boolean True if the URLs match, otherwise False * */ - public static function compareLink($a, $b) + public static function compareLink(string $a, string $b): bool { return (strcasecmp(self::normaliseLink($a), self::normaliseLink($b)) === 0); } @@ -338,7 +330,7 @@ class Strings * @param string $uri * @return string */ - public static function ensureQueryParameter($uri) + public static function ensureQueryParameter(string $uri): string { if (strpos($uri, '?') === false && ($pos = strpos($uri, '&')) !== false) { $uri = substr($uri, 0, $pos) . '?' . substr($uri, $pos + 1); @@ -351,10 +343,11 @@ class Strings * Check if the trimmed provided string is starting with one of the provided characters * * @param string $string - * @param array $chars + * @param array $chars + * * @return bool */ - public static function startsWithChars($string, array $chars) + public static function startsWithChars(string $string, array $chars): bool { $return = in_array(substr(trim($string), 0, 1), $chars); @@ -369,7 +362,7 @@ class Strings * @param string $start * @return bool */ - public static function startsWith(string $string, string $start) + public static function startsWith(string $string, string $start): bool { $return = substr_compare($string, $start, 0, strlen($start)) === 0; @@ -382,13 +375,12 @@ class Strings * @see http://maettig.com/code/php/php-performance-benchmarks.php#endswith * @param string $string * @param string $end + * * @return bool */ - public static function endsWith(string $string, string $end) + public static function endsWith(string $string, string $end): bool { - $return = substr_compare($string, $end, -strlen($end)) === 0; - - return $return; + return (substr_compare($string, $end, -strlen($end)) === 0); } /** @@ -397,7 +389,7 @@ class Strings * @return string * @see https://daringfireball.net/2010/07/improved_regex_for_matching_urls */ - public static function autoLinkRegEx() + public static function autoLinkRegEx(): string { return '@ (?