Add PHP type hints

This commit is contained in:
Shift
2023-03-30 14:15:39 +00:00
parent 5e7a2d9254
commit afb0f41611
220 changed files with 523 additions and 469 deletions
+2 -1
View File
@@ -2,6 +2,7 @@
namespace Blacklight;
use Illuminate\Database\Eloquent\Model;
use App\Models\BookInfo;
use App\Models\Category;
use App\Models\Release;
@@ -95,7 +96,7 @@ class Books
/**
* @return \Illuminate\Database\Eloquent\Model
*/
public function getBookInfoByName($title)
public function getBookInfoByName($title): Model
{
//only used to get a count of words
$searchWords = '';
+3 -3
View File
@@ -125,7 +125,7 @@ class Console
* @param string $platform
* @return false|\Illuminate\Database\Eloquent\Model
*/
public function getConsoleInfoByName($title, $platform)
public function getConsoleInfoByName(string $title, string $platform)
{
//only used to get a count of words
$searchWords = '';
@@ -300,7 +300,7 @@ class Console
/**
* @param string $review
*/
public function update($id, $title, $asin, $url, $salesrank, $platform, $publisher, $releasedate, $esrb, $cover, $genres_id, $review = 'review'): void
public function update($id, $title, $asin, $url, $salesrank, $platform, $publisher, $releasedate, $esrb, $cover, $genres_id, string $review = 'review'): void
{
$releasedate = $releasedate !== '' ? $releasedate : 'null';
$review = $review === 'review' ? $review : substr($review, 0, 3000);
@@ -515,7 +515,7 @@ class Console
*
* @param string $platform
*/
protected function _replacePlatform($platform): string
protected function _replacePlatform(string $platform): string
{
switch (strtoupper($platform)) {
case 'X360':
+2 -2
View File
@@ -41,7 +41,7 @@ class Genres
* @param bool $activeOnly
* @return array|mixed
*/
public function getGenres($type = '', $activeOnly = false)
public function getGenres(string $type = '', bool $activeOnly = false)
{
$sql = $this->getListQuery($type, $activeOnly);
$genres = Cache::get(md5($sql));
@@ -70,7 +70,7 @@ class Genres
* @param string $type
* @param bool $activeOnly
*/
private function getListQuery($type = '', $activeOnly = false): string
private function getListQuery(string $type = '', bool $activeOnly = false): string
{
if (! empty($type)) {
$typesql = sprintf(' AND g.type = %d', $type);
+14 -14
View File
@@ -188,7 +188,7 @@ class IRCClient
*
* @param int $timeout Seconds.
*/
public function setSocketTimeout($timeout)
public function setSocketTimeout(int $timeout)
{
if (! is_numeric($timeout)) {
echo 'ERROR: IRC socket timeout must be a number!'.PHP_EOL;
@@ -202,7 +202,7 @@ class IRCClient
*
* @param int $timeout Seconds.
*/
public function setConnectionTimeout($timeout)
public function setConnectionTimeout(int $timeout)
{
if (! is_numeric($timeout)) {
echo 'ERROR: IRC connection timeout must be a number!'.PHP_EOL;
@@ -216,7 +216,7 @@ class IRCClient
*
* @param int $retries
*/
public function setConnectionRetries($retries)
public function setConnectionRetries(int $retries)
{
if (! is_numeric($retries)) {
echo 'ERROR: IRC connection retries must be a number!'.PHP_EOL;
@@ -230,7 +230,7 @@ class IRCClient
*
* @param int $delay Seconds.
*/
public function setReConnectDelay($delay)
public function setReConnectDelay(int $delay)
{
if (! is_numeric($delay)) {
echo 'ERROR: IRC reconnect delay must be a number!'.PHP_EOL;
@@ -247,7 +247,7 @@ class IRCClient
* @param bool $tls Use encryption for the socket transport? (make sure the port is right).
* @return bool
*/
public function connect($hostname, $port = 6667, $tls = false)
public function connect(string $hostname, int $port = 6667, bool $tls = false): bool
{
$this->_alreadyLoggedIn = false;
$transport = ($tls === true ? 'tls' : 'tcp');
@@ -303,7 +303,7 @@ class IRCClient
* @param null $password The password - some servers require a password.
* @return bool
*/
public function login($nickName, $userName, $realName, $password = null)
public function login(string $nickName, string $userName, string $realName, $password = null): bool
{
if (! $this->_connected()) {
echo 'ERROR: You must connect to IRC first!'.PHP_EOL;
@@ -386,7 +386,7 @@ class IRCClient
* @param string $message Optional disconnect message.
* @return bool
*/
public function quit($message = null)
public function quit(string $message = null): bool
{
if ($this->_connected()) {
$this->_writeSocket('QUIT'.($message === null ? '' : ' :'.$message));
@@ -441,7 +441,7 @@ class IRCClient
* array( '#exampleChannel' => 'thePassword', '#exampleChan2' => null );
* @return bool
*/
public function joinChannels($channels = [])
public function joinChannels(array $channels = []): bool
{
$this->_channels = $channels;
@@ -474,7 +474,7 @@ class IRCClient
* @param string $channel
* @param string $password
*/
protected function _joinChannel($channel, $password)
protected function _joinChannel(string $channel, string $password)
{
$this->_writeSocket('JOIN '.$channel.(empty($password) ? '' : ' '.$password));
}
@@ -484,7 +484,7 @@ class IRCClient
*
* @param string $host
*/
protected function _pong($host)
protected function _pong(string $host)
{
if ($this->_writeSocket('PONG '.$host) === false) {
$this->_reconnect();
@@ -501,7 +501,7 @@ class IRCClient
*
* @param string $host
*/
protected function _ping($host)
protected function _ping(string $host)
{
$pong = $this->_writeSocket('PING '.$host);
@@ -557,7 +557,7 @@ class IRCClient
* @param string $command
* @return bool
*/
protected function _writeSocket($command)
protected function _writeSocket(string $command): bool
{
$command .= "\r\n";
for ($written = 0, $writtenMax = \strlen($command); $written < $writtenMax; $written += $fWrite) {
@@ -632,7 +632,7 @@ class IRCClient
*
* @return bool
*/
protected function _connected()
protected function _connected(): bool
{
return \is_resource($this->_socket) && ! feof($this->_socket);
}
@@ -643,7 +643,7 @@ class IRCClient
* @param string $text
* @return string
*/
protected function _stripControlCharacters($text)
protected function _stripControlCharacters(string $text): string
{
return preg_replace(
[
+2 -2
View File
@@ -406,7 +406,7 @@ class IRCScraper extends IRCClient
*
* @param bool $new
*/
protected function _doEcho($new = true)
protected function _doEcho(bool $new = true)
{
if (! $this->_silent) {
$nukeString = '';
@@ -463,7 +463,7 @@ class IRCScraper extends IRCClient
* @param string $groupName
* @return mixed
*/
protected function _getGroupID($groupName)
protected function _getGroupID(string $groupName)
{
if (! isset($this->_groupList[$groupName])) {
$group = UsenetGroup::query()->where('name', $groupName)->first(['id']);
+9 -9
View File
@@ -216,7 +216,7 @@ class Movie
* @param int $maxAge
* @return array|mixed
*/
public function getMovieRange($page, $cat, $start, $num, $orderBy, $maxAge = -1, array $excludedCats = [])
public function getMovieRange($page, $cat, $start, $num, $orderBy, int $maxAge = -1, array $excludedCats = [])
{
$catsrch = '';
if (\count($cat) > 0 && $cat[0] !== -1) {
@@ -381,7 +381,7 @@ class Movie
*
* @throws \Exception
*/
public function getTrailer($imdbId)
public function getTrailer(int $imdbId)
{
$trailer = MovieInfo::query()->where('imdbid', $imdbId)->where('trailer', '<>', '')->first(['trailer']);
if ($trailer !== null) {
@@ -411,7 +411,7 @@ class Movie
* @param array $data
* @return mixed
*/
public function parseTraktTv(&$data)
public function parseTraktTv(array &$data)
{
if (empty($data['ids']['imdb'])) {
return false;
@@ -521,7 +521,7 @@ class Movie
* @param string $variable5
* @return array|string
*/
protected function setVariables($variable1, $variable2, $variable3, $variable4, $variable5)
protected function setVariables(string $variable1, string $variable2, string $variable3, string $variable4, string $variable5)
{
if (! empty($variable1)) {
return $variable1;
@@ -744,7 +744,7 @@ class Movie
* @param bool $text
* @return array|false
*/
public function fetchTMDBProperties($imdbId, $text = false)
public function fetchTMDBProperties($imdbId, bool $text = false)
{
$lookupId = $text === false && (\strlen($imdbId) === 7 || strlen($imdbId) === 8) ? 'tt'.$imdbId : $imdbId;
@@ -1005,7 +1005,7 @@ class Movie
* @throws \DariusIII\ItunesApi\Exceptions\InvalidProviderException
* @throws \Exception
*/
public function fetchItunesMovieProperties($title)
public function fetchItunesMovieProperties(string $title)
{
$movie = true;
try {
@@ -1046,7 +1046,7 @@ class Movie
*
* @throws \Exception
*/
public function doMovieUpdate($buffer, $service, $id, $processImdb = 1): string
public function doMovieUpdate(string $buffer, string $service, int $id, int $processImdb = 1): string
{
$imdbId = false;
if (\is_string($buffer) && preg_match('/(?:imdb.*?)?(?:tt|Title\?)(?P<imdbid>\d{5,8})/i', $buffer, $hits)) {
@@ -1092,7 +1092,7 @@ class Movie
*
* @throws \Exception
*/
public function processMovieReleases($groupID = '', $guidChar = '', $lookupIMDB = 1): void
public function processMovieReleases(string $groupID = '', string $guidChar = '', int $lookupIMDB = 1): void
{
if ($lookupIMDB === 0) {
return;
@@ -1280,7 +1280,7 @@ class Movie
*
* @param string $releaseName
*/
protected function parseMovieSearchName($releaseName): bool
protected function parseMovieSearchName(string $releaseName): bool
{
$name = $year = '';
$followingList = '[^\w]((1080|480|720)p|AC3D|Directors([^\w]CUT)?|DD5\.1|(DVD|BD|BR)(Rip)?|BluRay|divx|HDTV|iNTERNAL|LiMiTED|(Real\.)?Proper|RE(pack|Rip)|Sub\.?(fix|pack)|Unrated|WEB-DL|(x|H)[ ._-]?264|xvid)[^\w]';
+3 -3
View File
@@ -405,7 +405,7 @@ class Music
*
* @throws \Exception
*/
public function processMusicReleases($local = false)
public function processMusicReleases(bool $local = false)
{
$res = DB::select(
sprintf(
@@ -484,7 +484,7 @@ class Music
* @param string $releaseName
* @return array|false
*/
public function parseArtist($releaseName)
public function parseArtist(string $releaseName)
{
if (preg_match('/(.+?)(\d{1,2} \d{1,2} )?\(?(19\d{2}|20[0-1][\d])\b/', $releaseName, $name)) {
$result = [];
@@ -624,7 +624,7 @@ class Music
* @throws \DariusIII\ItunesApi\Exceptions\InvalidProviderException
* @throws \Exception
*/
protected function fetchItunesMusicProperties($title)
protected function fetchItunesMusicProperties(string $title)
{
$mus = true;
// Load genres.
+4 -4
View File
@@ -356,7 +356,7 @@ class NNTP extends \Net_NNTP_Client
* @throws \Exception
* On failure : (object) PEAR_Error.
*/
public function selectGroup($group, $articles = false, bool $force = false): mixed
public function selectGroup(string $group, bool $articles = false, bool $force = false): mixed
{
$connected = $this->_checkConnection(false);
if ($connected !== true) {
@@ -384,7 +384,7 @@ class NNTP extends \Net_NNTP_Client
* @throws \Exception
* On failure : (object) PEAR_Error.
*/
public function getOverview($range = null, $names = true, $forceNames = true): mixed
public function getOverview(string $range = null, bool $names = true, bool $forceNames = true): mixed
{
$connected = $this->_checkConnection();
if ($connected !== true) {
@@ -507,7 +507,7 @@ class NNTP extends \Net_NNTP_Client
*
* @throws \Exception
*/
public function getGroups($wildMat = null)
public function getGroups(string $wildMat = null)
{
// Enabled header compression if not enabled.
$this->_enableCompression();
@@ -1300,7 +1300,7 @@ class NNTP extends \Net_NNTP_Client
* @return mixed (bool) On success: True when posting allowed, otherwise false.
* (object) On failure: pear_error
*/
public function connect($host = null, $encryption = null, $port = null, $timeout = 15, int $socketTimeout = 120): mixed
public function connect(string $host = null, $encryption = null, int $port = null, int $timeout = 15, int $socketTimeout = 120): mixed
{
if ($this->_isConnected()) {
return $this->throwError('Already connected, disconnect first!', null);
+2 -2
View File
@@ -144,7 +144,7 @@ class NZBContents
*
* @throws \Exception
*/
public function parseNZB($guid, $relID, $groupID, $nfoCheck = false)
public function parseNZB($guid, $relID, $groupID, bool $nfoCheck = false)
{
$nzbFile = $this->LoadNZB($guid);
if ($nzbFile !== false) {
@@ -251,7 +251,7 @@ class NZBContents
*
* @throws \Exception
*/
public function checkPAR2($guid, $relID, $groupID, $nameStatus, $show): bool
public function checkPAR2(string $guid, int $relID, int $groupID, int $nameStatus, int $show): bool
{
$nzbFile = $this->LoadNZB($guid);
if ($nzbFile !== false) {
+3 -3
View File
@@ -129,7 +129,7 @@ class NZBImport
*
* @throws \Exception
*/
public function beginImport($filesToProcess, $useNzbName = false, $delete = true, $deleteFailed = true)
public function beginImport(array $filesToProcess, $useNzbName = false, bool $delete = true, bool $deleteFailed = true)
{
// Get all the groups in the DB.
if (! $this->getAllGroups()) {
@@ -245,7 +245,7 @@ class NZBImport
*
* @throws \Exception
*/
protected function scanNZBFile(&$nzbXML, $useNzbName = false): bool
protected function scanNZBFile(&$nzbXML, bool $useNzbName = false): bool
{
$binary_names = [];
$totalFiles = $totalSize = $groupID = 0;
@@ -459,7 +459,7 @@ class NZBImport
*
* @param string $message
*/
protected function echoOut($message): void
protected function echoOut(string $message): void
{
if ($this->browser) {
$this->retVal .= $message.'<br />';
+1 -1
View File
@@ -1454,7 +1454,7 @@ class NameFixer
*
* @throws \Exception
*/
public function tvCheck($release, $echo, $type, $nameStatus, $show): void
public function tvCheck($release, bool $echo, string $type, $nameStatus, $show): void
{
$result = [];
+4 -4
View File
@@ -88,7 +88,7 @@ class Nfo
* @param string $str The string with a Show ID.
* @return array|false Return array with show ID and site source or false on failure.
*/
public function parseShowId($str)
public function parseShowId(string $str)
{
$return = false;
@@ -128,7 +128,7 @@ class Nfo
*
* @throws \Exception
*/
public function isNFO(&$possibleNFO, $guid): bool
public function isNFO(&$possibleNFO, string $guid): bool
{
if ($possibleNFO === false) {
return false;
@@ -195,7 +195,7 @@ class Nfo
*
* @throws \Exception
*/
public function addAlternateNfo(&$nfo, $release, $nntp): bool
public function addAlternateNfo(string &$nfo, $release, NNTP $nntp): bool
{
if ($release->id > 0 && $this->isNFO($nfo, $release->guid)) {
$check = ReleaseNfo::whereReleasesId($release->id)->first(['releases_id']);
@@ -240,7 +240,7 @@ class Nfo
*
* @throws \Exception
*/
public function processNfoFiles($nntp, $groupID = '', $guidChar = '', $processImdb = 1, $processTv = 1): int
public function processNfoFiles($nntp, string $groupID = '', string $guidChar = '', int $processImdb = 1, int $processTv = 1): int
{
$ret = 0;
+7 -7
View File
@@ -98,7 +98,7 @@ class Regexes
*
* @param int $id
*/
public function getRegexByID($id): array
public function getRegexByID(int $id): array
{
return (array) Arr::first(DB::select(sprintf('SELECT * FROM %s WHERE id = %d LIMIT 1', $this->tableName, $id)));
}
@@ -107,7 +107,7 @@ class Regexes
* @param string $group_regex
* @return mixed
*/
public function getRegex($group_regex = '')
public function getRegex(string $group_regex = '')
{
if ($this->tableName === 'collection_regexes') {
$table = CollectionRegex::class;
@@ -131,7 +131,7 @@ class Regexes
*
* @param string $group_regex Optional, keyword to find a group.
*/
public function getCount($group_regex = ''): int
public function getCount(string $group_regex = ''): int
{
$query = DB::select(
sprintf(
@@ -151,7 +151,7 @@ class Regexes
*
* @throws \Throwable
*/
public function deleteRegex($id): void
public function deleteRegex(int $id): void
{
DB::transaction(function () use ($id) {
DB::delete(sprintf('DELETE FROM %s WHERE id = %d', $this->tableName, $id));
@@ -169,7 +169,7 @@ class Regexes
*
* @throws \Exception
*/
public function testCollectionRegex($groupName, $regex, $limit): array
public function testCollectionRegex(string $groupName, string $regex, int $limit): array
{
$groupID = UsenetGroup::getIDByName($groupName);
@@ -331,7 +331,7 @@ class Regexes
*
* @throws \Exception
*/
protected function _matchRegex($regex, $subject): string
protected function _matchRegex(string $regex, string $subject): string
{
$returnString = '';
if (preg_match($regex, $subject, $hits) && \count($hits) > 0) {
@@ -362,7 +362,7 @@ class Regexes
*
* @param string $group_regex
*/
protected function _groupQueryString($group_regex): string
protected function _groupQueryString(string $group_regex): string
{
return $group_regex ? ('WHERE group_regex LIKE '.escapeString('%'.$group_regex.'%')) : '';
}
+2 -2
View File
@@ -102,7 +102,7 @@ class ReleaseCleaning
*
* @throws \Exception
*/
public function releaseCleaner($subject, $fromName, $groupName, $usePre = false)
public function releaseCleaner($subject, $fromName, $groupName, bool $usePre = false)
{
$hit = $hits = [];
// Get pre style name from releases.name
@@ -405,7 +405,7 @@ class ReleaseCleaning
/**
* @return array
*/
public function generic()
public function generic(): array
{
// This regex gets almost all of the predb release names also keep in mind that not every subject ends with yEnc, some are truncated, because of the 255 character limit and some have extra charaters tacked onto the end, like (5/10).
if (preg_match(
+2 -2
View File
@@ -70,7 +70,7 @@ class ReleaseExtra
/**
* @param string $guid
*/
public function getBriefByGuid($guid): array
public function getBriefByGuid(string $guid): array
{
return DB::select(sprintf("SELECT containerformat, videocodec, videoduration, videoaspect,
CONCAT(video_data.videowidth,'x',video_data.videoheight,' @',format(videoframerate,0),'fps') AS size,
@@ -322,7 +322,7 @@ class ReleaseExtra
* @param int $releaseID
* @param string $uniqueId
*/
public function addUID($releaseID, $uniqueId): void
public function addUID(int $releaseID, string $uniqueId): void
{
$dupecheck = ReleaseUnique::query()->where('releases_id', $releaseID)->orWhere([
'releases_id' => $releaseID,
+7 -7
View File
@@ -147,7 +147,7 @@ class ReleaseRemover
*
* @throws \Exception
*/
public function removeByCriteria($arguments)
public function removeByCriteria(array $arguments)
{
$this->delete = true;
$this->ignoreUserCheck = false;
@@ -212,7 +212,7 @@ class ReleaseRemover
*
* @throws \Exception
*/
public function removeCrap($delete, $time, $type = '', $blacklistID = '')
public function removeCrap(bool $delete, $time, string $type = '', $blacklistID = '')
{
$timeStart = now();
$this->delete = $delete;
@@ -1089,7 +1089,7 @@ class ReleaseRemover
* @param string $argument User argument.
* @return string|false
*/
protected function formatCriteriaQuery($argument)
protected function formatCriteriaQuery(string $argument)
{
// Check if the user wants to ignore the check.
if ($argument === 'ignore') {
@@ -1260,7 +1260,7 @@ class ReleaseRemover
*
* @return bool
*/
protected function checkUserResponse()
protected function checkUserResponse(): bool
{
if ($this->ignoreUserCheck || $this->browser) {
return true;
@@ -1290,7 +1290,7 @@ class ReleaseRemover
*
* @param string $string
*/
protected function cleanSpaces($string): string
protected function cleanSpaces(string $string): string
{
return trim(preg_replace('/\s{2,}/', ' ', $string));
}
@@ -1301,7 +1301,7 @@ class ReleaseRemover
* @param string $string The string to format.
* @param string $type The column name.
*/
protected function formatLike($string, $type): string
protected function formatLike(string $string, string $type): string
{
$newString = explode(' ', $string);
if (\count($newString) > 1) {
@@ -1334,7 +1334,7 @@ class ReleaseRemover
* @param string $dbRegex
* @return bool|mixed|string
*/
protected function extractSrchFromRegx($dbRegex = '')
protected function extractSrchFromRegx(string $dbRegex = '')
{
$regexMatch = '';
+3 -3
View File
@@ -198,7 +198,7 @@ class Tmux
/**
* @return int
*/
public function updateItem($setting, $value)
public function updateItem($setting, $value): int
{
return Settings::query()->where('setting', '=', $setting)->update(['value' => $value]);
}
@@ -265,7 +265,7 @@ class Tmux
*
* @throws \Exception
*/
public function rand_bool($loop, $chance = 60): bool
public function rand_bool($loop, int $chance = 60): bool
{
$usecache = Settings::settingValue('site.tmux.usecache') ?? 0;
if ($loop === 1 || $usecache === 0) {
@@ -294,7 +294,7 @@ class Tmux
*
* @throws \Exception
*/
public function proc_query($qry, $bookreqids, $db_name, $ppmax = '', $ppmin = ''): bool|string
public function proc_query($qry, $bookreqids, string $db_name, string $ppmax = '', string $ppmin = ''): bool|string
{
switch ((int) $qry) {
case 1:
+1 -1
View File
@@ -88,7 +88,7 @@ class XXX
*
* @param int $maxAge
*/
public function getXXXRange($page, $cat, $start, $num, $orderBy, $maxAge = -1, array $excludedCats = []): array
public function getXXXRange($page, $cat, $start, $num, $orderBy, int $maxAge = -1, array $excludedCats = []): array
{
$catSrch = '';
if (\count($cat) > 0 && $cat[0] !== -1) {
+9 -9
View File
@@ -48,7 +48,7 @@ class Geary
* @param string $gateway_id Your API key obtained from https://admin.gear.mycelium.com/gateways
* @param string $gateway_secret Your API secret obtained from https://admin.gear.mycelium.com/gateways
*/
public function __construct($gateway_id, $gateway_secret)
public function __construct(string $gateway_id, string $gateway_secret)
{
$this->gateway_id = $gateway_id;
$this->gateway_secret = $gateway_secret;
@@ -66,7 +66,7 @@ class Geary
* normally in satoshis
* @return mixed
*/
public function create_order($amount, $keychain_id, $callback_data)
public function create_order(float $amount, $keychain_id, $callback_data)
{
$request = $this->endpoint('orders');
$params = [
@@ -92,7 +92,7 @@ class Geary
* @param int $id Id is an existing order ID or payment ID
* @return mixed
*/
public function cancel_order($id)
public function cancel_order(int $id)
{
$request = $this->endpoint('orders');
@@ -113,7 +113,7 @@ class Geary
* @param int $payment_id Id is an existing payment ID
* @return mixed
*/
public function check_order($payment_id)
public function check_order(int $payment_id)
{
$request_uri = $this->endpoint('orders');
@@ -173,7 +173,7 @@ class Geary
*
* @param int $id Id is an existing order ID
*/
public function order_websocket_link($id): string
public function order_websocket_link(int $id): string
{
return "wss://gateway.gear.mycelium.com/gateways/{$this->gateway_id}/orders/$id/websocket";
}
@@ -222,7 +222,7 @@ class Geary
*
* @param string $method
*/
private function endpoint($method): string
private function endpoint(string $method): string
{
return "/gateways/{$this->gateway_id}/$method";
}
@@ -258,7 +258,7 @@ class Geary
*
* @param string $name
*/
private function get_header($name): string
private function get_header(string $name): string
{
$headers = getAllHeaders();
@@ -280,7 +280,7 @@ class Geary
*
* @param array $data
*/
private function prepare_header($data): array
private function prepare_header(array $data): array
{
$params = $data['params'];
$params_query = ! \is_array($params) ? "/$params" : '?'.http_build_query($params);
@@ -307,7 +307,7 @@ class Geary
* @param array $data
* @return mixed
*/
private function send_signed_request($data)
private function send_signed_request(array $data)
{
$ch = curl_init();
$url = self::API_URL.$data['request_uri'];
+5 -5
View File
@@ -68,7 +68,7 @@ class ADE extends AdultMovies
*
* @return array - url, streamid, basestreamingurl
*/
protected function trailers()
protected function trailers(): array
{
$this->_response = getRawHtml(self::ADE.$this->_trailers.$this->_directUrl);
$this->_html->loadHtml($this->_response);
@@ -100,7 +100,7 @@ class ADE extends AdultMovies
*
* @return array - Boxcover and backcover
*/
protected function covers()
protected function covers(): array
{
if ($ret = $this->_html->find('div#Boxcover, img[itemprop=image]', 1)) {
$this->_res['boxcover'] = preg_replace('/m\.jpg/', 'h.jpg', $ret->src);
@@ -115,7 +115,7 @@ class ADE extends AdultMovies
*
* @return array - plot
*/
protected function synopsis()
protected function synopsis(): array
{
$ret = $this->_html->findOne('meta[name=og:description]')->content;
if ($ret !== false) {
@@ -168,7 +168,7 @@ class ADE extends AdultMovies
* @param bool $extras
* @return array - ProductInfo/Extras = features
*/
protected function productInfo($extras = false)
protected function productInfo(bool $extras = false): array
{
$dofeature = null;
$this->_tmpResponse = str_ireplace('Section ProductInfo', 'spdinfo', $this->_response);
@@ -205,7 +205,7 @@ class ADE extends AdultMovies
* @param string $movie
* @return bool - True if releases has 90% match, else false
*/
public function processSite($movie): bool
public function processSite(string $movie): bool
{
if (empty($movie)) {
return false;
+2 -2
View File
@@ -74,7 +74,7 @@ class ADM extends AdultMovies
*
* @return array - boxcover,backcover
*/
protected function covers()
protected function covers(): array
{
$baseUrl = 'http://www.adultdvdmarketplace.com/';
if ($ret = $this->_html->find('a[rel=fancybox-button]', 0)) {
@@ -112,7 +112,7 @@ class ADM extends AdultMovies
*
* @param bool $extras
*/
protected function productInfo($extras = false): array
protected function productInfo(bool $extras = false): array
{
foreach ($this->_html->find('ul.list-unstyled li') as $li) {
$category = explode(':', $li->plaintext);
+2 -2
View File
@@ -144,7 +144,7 @@ class AEBN extends AdultMovies
*
* @param bool $extras
*/
protected function productInfo($extras = false): array
protected function productInfo(bool $extras = false): array
{
if ($ret = $this->_html->find('div#md-detailsLeft', 0)) {
foreach ($ret->find('div') as $div) {
@@ -190,7 +190,7 @@ class AEBN extends AdultMovies
*
* @param string $movie
*/
public function processSite($movie): bool
public function processSite(string $movie): bool
{
if (empty($movie)) {
return false;
+2 -2
View File
@@ -103,7 +103,7 @@ class Hotmovies extends AdultMovies
*
* @param bool $extras
*/
protected function productInfo($extras = false): array
protected function productInfo(bool $extras = false): array
{
$studio = false;
$director = false;
@@ -203,7 +203,7 @@ class Hotmovies extends AdultMovies
* @param string $movie
* @return bool , true if search >= 90%
*/
public function processSite($movie): bool
public function processSite(string $movie): bool
{
if (empty($movie)) {
return false;
+3 -3
View File
@@ -142,7 +142,7 @@ class Popporn extends AdultMovies
* @param bool $extras
* @return array|mixed
*/
protected function productInfo($extras = false)
protected function productInfo(bool $extras = false)
{
$country = false;
if ($ret = $this->_html->findOne('div#lside')) {
@@ -233,7 +233,7 @@ class Popporn extends AdultMovies
*
* @return array
*/
protected function genres()
protected function genres(): array
{
$genres = [];
if ($ret = $this->_html->find('div[id=thekeywords], p[class=keywords]', 1)) {
@@ -252,7 +252,7 @@ class Popporn extends AdultMovies
* @param string $movie
* @return bool , true if search >= 90%
*/
public function processSite($movie): bool
public function processSite(string $movie): bool
{
if (! empty($movie)) {
$this->_trailUrl = self::TRAILINGSEARCH.$movie;
+3 -3
View File
@@ -122,7 +122,7 @@ class AniDB
* @param int $episode
* @return \Illuminate\Database\Eloquent\Model|null|static
*/
private function checkAniDBInfo($anidbId, $episode = -1)
private function checkAniDBInfo($anidbId, int $episode = -1)
{
return AnidbEpisode::query()->where(
[
@@ -156,7 +156,7 @@ class AniDB
* @param string $cleanName
* @return array $hits
*/
private function extractTitleEpisode($cleanName = ''): array
private function extractTitleEpisode(string $cleanName = ''): array
{
$cleanName = str_replace('_', ' ', $cleanName);
@@ -197,7 +197,7 @@ class AniDB
* @param string $searchName
* @return mixed
*/
private function getAnidbByName($searchName = '')
private function getAnidbByName(string $searchName = '')
{
return DB::selectOne(
sprintf(
+4 -4
View File
@@ -44,7 +44,7 @@ class TMDB extends TV
*
* @param bool $local
*/
public function processSite($groupID, $guidChar, $process, $local = false): void
public function processSite($groupID, $guidChar, $process, bool $local = false): void
{
$res = $this->getTvReleases($groupID, $guidChar, $process, parent::PROCESS_TMDB);
@@ -186,7 +186,7 @@ class TMDB extends TV
* @param string $cleanName
* @return array|false
*/
protected function getShowInfo($cleanName): bool|array
protected function getShowInfo(string $cleanName): bool|array
{
$return = $response = false;
@@ -261,7 +261,7 @@ class TMDB extends TV
*
* @param int $videoId -- the local Video ID
*/
public function getPoster($videoId): int
public function getPoster(int $videoId): int
{
$ri = new ReleaseImage();
@@ -291,7 +291,7 @@ class TMDB extends TV
* @param int $videoId
* @return array|false
*/
protected function getEpisodeInfo($tmdbid, $season, $episode, $airdate = '', $videoId = 0): bool|array
protected function getEpisodeInfo(int $tmdbid, int $season, int $episode, string $airdate = '', int $videoId = 0): bool|array
{
$return = false;
+2 -2
View File
@@ -63,7 +63,7 @@ class TVDB extends TV
*
* @param bool $local
*/
public function processSite($groupID, $guidChar, $process, $local = false): void
public function processSite($groupID, $guidChar, $process, bool $local = false): void
{
$res = $this->getTvReleases($groupID, $guidChar, $process, parent::PROCESS_TVDB);
@@ -273,7 +273,7 @@ class TVDB extends TV
*
* @param int $videoId -- the local Video ID
*/
public function getPoster($videoId): int
public function getPoster(int $videoId): int
{
$ri = new ReleaseImage();
+4 -4
View File
@@ -52,7 +52,7 @@ class TVMaze extends TV
*
* @param bool $local
*/
public function processSite($groupID, $guidChar, $process, $local = false): void
public function processSite($groupID, $guidChar, $process, bool $local = false): void
{
$res = $this->getTvReleases($groupID, $guidChar, $process, parent::PROCESS_TVMAZE);
@@ -216,7 +216,7 @@ class TVMaze extends TV
* @param string $cleanName
* @return array|false
*/
protected function getShowInfo($cleanName)
protected function getShowInfo(string $cleanName)
{
$return = $response = false;
@@ -296,7 +296,7 @@ class TVMaze extends TV
*
* @param int $videoId -- the local Video ID
*/
public function getPoster($videoId): int
public function getPoster(int $videoId): int
{
$ri = new ReleaseImage();
@@ -326,7 +326,7 @@ class TVMaze extends TV
* @param int $videoId
* @return array|false
*/
protected function getEpisodeInfo($tvMazeId, $season, $episode, $airDate = '', $videoId = 0)
protected function getEpisodeInfo(int $tvMazeId, int $season, int $episode, string $airDate = '', int $videoId = 0)
{
$return = $response = false;
+3 -3
View File
@@ -67,7 +67,7 @@ class TraktTv extends TV
*
* @param bool $local
*/
public function processSite($groupID, $guidChar, $process, $local = false): void
public function processSite($groupID, $guidChar, $process, bool $local = false): void
{
$res = $this->getTvReleases($groupID, $guidChar, $process, parent::PROCESS_TRAKT);
@@ -202,7 +202,7 @@ class TraktTv extends TV
* @param int $episode
* @return array|false False on failure, an array of information fields otherwise.
*/
public function getEpisodeInfo($siteId, $series, $episode)
public function getEpisodeInfo(int $siteId, int $series, int $episode)
{
$return = false;
@@ -228,7 +228,7 @@ class TraktTv extends TV
*
* @param int $videoId ID from videos table.
*/
public function getPoster($videoId): int
public function getPoster(int $videoId): int
{
$hascover = 0;
$ri = new ReleaseImage();
+1 -1
View File
@@ -35,7 +35,7 @@ class Country
* @param string $country
* @return mixed
*/
public static function countryCode($country)
public static function countryCode(string $country)
{
if (\strlen($country) > 2) {
$code = CountryModel::whereFullName($country)->orWhere('name', $country)->first(['iso_3166_2']);
+1 -1
View File
@@ -35,7 +35,7 @@ class InstallNntmux extends Command
parent::__construct();
}
public function handle()
public function handle(): void
{
$error = false;
@@ -36,7 +36,7 @@ class NntmuxDeleteUnVerifiedUsers extends Command
*
* @return mixed
*/
public function handle()
public function handle(): void
{
$this->info('Deleting unverified users.');
User::deleteUnVerified();
@@ -36,7 +36,7 @@ class NntmuxPopulateSearchIndexes extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
if ($this->option('releases') && $this->option('manticore')) {
$this->manticoreReleases();
@@ -146,7 +146,7 @@ class NntmuxPopulateSearchIndexes extends Command
/**
* @return void
*/
private function elasticReleases()
private function elasticReleases(): void
{
$elastic = new ElasticSearchSiteSearch();
$total = Release::count();
@@ -192,7 +192,7 @@ class NntmuxPopulateSearchIndexes extends Command
/**
* @return void
*/
private function elasticPreDB()
private function elasticPreDB(): void
{
$elastic = new ElasticSearchSiteSearch();
$total = Predb::count();
@@ -39,7 +39,7 @@ class NntmuxRemoveBadReleases extends Command
*
* @throws \Exception
*/
public function handle()
public function handle(): void
{
Release::query()->where('passwordstatus', '=', -2)->delete();
+1 -1
View File
@@ -38,7 +38,7 @@ class NntmuxResetDb extends Command
/**
* @throws \Exception
*/
public function handle()
public function handle(): void
{
if ($this->confirm('This script removes all releases, nzb files, samples, previews , nfos, truncates all article tables and resets all groups. Are you sure you want reset the DB?')) {
$timestart = now();
@@ -51,7 +51,7 @@ class NntmuxResetPostProcessing extends Command
*
* @return mixed
*/
public function handle()
public function handle(): void
{
if (empty($this->option('category'))) {
$qry = Release::query()->select(['id'])->get();
+1 -1
View File
@@ -36,7 +36,7 @@ class NntmuxResetTruncate extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
UsenetGroup::query()->update(['first_record' => 0, 'first_record_postdate' => null, 'last_record' => 0, 'last_record_postdate' => null, 'last_updated' => null]);
$this->info('Reseting all groups completed.');
@@ -36,7 +36,7 @@ class NntmuxUpdateExpiredRoles extends Command
*
* @return mixed
*/
public function handle()
public function handle(): void
{
$this->info('Updating expired roles.');
$this->info('Updating users that will have their roles expire or are already expired');
+1 -1
View File
@@ -33,7 +33,7 @@ class TmuxUIRestart extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
$this->call('tmux-ui:stop', ['--kill' => true]);
$this->call('tmux-ui:start');
+1 -1
View File
@@ -26,7 +26,7 @@ class TmuxUIStart extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
$tmux = new Tmux();
$tmux_session = Settings::settingValue('site.tmux.tmux_session') ?? 0;
+1 -1
View File
@@ -26,7 +26,7 @@ class TmuxUIStop extends Command
/**
* @throws \Exception
*/
public function handle()
public function handle(): void
{
$tmux = new Tmux();
$tmux->stopIfRunning();
+1 -1
View File
@@ -28,7 +28,7 @@ class UpdateNNTmuxDB extends Command
parent::__construct();
}
public function handle()
public function handle(): void
{
// also prevent web access.
$this->output->writeln('<info>Updating database</info>');
+2 -2
View File
@@ -22,7 +22,7 @@ class Kernel extends ConsoleKernel
*
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->command('disposable:update')->weekly();
$schedule->command('clean:directories')->hourly()->withoutOverlapping();
@@ -43,7 +43,7 @@ class Kernel extends ConsoleKernel
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
+1 -1
View File
@@ -31,7 +31,7 @@ class Handler extends ExceptionHandler
*
* @return void
*/
public function register()
public function register(): void
{
$this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) {
+1 -1
View File
@@ -28,7 +28,7 @@ class PhpYenc
/**
* @param bool $ignore
*/
public static function decode(&$text, $ignore = false): bool|string
public static function decode(&$text, bool $ignore = false): bool|string
{
$crc = '';
// Extract the yEnc string itself.
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\Category;
use Blacklight\Regexes;
@@ -41,7 +42,7 @@ class AdminCategoryRegexesController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setAdminPrefs();
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'category_regexes']);
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\User;
use Blacklight\Contents;
@@ -32,7 +33,7 @@ class AdminContentController extends BasePageController
*
* @throws \Exception
*/
public function create(Request $request)
public function create(Request $request): RedirectResponse
{
$this->setAdminPrefs();
$contents = new Contents();
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\UsenetGroup;
use Illuminate\Http\Request;
@@ -67,7 +68,7 @@ class AdminGroupController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setAdminPrefs();
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\MovieInfo;
use App\Models\Release;
@@ -35,7 +36,7 @@ class AdminMovieController extends BasePageController
*
* @throws \Exception
*/
public function create(Request $request)
public function create(Request $request): RedirectResponse
{
if (! \defined('STDOUT')) {
\define('STDOUT', fopen('php://stdout', 'wb'));
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\Category;
use App\Models\Release;
@@ -34,7 +35,7 @@ class AdminReleasesController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setAdminPrefs();
$meta_title = $title = 'Release Edit';
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Jobs\SendAccountChangedEmail;
use App\Models\Invitation;
@@ -79,7 +80,7 @@ class AdminUserController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setAdminPrefs();
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api;
use Illuminate\Http\RedirectResponse;
use App\Events\UserAccessedApi;
use App\Http\Controllers\BasePageController;
use App\Models\Category;
@@ -245,7 +246,7 @@ class ApiV2Controller extends BasePageController
/**
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|void
*/
public function getNzb(Request $request)
public function getNzb(Request $request): RedirectResponse
{
$user = User::query()->where('api_token', $request->input('api_token'))->first();
event(new UserAccessedApi($user));
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Auth;
use Illuminate\Http\RedirectResponse;
use App\Http\Requests\Auth\LoginLoginRequest;
use App\Events\UserLoggedIn;
use App\Http\Controllers\Controller;
@@ -54,7 +55,7 @@ class LoginController extends Controller
* @throws \Illuminate\Auth\AuthenticationException
* @throws \Illuminate\Validation\ValidationException
*/
public function login(LoginLoginRequest $request)
public function login(LoginLoginRequest $request): RedirectResponse
{
$validator = Validator::make($request->all(), [
'username' => ['required'],
+8 -7
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Events\UserLoggedIn;
use App\Models\Category;
@@ -118,7 +119,7 @@ class BasePageController extends Controller
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show404($message = null)
public function show404($message = null): View
{
if ($message !== null) {
return view('errors.404')->with('Message', $message);
@@ -130,7 +131,7 @@ class BasePageController extends Controller
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show403()
public function show403(): View
{
return view('errors.403');
}
@@ -138,7 +139,7 @@ class BasePageController extends Controller
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show503()
public function show503(): View
{
return view('errors.503')->with('Error', 'Service temporarily unavailable');
}
@@ -146,7 +147,7 @@ class BasePageController extends Controller
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showBadBoy()
public function showBadBoy(): View
{
return view('errors.badboy')->with('Message', 'This is not you account.');
}
@@ -154,7 +155,7 @@ class BasePageController extends Controller
/**
* Show maintenance page.
*/
public function showMaintenance()
public function showMaintenance(): View
{
return view('errors.maintenance')->with('Message', 'We are performing an site maintenance.');
}
@@ -162,7 +163,7 @@ class BasePageController extends Controller
/**
* Show Security token mismatch page.
*/
public function showTokenError()
public function showTokenError(): View
{
return view('errors.tokenError')->with('Error', 'Token mismatch');
}
@@ -170,7 +171,7 @@ class BasePageController extends Controller
/**
* @param string $retry
*/
public function show429($retry = '')
public function show429(string $retry = '')
{
abort(429, $retry);
}
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Blacklight\Contents;
use Illuminate\Http\Request;
@@ -12,7 +13,7 @@ class ContentController extends BasePageController
*
* @throws \Exception
*/
public function show(Request $request)
public function show(Request $request): JsonResponse
{
$this->setPreferences();
$contents = new Contents();
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use App\Models\DnzbFailure;
use App\Models\Predb;
@@ -30,7 +31,7 @@ class DetailsController extends BasePageController
*
* @throws \Exception
*/
public function show(Request $request, string $guid)
public function show(Request $request, string $guid): RedirectResponse
{
$this->setPreferences();
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use App\Models\Forumpost;
use App\Models\Settings;
use Illuminate\Http\Request;
@@ -14,7 +15,7 @@ class ForumController extends BasePageController
*
* @throws \Exception
*/
public function forum(Request $request)
public function forum(Request $request): RedirectResponse
{
$this->setPreferences();
if ($this->isPostBack() && $request->has('addMessage') && $request->has('addSubject')) {
@@ -68,7 +69,7 @@ class ForumController extends BasePageController
*
* @throws \Exception
*/
public function getPosts($id, Request $request)
public function getPosts($id, Request $request): RedirectResponse
{
$this->setPreferences();
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use App\Jobs\SendAccountDeletedEmail;
use App\Models\ReleaseComment;
use App\Models\Settings;
@@ -103,7 +104,7 @@ class ProfileController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setPreferences();
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
@@ -12,7 +13,7 @@ class Authenticate extends Middleware
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
protected function redirectTo(Request $request): string
{
if (! $request->expectsJson()) {
return route('login');
+3 -1
View File
@@ -2,6 +2,8 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Request;
use Closure;
use Illuminate\Support\Facades\Auth;
@@ -15,7 +17,7 @@ class ClearanceMiddleware
*
* @throws \Exception
*/
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$user = $request->user();
+3 -1
View File
@@ -2,6 +2,8 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Request;
use App\Support\Google2FAAuthenticator;
use Closure;
@@ -13,7 +15,7 @@ class Google2FAMiddleware
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$authenticator = app(Google2FAAuthenticator::class)->boot($request);
@@ -2,6 +2,8 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Request;
use Closure;
use Illuminate\Support\Facades\Auth;
@@ -14,7 +16,7 @@ class RedirectIfAuthenticated
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
public function handle(Request $request, Closure $next, ?string $guard = null): Response
{
if (Auth::guard($guard)->check()) {
return redirect()->to('/');
+1 -1
View File
@@ -11,7 +11,7 @@ class LoginLoginRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'g-recaptcha-response' => [
@@ -11,7 +11,7 @@ class RegisterRegisterRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'g-recaptcha-response' => [
@@ -11,7 +11,7 @@ class ShowLinkRequestFormForgotPasswordRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return ['g-recaptcha-response' => [
'required',
+1 -1
View File
@@ -11,7 +11,7 @@ class ContactContactURequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return ['g-recaptcha-response' => [
'required',
@@ -11,7 +11,7 @@ class Disable2faPasswordSecurityRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return ['current-password' => [
'required',
+1 -1
View File
@@ -28,7 +28,7 @@ class RemoveInactiveAccounts implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
User::query()->where('lastlogin', '<', now()->subMonths(6))->where('apiaccess', '<', now()->subMonths(6))->where('roles_id', '=', 1)->delete();
User::query()->where('lastlogin', '<', now()->subMonths(6))->whereNull('apiaccess')->where('roles_id', '=', 1)->delete();
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\AccountChange;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendAccountChangedEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendAccountChangedEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new AccountChange($this->user));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\AccountDeleted;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendAccountDeletedEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendAccountDeletedEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to(config('mail.from.address'))->send(new AccountDeleted($this->user));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\AccountExpired;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendAccountExpiredEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendAccountExpiredEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new AccountExpired($this->user));
}
+1 -1
View File
@@ -34,7 +34,7 @@ class SendAccountWillExpireEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new AccountWillExpire($this->user, $this->days));
}
+1 -1
View File
@@ -30,7 +30,7 @@ class SendContactUsEmail implements ShouldQueue
$this->mailBody = $mailBody;
}
public function handle()
public function handle(): void
{
Mail::to($this->mailTo)->send(new ContactUs($this->email, $this->mailBody));
}
+1 -1
View File
@@ -40,7 +40,7 @@ class SendInviteEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->email)->send(new SendInvite($this->user, $this->url));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\NewAccountCreatedEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendNewRegisteredAccountMail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendNewRegisteredAccountMail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to(config('mail.from.address'))->send(new NewAccountCreatedEmail($this->user));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\ForgottenPassword;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -26,7 +27,7 @@ class SendPasswordForgottenEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user, $resetLink)
public function __construct(User $user, $resetLink)
{
$this->user = $user;
$this->resetLink = $resetLink;
@@ -37,7 +38,7 @@ class SendPasswordForgottenEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new ForgottenPassword($this->resetLink));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\PasswordReset;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -30,7 +31,7 @@ class SendPasswordResetEmail implements ShouldQueue
* @param \App\Models\User $user
* @param string $newPass
*/
public function __construct($user, $newPass)
public function __construct(User $user, string $newPass)
{
$this->user = $user;
$this->newPass = $newPass;
@@ -41,7 +42,7 @@ class SendPasswordResetEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new PasswordReset($this->user, $this->newPass));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\WelcomeEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendWelcomeEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendWelcomeEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new WelcomeEmail($this->user));
}
+1 -1
View File
@@ -22,7 +22,7 @@ class UpdateUserAccessedApi
*
* @return void
*/
public function handle(UserAccessedApi $event)
public function handle(UserAccessedApi $event): void
{
User::find($event->user->id)->update(['apiaccess' => now()]);
}
+1 -1
View File
@@ -22,7 +22,7 @@ class UpdateUserLoggedIn
*
* @return void
*/
public function handle(UserLoggedIn $event)
public function handle(UserLoggedIn $event): void
{
User::find($event->user->id)->update(
[
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@@ -30,7 +31,7 @@ class AccountChange extends Mailable
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
$this->siteEmail = config('mail.from.address');
@@ -44,7 +45,7 @@ class AccountChange extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Account Changed')->view('emails.accountChange')->with(['account' => $this->user->role->name, 'username' => $this->user->username, 'site' => $this->siteTitle]);
}
+1 -1
View File
@@ -40,7 +40,7 @@ class AccountDeleted extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('User Account Deleted')->view('emails.accountDelete')->with(['username' => $this->user->username, 'site' => $this->siteTitle]);
}
+1 -1
View File
@@ -33,7 +33,7 @@ class AccountExpired extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Account expired')->view('emails.accountExpired')->with(['account' => $this->user->role->name, 'username' => $this->user->username, 'site' => $this->siteTitle]);
}
+1 -1
View File
@@ -42,7 +42,7 @@ class AccountWillExpire extends Mailable
*
* @return $this
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Account about to expire')->view('emails.accountAboutToExpire')->with(['account' => $this->user->role->name, 'username' => $this->user->username, 'site' => $this->siteTitle, 'days' => $this->days]);
}
+1 -1
View File
@@ -30,7 +30,7 @@ class ContactUs extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->mailFrom)->subject('Contact form submitted')->replyTo($this->mailFrom)->view('emails.contactUs')->with(['mailBody' => $this->mailBody]);
}
+1 -1
View File
@@ -41,7 +41,7 @@ class ForgottenPassword extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Forgotten password reset')->view('emails.forgottenPassword')->with(['resetLink' => $this->resetLink, 'site' => $this->siteTitle]);
}
+1 -1
View File
@@ -42,7 +42,7 @@ class NewAccountCreatedEmail extends Mailable
*
* @return $this
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('New account registered')->view('emails.newAccountCreated')->with(['username' => $this->user->username, 'site' => $this->siteTitle]);
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@@ -35,7 +36,7 @@ class PasswordReset extends Mailable
*
* @param \App\Models\User $user
*/
public function __construct($user, $newPass)
public function __construct(User $user, $newPass)
{
$this->user = $user;
$this->newPass = $newPass;
@@ -50,7 +51,7 @@ class PasswordReset extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Password reset')->view('emails.passwordReset')->with(['newPass' => $this->newPass, 'userName' => $this->user->username, 'site' => $this->siteTitle]);
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@@ -35,7 +36,7 @@ class SendInvite extends Mailable
*
* @param \App\Models\User $user
*/
public function __construct($user, $invite)
public function __construct(User $user, $invite)
{
$this->user = $user;
$this->invite = $invite;
@@ -50,7 +51,7 @@ class SendInvite extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Invite received')->view('emails.sendinvite')->with(['invite' => $this->invite, 'username' => $this->user['username'], 'site' => $this->siteTitle, 'email' => $this->user['email']]);
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@@ -30,7 +31,7 @@ class WelcomeEmail extends Mailable
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
$this->siteEmail = config('mail.from.address');
@@ -42,7 +43,7 @@ class WelcomeEmail extends Mailable
*
* @return $this
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Welcome to '.$this->siteTitle)->view('emails.welcome')->with(['username' => $this->user->username, 'site' => $this->siteTitle]);
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
/**
@@ -78,7 +79,7 @@ class AnidbInfo extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function title()
public function title(): BelongsTo
{
return $this->belongsTo(AnidbTitle::class, 'anidbid');
}
@@ -86,7 +87,7 @@ class AnidbInfo extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function episode()
public function episode(): BelongsTo
{
return $this->belongsTo(AnidbEpisode::class, 'anidbid');
}
+2 -2
View File
@@ -70,7 +70,7 @@ class BookInfo extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ix_bookinfo_author_title_ft';
}
@@ -78,7 +78,7 @@ class BookInfo extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'author' => $this->author,
+3 -3
View File
@@ -270,7 +270,7 @@ class Category extends Model
/**
* @return HasMany
*/
public function releases()
public function releases(): HasMany
{
return $this->hasMany(Release::class, 'categories_id');
}
@@ -278,7 +278,7 @@ class Category extends Model
/**
* @return BelongsTo
*/
public function parent()
public function parent(): BelongsTo
{
return $this->belongsTo(RootCategory::class, 'root_categories_id');
}
@@ -311,7 +311,7 @@ class Category extends Model
/**
* @return string
*/
public static function getCategorySearch(array $cat = [])
public static function getCategorySearch(array $cat = []): string
{
$categories = [];
// If multiple categories were sent in a single array position, slice and add them
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Model;
/**
@@ -59,7 +60,7 @@ class Forumpost extends Model
* @param int $sticky
* @param int $replies
*/
public static function add($parentId, $userid, $subject, $message, $locked = 0, $sticky = 0, $replies = 0): int
public static function add($parentId, $userid, $subject, $message, int $locked = 0, int $sticky = 0, int $replies = 0): int
{
if ($message === '') {
return -1;
@@ -140,7 +141,7 @@ class Forumpost extends Model
* @param $start
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getBrowseRange()
public static function getBrowseRange(): LengthAwarePaginator
{
return self::query()
->where('forumpost.parentid', '=', 0)
+2 -2
View File
@@ -68,7 +68,7 @@ class GamesInfo extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ix_title_ft';
}
@@ -76,7 +76,7 @@ class GamesInfo extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'title' => $this->title,
+2 -2
View File
@@ -79,7 +79,7 @@ class MusicInfo extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ix_musicinfo_artist_title_ft';
}
@@ -87,7 +87,7 @@ class MusicInfo extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'artist' => $this->artist,
+4 -4
View File
@@ -155,7 +155,7 @@ class Predb extends Model
* @param string $cleanerName
* @return array|false Array with title/id from PreDB if found, false if not found.
*/
public static function matchPre($cleanerName)
public static function matchPre(string $cleanerName)
{
if (empty($cleanerName)) {
return false;
@@ -189,7 +189,7 @@ class Predb extends Model
*
* @throws \Exception
*/
public static function getAll($search = '')
public static function getAll(string $search = '')
{
$expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium'));
$predb = Cache::get(md5($search));
@@ -238,7 +238,7 @@ class Predb extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ft_predb_filename';
}
@@ -246,7 +246,7 @@ class Predb extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'filename' => $this->filename,
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
/**
@@ -50,7 +51,7 @@ class PredbHash extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function predb()
public function predb(): BelongsTo
{
return $this->belongsTo(Predb::class, 'predb_id');
}
+18 -14
View File
@@ -2,6 +2,10 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Blacklight\ElasticSearchSiteSearch;
use Blacklight\ManticoreSearch;
use Blacklight\NZB;
@@ -163,7 +167,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function group()
public function group(): BelongsTo
{
return $this->belongsTo(UsenetGroup::class, 'groups_id');
}
@@ -171,7 +175,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function download()
public function download(): HasMany
{
return $this->hasMany(UserDownload::class, 'releases_id');
}
@@ -179,7 +183,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function userRelease()
public function userRelease(): HasMany
{
return $this->hasMany(UsersRelease::class, 'releases_id');
}
@@ -192,7 +196,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function category()
public function category(): BelongsTo
{
return $this->belongsTo(Category::class, 'categories_id');
}
@@ -200,7 +204,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function predb()
public function predb(): BelongsTo
{
return $this->belongsTo(Predb::class, 'predb_id');
}
@@ -208,7 +212,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function failed()
public function failed(): HasMany
{
return $this->hasMany(DnzbFailure::class, 'release_id');
}
@@ -216,7 +220,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function releaseExtra()
public function releaseExtra(): HasMany
{
return $this->hasMany(ReleaseExtraFull::class, 'releases_id');
}
@@ -224,7 +228,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function nfo()
public function nfo(): HasOne
{
return $this->hasOne(ReleaseNfo::class, 'releases_id');
}
@@ -232,7 +236,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function comment()
public function comment(): HasMany
{
return $this->hasMany(ReleaseComment::class, 'releases_id');
}
@@ -240,7 +244,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function releaseGroup()
public function releaseGroup(): HasMany
{
return $this->hasMany(ReleasesGroups::class, 'releases_id');
}
@@ -248,7 +252,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function video()
public function video(): BelongsTo
{
return $this->belongsTo(Video::class, 'videos_id');
}
@@ -256,7 +260,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function episode()
public function episode(): BelongsTo
{
return $this->belongsTo(TvEpisode::class, 'tv_episodes_id');
}
@@ -345,7 +349,7 @@ class Release extends Model
*
* @throws \Exception
*/
public static function updateGrab($guid): void
public static function updateGrab(string $guid): void
{
$updateGrabs = ((int) Settings::settingValue('..grabstatus') !== 0);
if ($updateGrabs) {
@@ -541,7 +545,7 @@ class Release extends Model
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getFailedRange()
public static function getFailedRange(): LengthAwarePaginator
{
$failedList = self::query()
->select(['name', 'searchname', 'size', 'guid', 'totalpart', 'postdate', 'adddate', 'grabs', 'cp.title as parent_category', 'c.title as sub_category', DB::raw("CONCAT(cp.title, ' > ', c.title) AS category_name")])
+7 -5
View File
@@ -2,6 +2,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Model;
/**
@@ -68,7 +70,7 @@ class ReleaseComment extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function release()
public function release(): BelongsTo
{
return $this->belongsTo(Release::class, 'releases_id');
}
@@ -76,7 +78,7 @@ class ReleaseComment extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'users_id');
}
@@ -95,7 +97,7 @@ class ReleaseComment extends Model
/**
* @return array
*/
public static function getComments($id)
public static function getComments($id): array
{
return self::query()->where('releases_id', $id)->orderByDesc('created_at')->get()->toArray();
}
@@ -157,7 +159,7 @@ class ReleaseComment extends Model
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getCommentsRange()
public static function getCommentsRange(): LengthAwarePaginator
{
$range = self::query()
->select(['release_comments.*', 'releases.guid'])
@@ -189,7 +191,7 @@ class ReleaseComment extends Model
/**
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getCommentsForUserRange($uid)
public static function getCommentsForUserRange($uid): LengthAwarePaginator
{
return self::query()
->select(['release_comments.*', 'r.guid', 'r.searchname', 'u.username'])

Some files were not shown because too many files have changed in this diff Show More