Fix some PHP8.1 issues if possible

This commit is contained in:
Philipp Holzer 2022-11-09 23:16:12 +01:00
parent 3b03da3259
commit 477bec1977
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
4 changed files with 9 additions and 9 deletions

View file

@ -130,7 +130,7 @@ class Page implements ArrayAccess
* The return value will be casted to boolean if non-boolean was returned.
* @since 5.0.0
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return isset($this->page[$offset]);
}

View file

@ -188,10 +188,10 @@ class L10n
{
$lang_variable = $server['HTTP_ACCEPT_LANGUAGE'] ?? null;
$acceptedLanguages = preg_split('/,\s*/', $lang_variable);
if (empty($acceptedLanguages)) {
if (empty($lang_variable)) {
$acceptedLanguages = [];
} else {
$acceptedLanguages = preg_split('/,\s*/', $lang_variable);
}
// Add get as absolute quality accepted language (except this language isn't valid)

View file

@ -485,11 +485,11 @@ class Network
$get('host') .
($port ? ":$port" : '');
return (strlen($scheme) ? $scheme . ':' : '') .
(strlen($authority) ? '//' . $authority : '') .
return (!empty($scheme) ? $scheme . ':' : '') .
(!empty($authority) ? '//' . $authority : '') .
$get('path') .
(strlen($query) ? '?' . $query : '') .
(strlen($fragment) ? '#' . $fragment : '');
(!empty($query) ? '?' . $query : '') .
(!empty($fragment) ? '#' . $fragment : '');
}
/**

View file

@ -60,7 +60,7 @@ class ReversedFileReader implements \Iterator
$this->fh = fopen($filename, 'r');
if (!$this->fh) {
// this should use a custom exception.
throw \Exception("Unable to open $filename");
throw new \Exception("Unable to open $filename");
}
$this->filesize = filesize($filename);
$this->pos = -1;