Prepare for PHP 8

This commit is contained in:
jrenslin committed 2021-05-13 23:02:37 +02:00
1 parent 20c33437c9
commit a06a6ed41d
1 file changed
+4 -9
+4 -9
View File
@@ -237,7 +237,7 @@ public static function strtotime(string $datetime):int {
* @param string $url URL to query.
* @param integer $timeout Timeout in milliseconds.
*
* @return resource
* @return CurlHandle
*/
public static function curl_init(string $url, int $timeout) {
@@ -300,9 +300,7 @@ public static function runCurl(string $url, int $timeout = 1200):string {
*/
public static function runCurlMulti(array $urls, int $timeout = 1200):array {
if (!($mh = curl_multi_init())) {
throw new Exception("Failed to set up multi handle");
}
$mh = curl_multi_init();
$curl_array = [];
foreach($urls as $i => $url) {
@@ -322,7 +320,7 @@ public static function runCurlMulti(array $urls, int $timeout = 1200):array {
$res = [];
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){
@@ -508,9 +506,6 @@ public static function human_filesize(int $bytes, int $decimals = 2):string {
public static function openssl_random_pseudo_bytes(int $length):string {
$output = \openssl_random_pseudo_bytes($length);
if ($output === false) {
throw new Exception("Failed generating random pseudo bytes using openssl_random_pseudo_bytes");
}
return $output;
}
@@ -579,7 +574,7 @@ public static function mime_content_type(string $filepath):string {
/**
* 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
*/