Prepare for PHP 8

This commit is contained in:
Joshua Ramon Enslin 2021-05-13 23:02:37 +02:00
parent 20c33437c9
commit a06a6ed41d
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -237,7 +237,7 @@ final class MD_STD {
* @param string $url URL to query. * @param string $url URL to query.
* @param integer $timeout Timeout in milliseconds. * @param integer $timeout Timeout in milliseconds.
* *
* @return resource * @return CurlHandle
*/ */
public static function curl_init(string $url, int $timeout) { public static function curl_init(string $url, int $timeout) {
@ -300,9 +300,7 @@ final class MD_STD {
*/ */
public static function runCurlMulti(array $urls, int $timeout = 1200):array { public static function runCurlMulti(array $urls, int $timeout = 1200):array {
if (!($mh = curl_multi_init())) { $mh = curl_multi_init();
throw new Exception("Failed to set up multi handle");
}
$curl_array = []; $curl_array = [];
foreach($urls as $i => $url) { foreach($urls as $i => $url) {
@ -322,7 +320,7 @@ final class MD_STD {
$res = []; $res = [];
foreach($urls as $i => $url) { foreach($urls as $i => $url) {
$res[$i] = curl_multi_getcontent($curl_array[$i]); $res[$i] = curl_multi_getcontent($curl_array[$i]) ?: '';
} }
foreach($urls as $i => $url){ foreach($urls as $i => $url){
@ -508,9 +506,6 @@ final class MD_STD {
public static function openssl_random_pseudo_bytes(int $length):string { public static function openssl_random_pseudo_bytes(int $length):string {
$output = \openssl_random_pseudo_bytes($length); $output = \openssl_random_pseudo_bytes($length);
if ($output === false) {
throw new Exception("Failed generating random pseudo bytes using openssl_random_pseudo_bytes");
}
return $output; return $output;
} }
@ -579,7 +574,7 @@ final class MD_STD {
/** /**
* Wrapper around the finfo functions to get the mime content type of a file. * Wrapper around the finfo functions to get the mime content type of a file.
* *
* @param string $filepath Expected file path. * @param string $url Expected file path.
* *
* @return string * @return string
*/ */