From 7a919a79d7b504c591ba2360b68f2e401675fdae Mon Sep 17 00:00:00 2001 From: wn_ Date: Thu, 11 Nov 2021 11:08:04 +0000 Subject: Fix some additional PHPStan warnings in UrlHelper. --- classes/urlhelper.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'classes/urlhelper.php') diff --git a/classes/urlhelper.php b/classes/urlhelper.php index 5f175af3c..a660af170 100644 --- a/classes/urlhelper.php +++ b/classes/urlhelper.php @@ -16,7 +16,7 @@ class UrlHelper { static bool $fetch_curl_used; /** - * @param array $parts + * @param array $parts */ static function build_url(array $parts): string { $tmp = $parts['scheme'] . "://" . $parts['host']; @@ -113,6 +113,11 @@ class UrlHelper { } else { $tokens['host'] = idn_to_ascii($tokens['host']); } + + // if `idn_to_ascii` failed + if ($tokens['host'] === false) { + return false; + } } } @@ -199,6 +204,7 @@ class UrlHelper { } /** + * @param array|string $options * @return bool|string false if something went wrong, otherwise string contents */ // TODO: max_size currently only works for CURL transfers @@ -522,7 +528,10 @@ class UrlHelper { } } - public static function url_to_youtube_vid(string $url) { # : bool|string + /** + * @return bool|string false if the provided URL didn't match expected patterns, otherwise the video ID string + */ + public static function url_to_youtube_vid(string $url) { $url = str_replace("youtube.com", "youtube-nocookie.com", $url); $regexps = [ -- cgit v1.2.3