Address PHPStan warnings in 'classes/urlhelper.php'.
Intentionally skipping the line 66 one for now; adding an 'is_array' check clears the warning, but there's a larger topic of how to handle an invalid '' that doesn't result in an array. ------ --------------------------------------------------------------------- Line classes/urlhelper.php ------ --------------------------------------------------------------------- 66 Offset 'path' on array{scheme: string} in isset() does not exist. 165 Parameter #2 $associative of function get_headers expects bool, int given. 167 Parameter #2 $associative of function get_headers expects bool, int given. 278 Negated boolean expression is always true. 309 Negated boolean expression is always true. ------ ---------------------------------------------------------------------
This commit is contained in:
parent
ac5a4f5937
commit
9dac9c5a0d
|
@ -162,8 +162,12 @@ class UrlHelper {
|
||||||
|
|
||||||
$context = stream_context_create($context_options);
|
$context = stream_context_create($context_options);
|
||||||
|
|
||||||
|
// PHP 8 changed the second param from int to bool, but we still support PHP >= 7.1.0
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$headers = get_headers($url, 0, $context);
|
$headers = get_headers($url, 0, $context);
|
||||||
} else {
|
} else {
|
||||||
|
// PHP 8 changed the second param from int to bool, but we still support PHP >= 7.1.0
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
$headers = get_headers($url, 0);
|
$headers = get_headers($url, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +279,7 @@ class UrlHelper {
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_CONNECT_TIMEOUT));
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_CONNECT_TIMEOUT));
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_TIMEOUT));
|
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_TIMEOUT));
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir") && $followlocation);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followlocation);
|
||||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
|
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
|
||||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
@ -283,6 +287,7 @@ class UrlHelper {
|
||||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : Config::get_user_agent());
|
curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : Config::get_user_agent());
|
||||||
curl_setopt($ch, CURLOPT_ENCODING, "");
|
curl_setopt($ch, CURLOPT_ENCODING, "");
|
||||||
|
curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null");
|
||||||
|
|
||||||
if ($http_referrer)
|
if ($http_referrer)
|
||||||
curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
|
curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
|
||||||
|
@ -306,10 +311,6 @@ class UrlHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ini_get("open_basedir")) {
|
|
||||||
curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config::get(Config::HTTP_PROXY)) {
|
if (Config::get(Config::HTTP_PROXY)) {
|
||||||
curl_setopt($ch, CURLOPT_PROXY, Config::get(Config::HTTP_PROXY));
|
curl_setopt($ch, CURLOPT_PROXY, Config::get(Config::HTTP_PROXY));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue