diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index dc3d8aa74..bb9e1dfe0 100644 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -64,7 +64,7 @@ class Releases extends Release * @param int $minSize * @return Collection|mixed */ - public function getBrowseRange($page, $cat, $start, $num, $orderBy, int $maxAge = -1, array $excludedCats = [], int|string $groupName = -1, int $minSize = 0, array $tags = []) + public function getBrowseRange($page, $cat, $start, $num, $orderBy, int $maxAge = -1, array $excludedCats = [], int|string $groupName = -1, int $minSize = 0, array $tags = []): mixed { $orderBy = $this->getBrowseOrder($orderBy); @@ -161,7 +161,7 @@ class Releases extends Release /** * @return string */ - public function showPasswords() + public function showPasswords(): string { $show = (int) Settings::settingValue('..showpasswordedrelease'); $setting = $show ?? 0; @@ -217,13 +217,10 @@ class Releases extends Release } /** - * Get list of releases available for export. - * - * * @param string $postFrom * @param string $postTo * @param string $groupID - * @return Collection|\Illuminate\Support\Collection|static[] + * @return \App\Models\Release[]|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Query\Builder[]|\Illuminate\Support\Collection */ public function getForExport(string $postFrom = '', string $postTo = '', string $groupID = '') { @@ -257,13 +254,9 @@ class Releases extends Release } /** - * Get date in this format : 01/01/2014 of the oldest release. - * - * @note Used for exporting NZBs. - * - * @return mixed + * @return mixed|string */ - public function getEarliestUsenetPostDate() + public function getEarliestUsenetPostDate(): mixed { $row = self::query()->selectRaw("DATE_FORMAT(min(postdate), '%d/%m/%Y') AS postdate")->first(); @@ -271,13 +264,9 @@ class Releases extends Release } /** - * Get date in this format : 01/01/2014 of the newest release. - * - * @note Used for exporting NZBs. - * - * @return mixed + * @return mixed|string */ - public function getLatestUsenetPostDate() + public function getLatestUsenetPostDate(): mixed { $row = self::query()->selectRaw("DATE_FORMAT(max(postdate), '%d/%m/%Y') AS postdate")->first(); @@ -285,12 +274,7 @@ class Releases extends Release } /** - * Gets all groups for drop down selection on NZB-Export web page. - * * @param bool $blnIncludeAll - * - * @note Used for exporting NZBs. - * * @return array */ public function getReleasedGroupsForSelect(bool $blnIncludeAll = true): array @@ -313,16 +297,13 @@ class Releases extends Release } /** - * Get TV for My Shows page. - * - * * @param $userShows * @param $offset * @param $limit * @param $orderBy * @param int $maxAge * @param array $excludedCats - * @return Collection|mixed + * @return \Illuminate\Cache\|\Illuminate\Database\Eloquent\Collection|mixed */ public function getShowsRange($userShows, $offset, $limit, $orderBy, int $maxAge = -1, array $excludedCats = []) { @@ -363,9 +344,7 @@ class Releases extends Release } /** - * Get count for my shows page pagination. - * - * @param $userShows + * @param $userShows * @param int $maxAge * @param array $excludedCats * @return int @@ -393,9 +372,8 @@ class Releases extends Release } /** - * Delete multiple releases, or a single by ID. - * - * @param int|array|string $list Array of GUID or ID of releases to delete. + * @param int|array|string $list + * @return void * * @throws \Exception */ @@ -540,7 +518,7 @@ class Releases extends Release * @throws \Foolz\SphinxQL\Exception\DatabaseException * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ - public function search(array $searchArr, $groupName, $sizeFrom, $sizeTo, $daysNew, $daysOld, int $offset = 0, int $limit = 1000, array|string $orderBy = '', int $maxAge = -1, array $excludedCats = [], string $type = 'basic', array $cat = [-1], int $minSize = 0, array $tags = []) + public function search(array $searchArr, $groupName, $sizeFrom, $sizeTo, $daysNew, $daysOld, int $offset = 0, int $limit = 1000, array|string $orderBy = '', int $maxAge = -1, array $excludedCats = [], string $type = 'basic', array $cat = [-1], int $minSize = 0, array $tags = []): mixed { $sizeRange = [ 1 => 1, @@ -816,7 +794,7 @@ class Releases extends Release if (! empty($name) && $showSql === '') { if (! empty($series) && (int) $series < 1900) { $name .= sprintf(' S%s', str_pad($series, 2, '0', STR_PAD_LEFT)); - if (! empty($episode) && strpos($episode, '/') === false) { + if (! empty($episode) && ! str_contains($episode, '/')) { $name .= sprintf('E%s', str_pad($episode, 2, '0', STR_PAD_LEFT)); } } elseif (! empty($airDate)) { @@ -917,7 +895,7 @@ class Releases extends Release * @throws \Foolz\SphinxQL\Exception\DatabaseException * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ - public function apiTvSearch(array $siteIdArr = [], string $series = '', string $episode = '', string $airDate = '', int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = [], array $tags = []) + public function apiTvSearch(array $siteIdArr = [], string $series = '', string $episode = '', string $airDate = '', int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = [], array $tags = []): mixed { $siteSQL = []; $showSql = ''; @@ -945,7 +923,7 @@ class Releases extends Release ); $show = self::fromQuery($showQry); if ($show->isNotEmpty()) { - if ((! empty($series) || ! empty($episode) || ! empty($airDate)) && $show[0]->episodes != '') { + if ((! empty($series) || ! empty($episode) || ! empty($airDate)) && $show[0]->episodes !== '') { $showSql = sprintf('AND r.tv_episodes_id IN (%s)', $show[0]->episodes); } elseif ((int) $show[0]->video > 0) { $showSql = 'AND r.videos_id = '.$show[0]->video; @@ -1056,7 +1034,7 @@ class Releases extends Release * @throws \Foolz\SphinxQL\Exception\DatabaseException * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ - public function animeSearch($aniDbID, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, array $excludedCategories = []) + public function animeSearch($aniDbID, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, array $excludedCategories = []): mixed { if (! empty($name)) { if (config('nntmux.elasticsearch_enabled') === true) { @@ -1140,7 +1118,7 @@ class Releases extends Release * @throws \Foolz\SphinxQL\Exception\DatabaseException * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ - public function moviesSearch(int $imDbId = -1, int $tmDbId = -1, int $traktId = -1, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = [], array $tags = []) + public function moviesSearch(int $imDbId = -1, int $tmDbId = -1, int $traktId = -1, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = [], array $tags = []): mixed { if (! empty($name)) { if (config('nntmux.elasticsearch_enabled') === true) { @@ -1219,7 +1197,7 @@ class Releases extends Release * @throws \Foolz\SphinxQL\Exception\DatabaseException * @throws \Foolz\SphinxQL\Exception\SphinxQLException */ - public function searchSimilar($currentID, $name, array $excludedCats = []) + public function searchSimilar($currentID, $name, array $excludedCats = []): bool|array { // Get the category for the parent of this release. $ret = false; diff --git a/app/Http/Controllers/Api/API.php b/app/Http/Controllers/Api/API.php index b603f37c6..4089b9806 100644 --- a/app/Http/Controllers/Api/API.php +++ b/app/Http/Controllers/Api/API.php @@ -172,7 +172,7 @@ class API extends Capabilities */ public function verifyEmptyParameter(string $parameter): void { - if (request()->has($parameter) && ! request()->filled($parameter)) { + if (request()->has($parameter) && request()->isNotFilled($parameter)) { Utility::showApiError(201, 'Incorrect parameter ('.$parameter.' must not be empty)'); } } diff --git a/app/Http/Controllers/Api/ApiController.php b/app/Http/Controllers/Api/ApiController.php index e9ba53d5c..9480cacac 100644 --- a/app/Http/Controllers/Api/ApiController.php +++ b/app/Http/Controllers/Api/ApiController.php @@ -233,9 +233,9 @@ class ApiController extends BasePageController $maxAge = $api->maxAge(); UserRequest::addApiRequest($apiKey, $request->getRequestUri()); - $imdbId = $request->has('imdbid') && ! empty($request->input('imdbid')) ? (int) $request->input('imdbid') : -1; - $tmdbId = $request->has('tmdbid') && ! empty($request->input('tmdbid')) ? (int) $request->input('tmdbid') : -1; - $traktId = $request->has('traktid') && ! empty($request->input('traktid')) ? (int) $request->input('traktid') : -1; + $imdbId = $request->has('imdbid') && $request->filled('imdbid') ? (int) $request->input('imdbid') : -1; + $tmdbId = $request->has('tmdbid') && $request->filled('tmdbid') ? (int) $request->input('tmdbid') : -1; + $traktId = $request->has('traktid') && $request->filled('traktid') ? (int) $request->input('traktid') : -1; $relData = $releases->moviesSearch( $imdbId, diff --git a/app/Http/Controllers/Api/ApiV2Controller.php b/app/Http/Controllers/Api/ApiV2Controller.php index 3a8556237..4545ad0a3 100644 --- a/app/Http/Controllers/Api/ApiV2Controller.php +++ b/app/Http/Controllers/Api/ApiV2Controller.php @@ -15,6 +15,7 @@ use App\Transformers\CategoryTransformer; use App\Transformers\DetailsTransformer; use Blacklight\Releases; use Blacklight\utility\Utility; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Carbon; @@ -23,7 +24,7 @@ class ApiV2Controller extends BasePageController /** * @return \Illuminate\Http\JsonResponse */ - public function capabilities(): \Illuminate\Http\JsonResponse + public function capabilities(): JsonResponse { $category = Category::getForApi(); @@ -63,7 +64,7 @@ class ApiV2Controller extends BasePageController * @throws \Foolz\SphinxQL\Exception\SphinxQLException * @throws \Throwable */ - public function movie(Request $request): \Illuminate\Http\JsonResponse + public function movie(Request $request): JsonResponse { $api = new API(); $releases = new Releases(); @@ -119,7 +120,7 @@ class ApiV2Controller extends BasePageController * @throws \Exception * @throws \Throwable */ - public function apiSearch(Request $request): \Illuminate\Http\JsonResponse + public function apiSearch(Request $request): JsonResponse { $api = new API(); $releases = new Releases(); @@ -188,7 +189,7 @@ class ApiV2Controller extends BasePageController * @throws \Exception * @throws \Throwable */ - public function tv(Request $request): \Illuminate\Http\JsonResponse + public function tv(Request $request): JsonResponse { $api = new API(); $releases = new Releases(); @@ -225,15 +226,15 @@ class ApiV2Controller extends BasePageController $series = $request->input('season') ?? ''; $episode = $request->input('ep') ?? ''; - if (preg_match('#^(19|20)\d{2}$#', $series, $year) && strpos($episode, '/') !== false) { - $airdate = str_replace('/', '-', $year[0].'-'.$episode); + if (preg_match('#^(19|20)\d{2}$#', $series, $year) && str_contains($episode, '/')) { + $airDate = str_replace('/', '-', $year[0].'-'.$episode); } $relData = $releases->apiTvSearch( $siteIdArr, $series, $episode, - $airdate ?? '', + $airDate ?? '', $api->offset(), $api->limit(), $request->input('id') ?? '', @@ -265,7 +266,7 @@ class ApiV2Controller extends BasePageController /** * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|void */ public function getNzb(Request $request) { @@ -284,7 +285,7 @@ class ApiV2Controller extends BasePageController * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ - public function details(Request $request): \Illuminate\Http\JsonResponse + public function details(Request $request): JsonResponse { if ($request->missing('id')) { Utility::showApiError(200, 'Missing parameter (guid is required for single release details)'); diff --git a/app/Http/Controllers/Api/XML_Response.php b/app/Http/Controllers/Api/XML_Response.php index c1e26a785..3b390fb26 100644 --- a/app/Http/Controllers/Api/XML_Response.php +++ b/app/Http/Controllers/Api/XML_Response.php @@ -674,7 +674,7 @@ class XML_Response * @param array $columns The columns in the release we need to insert * @return string The HTML format cData */ - protected function buildCdata($columns): string + protected function buildCdata(array $columns): string { $cData = '';