From 5aeb909630fe3418a92d8ef57e5aa9270afad673 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 12 May 2022 17:48:14 +0200 Subject: [inc/Download] Add types --- inc/download.inc.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'inc') diff --git a/inc/download.inc.php b/inc/download.inc.php index 5a71014e..3986bc40 100644 --- a/inc/download.inc.php +++ b/inc/download.inc.php @@ -3,13 +3,17 @@ class Download { + /** + * @var false|resource + */ private static $curlHandle = false; /** * Common initialization for download and downloadToFile * Return file handle to header file + * @return false|resource */ - private static function initCurl($url, $timeout, &$head) + private static function initCurl(string $url, int $timeout, &$head) { if (self::$curlHandle === false) { self::$curlHandle = curl_init(); @@ -51,7 +55,7 @@ class Download * Download file, obey given timeout in seconds * Return data on success, false on failure */ - public static function asString($url, $timeout, &$code) + public static function asString(string $url, int $timeout, &$code) { $ch = self::initCurl($url, $timeout, $head); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -73,7 +77,7 @@ class Download * @param int $timeout timeout in seconds * @param int $code HTTP response code, or 999 on error */ - public static function asStringPost($url, $params, $timeout, &$code) + public static function asStringPost(string $url, $params, int $timeout, &$code) { $string = ''; if (is_array($params)) { @@ -107,7 +111,7 @@ class Download * @param int $code HTTP status code passed out by reference * @return boolean */ - public static function toFile($target, $url, $timeout, &$code) + public static function toFile(string $target, string $url, int $timeout, &$code): bool { $fh = fopen($target, 'wb'); if ($fh === false) -- cgit v1.2.3-55-g7522