From 06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 14 Nov 2023 14:47:55 +0100 Subject: Add function param/return types, fix a lot more phpstorm complaints --- inc/download.inc.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'inc/download.inc.php') diff --git a/inc/download.inc.php b/inc/download.inc.php index 10eac188..49ebbfbc 100644 --- a/inc/download.inc.php +++ b/inc/download.inc.php @@ -24,7 +24,6 @@ class Download curl_setopt(self::$curlHandle, CURLOPT_TIMEOUT, $timeout); curl_setopt(self::$curlHandle, CURLOPT_FOLLOWLOCATION, true); curl_setopt(self::$curlHandle, CURLOPT_AUTOREFERER, true); - curl_setopt(self::$curlHandle, CURLOPT_BINARYTRANSFER, true); curl_setopt(self::$curlHandle, CURLOPT_MAXREDIRS, 6); } @@ -37,7 +36,7 @@ class Download * Download file, obey given timeout in seconds * Return data on success, false on failure */ - public static function asString(string $url, int $timeout, &$code) + public static function asString(string $url, int $timeout, ?int &$code) { $ch = self::initCurl($url, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -52,9 +51,10 @@ class Download * @param string $url URL to fetch * @param array|false $params POST params to set in body, list of key-value-pairs * @param int $timeout timeout in seconds - * @param int $code HTTP response code, or 999 on error + * @param ?int $code HTTP response code, or 999 on error + * @return string|false */ - public static function asStringPost(string $url, $params, int $timeout, &$code) + public static function asStringPost(string $url, $params, int $timeout, ?int &$code) { $string = ''; if (is_array($params)) { @@ -80,10 +80,9 @@ class Download * @param string $target destination path to download file to * @param string $url URL of file to download * @param int $timeout timeout in seconds - * @param int $code HTTP status code passed out by reference - * @return boolean + * @param ?int $code HTTP status code passed out by reference */ - public static function toFile(string $target, string $url, int $timeout, &$code): bool + public static function toFile(string $target, string $url, int $timeout, ?int &$code): bool { $fh = fopen($target, 'wb'); if ($fh === false) -- cgit v1.2.3-55-g7522