diff --git a/Blacklight/libraries/Forking.php b/Blacklight/libraries/Forking.php index 1046725ea..b19de868c 100755 --- a/Blacklight/libraries/Forking.php +++ b/Blacklight/libraries/Forking.php @@ -460,7 +460,7 @@ class Forking /** * @throws \Exception */ - private function safeBinaries() + private function safeBinaries(): void { $maxHeaders = (int) Settings::settingValue('..max_headers_iteration') ?: 1000000; $maxMessages = (int) Settings::settingValue('..maxmssgs'); diff --git a/Blacklight/processing/PostProcess.php b/Blacklight/processing/PostProcess.php index fe9528811..03b7e95ac 100755 --- a/Blacklight/processing/PostProcess.php +++ b/Blacklight/processing/PostProcess.php @@ -31,12 +31,12 @@ class PostProcess /** * @var \Blacklight\NameFixer */ - protected $nameFixer; + protected NameFixer $nameFixer; /** * @var \dariusiii\rarinfo\Par2Info */ - protected $_par2Info; + protected Par2Info $_par2Info; /** * @var @@ -48,26 +48,26 @@ class PostProcess * * @var bool */ - private $alternateNNTP; + private bool $alternateNNTP; /** * Add par2 info to rar list? * * @var bool */ - private $addpar2; + private bool $addpar2; /** * Should we echo to CLI? * * @var bool */ - private $echooutput; + private bool $echooutput; /** * @var \Blacklight\Nfo */ - private $Nfo; + private Nfo $Nfo; /** * Constructor. @@ -183,7 +183,7 @@ class PostProcess * * @throws \Exception */ - public function processMovies($groupID = '', $guidChar = '', $processMovies = ''): void + public function processMovies(string $groupID = '', string $guidChar = '', int|string|null $processMovies = ''): void { $processMovies = (is_numeric($processMovies) ? $processMovies : Settings::settingValue('..lookupimdb')); if ($processMovies > 0) { @@ -211,7 +211,7 @@ class PostProcess * * @throws \Exception */ - public function processNfos(&$nntp, $groupID = '', $guidChar = ''): void + public function processNfos(NNTP $nntp, string $groupID = '', string $guidChar = ''): void { if ((int) Settings::settingValue('..lookupnfo') === 1) { $this->Nfo->processNfoFiles($nntp, $groupID, $guidChar, (int) Settings::settingValue('..lookupimdb'), (int) Settings::settingValue('..lookuptvrage')); @@ -225,7 +225,7 @@ class PostProcess * * @throws \Exception */ - public function processSharing(&$nntp): void + public function processSharing(NNTP $nntp): void { (new Sharing(['NNTP' => $nntp]))->start(); } @@ -235,13 +235,13 @@ class PostProcess * * @param string $groupID (Optional) ID of a group to work on. * @param string $guidChar (Optional) First letter of a release GUID to use to get work. - * @param string|int|null $processTV (Optional) 0 Don't process, 1 process all releases, + * @param int|string|null $processTV (Optional) 0 Don't process, 1 process all releases, * 2 process renamed releases only, '' check site setting * @return void * * @throws \Exception */ - public function processTv($groupID = '', $guidChar = '', $processTV = ''): void + public function processTv(string $groupID = '', string $guidChar = '', int|string|null $processTV = ''): void { $processTV = (is_numeric($processTV) ? $processTV : Settings::settingValue('..lookuptvrage')); if ($processTV > 0) { @@ -276,7 +276,7 @@ class PostProcess * * @throws \Exception */ - public function processAdditional(&$nntp, $groupID = '', $guidChar = ''): void + public function processAdditional(NNTP $nntp, int|string $groupID = '', string $guidChar = ''): void { (new ProcessAdditional(['Echo' => $this->echooutput, 'NNTP' => $nntp, 'NameFixer' => $this->nameFixer, 'Nfo' => $this->Nfo]))->start($groupID, $guidChar); } @@ -295,7 +295,7 @@ class PostProcess * * @throws \Exception */ - public function parsePAR2($messageID, $relID, $groupID, &$nntp, $show): bool + public function parsePAR2(string $messageID, int $relID, int $groupID, NNTP $nntp, int $show): bool { if ($messageID === '') { return false; diff --git a/Blacklight/processing/ProcessReleases.php b/Blacklight/processing/ProcessReleases.php index 53f2c7f0f..3a8f15dd5 100755 --- a/Blacklight/processing/ProcessReleases.php +++ b/Blacklight/processing/ProcessReleases.php @@ -540,7 +540,7 @@ class ProcessReleases if ($releaseID !== null) { // Update collections table to say we inserted the release. - DB::transaction(function () use ($collection, $releaseID) { + DB::transaction(static function () use ($collection, $releaseID) { Collection::query()->where('id', $collection->id)->update(['filecheck' => self::COLLFC_INSERTED, 'releases_id' => $releaseID]); }, 10); @@ -1054,7 +1054,7 @@ class ProcessReleases */ private function collectionFileCheckStage1(int $groupID): void { - DB::transaction(function () use ($groupID) { + DB::transaction(static function () use ($groupID) { $collectionsCheck = Collection::query()->select(['collections.id']) ->join('binaries', 'binaries.collections_id', '=', 'collections.id') ->where('collections.totalfiles', '>', 0) @@ -1087,7 +1087,7 @@ class ProcessReleases */ private function collectionFileCheckStage2(int $groupID): void { - DB::transaction(function () use ($groupID) { + DB::transaction(static function () use ($groupID) { $collectionsCheck = Collection::query()->select(['collections.id']) ->join('binaries', 'binaries.collections_id', '=', 'collections.id') ->where('binaries.filenumber', '=', 0) @@ -1103,7 +1103,7 @@ class ProcessReleases })->update(['collections.filecheck' => self::COLLFC_ZEROPART]); }, 10); - DB::transaction(function () use ($groupID) { + DB::transaction(static function () use ($groupID) { $collectionQuery = Collection::query()->where('filecheck', '=', self::COLLFC_COMPCOLL); if (! empty($groupID)) { $collectionQuery->where('groups_id', $groupID); diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php index 90b1d420e..1a663b184 100755 --- a/Blacklight/processing/post/ProcessAdditional.php +++ b/Blacklight/processing/post/ProcessAdditional.php @@ -979,7 +979,6 @@ class ProcessAdditional $failed = $downloaded = 0; // Loop through the files, attempt to find if password-ed and files. Starting with what not to process. foreach ($this->_nzbContents as $nzbFile) { - // TODO change this to max calculated size, as segments vary in size greatly. if ($downloaded >= $this->_maximumRarSegments) { break; } @@ -1662,7 +1661,7 @@ class ProcessAdditional * @param string $path * @return bool|string|\Symfony\Component\Finder\SplFileInfo[] */ - protected function _getTempDirectoryContents(string $pattern = '', string $path = '') + protected function _getTempDirectoryContents(string $pattern = '', string $path = ''): array|bool|string { if ($path === '') { $path = $this->tmpPath; @@ -2027,16 +2026,11 @@ class ProcessAdditional $lowestLength = ($numbers[1] - $this->_ffMPEGDuration); // Form the time string. $end = '.'.$numbers[2]; - switch (\strlen($lowestLength)) { - case 1: - $lowestLength = ('00:00:0'.$lowestLength.$end); - break; - case 2: - $lowestLength = ('00:00:'.$lowestLength.$end); - break; - default: - $lowestLength = '00:00:60.00'; - } + $lowestLength = match (\strlen($lowestLength)) { + 1 => ('00:00:0'.$lowestLength.$end), + 2 => ('00:00:'.$lowestLength.$end), + default => '00:00:60.00', + }; } // Try to get the sample (from the end instead of the start). diff --git a/Blacklight/processing/tv/TMDB.php b/Blacklight/processing/tv/TMDB.php index e359d1be2..5f2f2b59b 100644 --- a/Blacklight/processing/tv/TMDB.php +++ b/Blacklight/processing/tv/TMDB.php @@ -3,6 +3,7 @@ namespace Blacklight\processing\tv; use Blacklight\ReleaseImage; +use JetBrains\PhpStorm\ArrayShape; use Tmdb\Client; use Tmdb\Exception\TmdbApiException; use Tmdb\Helper\ImageHelper; @@ -17,39 +18,27 @@ class TMDB extends TV /** * @string URL for show poster art */ - public $posterUrl = ''; + public string $posterUrl = ''; /** * @var ApiToken */ - public $token; + public ApiToken $token; /** * @var Client */ - public $client; + public Client $client; /** * @var ConfigurationRepository */ - public $configRepository; + public ConfigurationRepository $configRepository; /** * @var \Tmdb\Model\Configuration */ - public $config; + public \Tmdb\Model\Configuration $config; /** * @var ImageHelper */ - public $helper; - - /** - * Construct. Instantiate TMDB Class. - * - * @param array $options Class instances. - * - * @throws \Exception - */ - public function __construct(array $options = []) - { - parent::__construct($options); - } + public ImageHelper $helper; /** * Fetch banner from site. @@ -209,10 +198,10 @@ class TMDB extends TV * Calls the API to perform initial show name match to TMDB title * Returns a formatted array of show data or false if no match. * - * @param $cleanName + * @param string $cleanName * @return array|false */ - protected function getShowInfo($cleanName) + protected function getShowInfo($cleanName): bool|array { $return = $response = false; @@ -236,7 +225,7 @@ class TMDB extends TV * @param string $cleanName * @return array|false */ - private function matchShowInfo($shows, $cleanName) + private function matchShowInfo(array $shows, string $cleanName): bool|array { $return = false; $highestMatch = 0; @@ -320,7 +309,7 @@ class TMDB extends TV * @param int $videoId * @return array|false */ - protected function getEpisodeInfo($tmdbid, $season, $episode, $airdate = '', $videoId = 0) + protected function getEpisodeInfo($tmdbid, $season, $episode, $airdate = '', $videoId = 0): bool|array { $return = false; @@ -381,7 +370,15 @@ class TMDB extends TV * @param $episode * @return array */ - protected function formatEpisodeInfo($episode): array + #[ArrayShape([ + 'title' => 'string', + 'series' => 'int', + 'episode' => 'int', + 'se_complete' => 'string', + 'firstaired' => 'string', + 'summary' => 'string', + ])] + protected function formatEpisodeInfo($episode): array { return [ 'title' => (string) $episode['name'], diff --git a/misc/update/multiprocessing/.do_not_run/switch.php b/misc/update/multiprocessing/.do_not_run/switch.php index 91d246849..98df65d6c 100644 --- a/misc/update/multiprocessing/.do_not_run/switch.php +++ b/misc/update/multiprocessing/.do_not_run/switch.php @@ -388,7 +388,7 @@ switch ($options[1]) { * * @throws \Throwable */ -function processReleases($releases, $groupID) +function processReleases(ProcessReleases $releases, $groupID): void { $releaseCreationLimit = (Settings::settingValue('..maxnzbsprocessed') !== '' ? (int) Settings::settingValue('..maxnzbsprocessed') : 1000); $releases->processIncompleteCollections($groupID); @@ -410,24 +410,20 @@ function processReleases($releases, $groupID) * @param string $char * @return bool */ -function charCheck($char) +function charCheck($char): bool { - if (\in_array($char, ['a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], true)) { - return true; - } - - return false; + return \in_array($char, ['a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], true); } /** * Connect to usenet, return NNTP object. * - * @param bool $alternate Use alternate NNTP provider. + * @param bool $alternate Use alternate NNTP provider. * @return NNTP * * @throws \Exception */ -function &nntp($alternate = false) +function &nntp(bool $alternate = false) { $nntp = new NNTP(); if (($alternate && (int) Settings::settingValue('..alternate_nntp') === 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) {