diff --git a/Blacklight/Books.php b/Blacklight/Books.php index d751ed702..b695afb35 100755 --- a/Blacklight/Books.php +++ b/Blacklight/Books.php @@ -191,8 +191,8 @@ class Books $bookIDs = $releaseIDs = false; if (\is_array($books['result'])) { foreach ($books['result'] as $book => $id) { - $bookIDs[] = $id->id; - $releaseIDs[] = $id->grp_release_id; + $bookIDs = [$id->id]; + $releaseIDs = [$id->grp_release_id]; } } $sql = sprintf( @@ -307,7 +307,7 @@ class Books { $browseby = ' '; foreach ($this->getBrowseByOptions() as $bbk => $bbv) { - if (isset($_REQUEST[$bbk]) && ! empty($_REQUEST[$bbk])) { + if (! empty($_REQUEST[$bbk])) { $bbs = stripslashes($_REQUEST[$bbk]); $browseby .= ' AND boo.'.$bbv.' '.'LIKE '.escapeString('%'.$bbs.'%'); } @@ -336,11 +336,10 @@ class Books $this->processBookReleasesHelper( Release::query()->where('nzbstatus', '=', NZB::NZB_ADDED) ->whereNull('bookinfo_id') - ->whereIn('categories_id', [$bookids[$i]]) + ->whereIn('categories_id', [$iValue]) ->orderBy('postdate', 'desc') ->limit($this->bookqty) - ->get(['searchname', 'id', 'categories_id']), - $bookids[$i] + ->get(['searchname', 'id', 'categories_id']), $iValue ); } } diff --git a/Blacklight/Console.php b/Blacklight/Console.php index 8a183a9bd..70fef8b75 100755 --- a/Blacklight/Console.php +++ b/Blacklight/Console.php @@ -205,8 +205,8 @@ class Console $consoleIDs = $releaseIDs = false; if (\is_array($consoles['result'])) { foreach ($consoles['result'] as $console => $id) { - $consoleIDs[] = $id->id; - $releaseIDs[] = $id->grp_release_id; + $consoleIDs = [$id->id]; + $releaseIDs = [$id->grp_release_id]; } } $sql = sprintf( @@ -312,7 +312,7 @@ class Console { $browseBy = ' '; foreach ($this->getBrowseByOptions() as $bbk => $bbv) { - if (isset($_REQUEST[$bbk]) && ! empty($_REQUEST[$bbk])) { + if (! empty($_REQUEST[$bbk])) { $bbs = stripslashes($_REQUEST[$bbk]); $browseBy .= ' AND con.'.$bbv.' LIKE '.escapeString('%'.$bbs.'%'); } diff --git a/Blacklight/Contents.php b/Blacklight/Contents.php index 28e60d5f9..d78562244 100755 --- a/Blacklight/Contents.php +++ b/Blacklight/Contents.php @@ -33,11 +33,7 @@ class Contents return false; } - foreach ($rows as $row) { - $arr[] = $row; - } - - return $arr; + return array_values($rows); } /** @@ -51,11 +47,7 @@ class Contents return false; } - foreach ($rows as $row) { - $arr[] = $row; - } - - return $arr; + return array_values($rows); } /** @@ -71,11 +63,7 @@ class Contents return false; } - foreach ($rows as $row) { - $arr[] = $row; - } - - return $arr; + return array_values($rows); } /** @@ -89,11 +77,7 @@ class Contents return false; } - foreach ($rows as $row) { - $arr[] = $row; - } - - return $arr; + return array_values($rows); } /** @@ -109,11 +93,7 @@ class Contents return false; } - foreach ($rows as $row) { - $arr[] = $row; - } - - return $arr; + return array_values($rows); } /** diff --git a/Blacklight/Games.php b/Blacklight/Games.php index 6f27344ce..385961213 100755 --- a/Blacklight/Games.php +++ b/Blacklight/Games.php @@ -279,8 +279,8 @@ class Games $gameIDs = $releaseIDs = false; if (\is_array($games['result'])) { foreach ($games['result'] as $game => $id) { - $gameIDs[] = $id->id; - $releaseIDs[] = $id->grp_release_id; + $gameIDs = [$id->id]; + $releaseIDs = [$id->grp_release_id]; } } $returnSql = @@ -383,7 +383,7 @@ class Games { $browseBy = ' '; foreach ($this->getBrowseByOptions() as $bbk => $bbv) { - if (isset($_REQUEST[$bbk]) && ! empty($_REQUEST[$bbk])) { + if (! empty($_REQUEST[$bbk])) { $bbs = stripslashes($_REQUEST[$bbk]); if ($bbk === 'year') { $browseBy .= ' AND YEAR (gi.releasedate) '.'LIKE '.escapeString('%'.$bbs.'%'); diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index 860a370db..00b875787 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -1158,7 +1158,7 @@ class Movie // Loop over releases. foreach ($res as $arr) { // Try to get a name/year. - if ($this->parseMovieSearchName($arr['searchname']) === false) { + if (! $this->parseMovieSearchName($arr['searchname'])) { //We didn't find a name, so set to all 0's so we don't parse again. Release::query()->where('id', $arr['id'])->update(['imdbid' => 0000000]); continue; diff --git a/Blacklight/Music.php b/Blacklight/Music.php index 788b132a6..10ef4a568 100755 --- a/Blacklight/Music.php +++ b/Blacklight/Music.php @@ -194,8 +194,8 @@ class Music $musicIDs = $releaseIDs = false; if (\is_array($music['result'])) { foreach ($music['result'] as $mus => $id) { - $musicIDs[] = $id->id; - $releaseIDs[] = $id->grp_release_id; + $musicIDs = [$id->id]; + $releaseIDs = [$id->grp_release_id]; } } $sql = sprintf( @@ -295,7 +295,7 @@ class Music { $browseby = ' '; foreach ($this->getBrowseByOptions() as $bbk => $bbv) { - if (isset($_REQUEST[$bbk]) && ! empty($_REQUEST[$bbk])) { + if (! empty($_REQUEST[$bbk])) { $bbs = stripslashes($_REQUEST[$bbk]); if (stripos($bbv, 'id') !== false) { $browseby .= ' AND m.'.$bbv.' = '.$bbs; diff --git a/Blacklight/NZB.php b/Blacklight/NZB.php index fe68f9189..dac29bae1 100755 --- a/Blacklight/NZB.php +++ b/Blacklight/NZB.php @@ -345,7 +345,7 @@ class NZB // Strip file / part count to get proper sorting. $i = preg_replace('#\d+[- ._]?(/|\||[o0]f)[- ._]?\d+?(?![- ._]\d)#i', '', $i); // Change .rar and .par2 to be sorted before .part0x.rar and .volxxx+xxx.par2 - if (strpos($i, '.par2') !== false && ! preg_match('#\.vol\d+\+\d+\.par2#i', $i)) { + if (str_contains($i, '.par2') && ! preg_match('#\.vol\d+\+\d+\.par2#i', $i)) { $i = str_replace('.par2', '.vol0.par2', $i); } elseif (preg_match('#\.rar[^a-z0-9]#i', $i) && ! preg_match('#\.part\d+\.rar$#i', $i)) { $i = preg_replace('#\.rar(?:[^a-z0-9])#i', '.part0.rar', $i); diff --git a/Blacklight/NZBContents.php b/Blacklight/NZBContents.php index ba1940a1b..c398a78f8 100755 --- a/Blacklight/NZBContents.php +++ b/Blacklight/NZBContents.php @@ -265,7 +265,7 @@ class NZBContents $nzbFile = $this->LoadNZB($guid); if ($nzbFile !== false) { foreach ($nzbFile->file as $nzbContents) { - if ($nameStatus === 1 && $this->pp->parsePAR2((string) $nzbContents->segments->segment, $relID, $groupID, $this->nntp, $show) === true && preg_match('/\.(par[2" ]|\d{2,3}").+\(1\/1\)/i', (string) $nzbContents->attributes()->subject)) { + if ($nameStatus === 1 && $this->pp->parsePAR2((string) $nzbContents->segments->segment, $relID, $groupID, $this->nntp, $show) && preg_match('/\.(par[2" ]|\d{2,3}").+\(1\/1\)/i', (string) $nzbContents->attributes()->subject)) { Release::query()->where('id', $relID)->update(['proc_par2' => 1]); return true; diff --git a/Blacklight/NZBGet.php b/Blacklight/NZBGet.php index 24941bb77..afd21f02a 100755 --- a/Blacklight/NZBGet.php +++ b/Blacklight/NZBGet.php @@ -400,7 +400,7 @@ class NZBGet $value = (array) $member->value; $value = array_shift($value); if (! \is_object($value)) { - $retVal[(string) $member->name] = $value; + $retVal = [(string) $member->name => $value]; } } } diff --git a/Blacklight/NZBVortex.php b/Blacklight/NZBVortex.php index 32403a1c0..7f5a062ff 100755 --- a/Blacklight/NZBVortex.php +++ b/Blacklight/NZBVortex.php @@ -72,7 +72,7 @@ final class NZBVortex $response = $this->sendRequest(sprintf('app/webUpdate'), $params); foreach ($response['nzbs'] as &$nzb) { $nzb['original_state'] = $nzb['state']; - $nzb['state'] = (1 == $nzb['isPaused']) ? 'Paused' : $this->getState($nzb['state']); + $nzb['state'] = ($nzb['isPaused'] === true) ? 'Paused' : $this->getState($nzb['state']); } return $response; diff --git a/Blacklight/XXX.php b/Blacklight/XXX.php index b20ad047b..fcc209262 100755 --- a/Blacklight/XXX.php +++ b/Blacklight/XXX.php @@ -107,10 +107,10 @@ class XXX * Get XXX releases with covers for xxx browse page. * * @param $page - * @param $cat - * @param $start - * @param $num - * @param $orderBy + * @param $cat + * @param $start + * @param $num + * @param $orderBy * @param int $maxAge * @param array $excludedCats * @return array @@ -161,8 +161,8 @@ class XXX $xxxIDs = $releaseIDs = false; if (\is_array($xxxmovies['result'])) { foreach ($xxxmovies['result'] as $xxx => $id) { - $xxxIDs[] = $id->id; - $releaseIDs[] = $id->grp_release_id; + $xxxIDs = [$id->id]; + $releaseIDs = [$id->grp_release_id]; } } $sql = sprintf( @@ -265,7 +265,7 @@ class XXX { $browseBy = ' '; foreach (['title', 'director', 'actors', 'genre', 'id'] as $bb) { - if (isset($_REQUEST[$bb]) && ! empty($_REQUEST[$bb])) { + if (! empty($_REQUEST[$bb])) { $bbv = stripslashes($_REQUEST[$bb]); if ($bb === 'genre') { $bbv = $this->getGenreID($bbv); @@ -343,7 +343,7 @@ class XXX * @param bool $activeOnly * @return array */ - public function getAllGenres($activeOnly = false): array + public function getAllGenres(bool $activeOnly = false): array { $ret = []; if ($activeOnly) { @@ -352,11 +352,7 @@ class XXX $res = Genre::query()->where(['type' => Category::XXX_ROOT])->orderBy('title')->get(['title']); } - foreach ($res as $arr => $value) { - $ret[] = $value['title']; - } - - return $ret; + return array_column($res, 'title'); } /** diff --git a/Blacklight/http/API.php b/Blacklight/http/API.php index ae7343b4a..906365dff 100755 --- a/Blacklight/http/API.php +++ b/Blacklight/http/API.php @@ -67,7 +67,7 @@ class API extends Capabilities if (isset($release->id)) { $language = AudioData::query()->where('releases_id', $release->id)->first(['audiolanguage']); if ($language !== null) { - $releases[$key]->searchname .= ' '.$language['audiolanguage']; + $release->searchname .= ' '.$language['audiolanguage']; } } } @@ -186,7 +186,7 @@ class API extends Capabilities if ($releases && \count($releases)) { foreach ($releases as $key => $release) { if (isset($release->id)) { - $releases[$key]->coverurl = $getCoverURL($release); + $release->coverurl = $getCoverURL($release); } } } diff --git a/Blacklight/libraries/Geary.php b/Blacklight/libraries/Geary.php index 4c271083a..2a28355e9 100644 --- a/Blacklight/libraries/Geary.php +++ b/Blacklight/libraries/Geary.php @@ -25,7 +25,7 @@ if (! \function_exists('getAllHeaders')) { $headers = []; foreach ($_SERVER as $name => $value) { - if (strpos($name, 'HTTP_') === 0) { + if (str_starts_with($name, 'HTTP_')) { $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; } } diff --git a/Blacklight/processing/tv/TMDB.php b/Blacklight/processing/tv/TMDB.php index 53e1114d6..abebe26ee 100644 --- a/Blacklight/processing/tv/TMDB.php +++ b/Blacklight/processing/tv/TMDB.php @@ -271,7 +271,7 @@ class TMDB extends TV return false; } - if ($showAlternativeTitles !== null && \is_array($showAlternativeTitles)) { + if (\is_array($showAlternativeTitles)) { foreach ($showAlternativeTitles['results'] as $aka) { $highest['alternative_titles'][] = $aka['title']; }