summaryrefslogtreecommitdiff
path: root/classes/urlhelper.php
diff options
context:
space:
mode:
authorwn_ <[email protected]>2021-11-11 11:08:04 +0000
committerwn_ <[email protected]>2021-11-11 11:12:40 +0000
commit7a919a79d7b504c591ba2360b68f2e401675fdae (patch)
tree78664f04a891c4c0e7b624d702833688c6b0125c /classes/urlhelper.php
parentbf53dfa51559fd094338f23acd0f4ec312bfd215 (diff)
Fix some additional PHPStan warnings in UrlHelper.
Diffstat (limited to 'classes/urlhelper.php')
-rw-r--r--classes/urlhelper.php13
1 files changed, 11 insertions, 2 deletions
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<string, string> $parts
+ * @param array<string, string|int> $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, bool|int|string>|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 = [