diff --git a/.phpcs.xml b/.phpcs.xml
index 89305a0db..a6dafd3bb 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -7,7 +7,6 @@
.
cache/*
- lib/override.config.php
*/.docker/*
*/.git/*
*/node_modules/*
@@ -17,46 +16,32 @@
*/vendor/*
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/app/API/User.php b/app/API/User.php
index a7b82824e..6c86fec5a 100644
--- a/app/API/User.php
+++ b/app/API/User.php
@@ -9,7 +9,7 @@ class User extends AbstractAPI {
public function run(): array {
if (isset($_GET['user_id'])) {
$this->id = (int)$_GET['user_id'];
- } else if (isset($_GET['username'])) {
+ } elseif (isset($_GET['username'])) {
$this->username = $_GET['username'];
} else {
json_error("Need to supply either user_id or username");
diff --git a/app/Artist/Similar.php b/app/Artist/Similar.php
index 55c4eeaf0..7a4f8c973 100644
--- a/app/Artist/Similar.php
+++ b/app/Artist/Similar.php
@@ -276,7 +276,7 @@ public function similarGraph(int $width, int $height): array {
$layout = [];
$angle = fmod($this->id(), 2 * M_PI);
$golden = M_PI * (3 - sqrt(5));
- foreach (range(0, $nrSimilar-1) as $r) {
+ foreach (range(0, $nrSimilar - 1) as $r) {
$layout[] = $angle;
$angle = fmod($angle + $golden, 2 * M_PI);
}
@@ -295,7 +295,7 @@ public function similarGraph(int $width, int $height): array {
// For all artists with relations, sort their relations list by least relations first.
// The idea is to have other artists that are only related to this one close by.
foreach ($similar as &$s) {
- if ($s['nrRelated'] < 2) {
+ if ($s['nrRelated'] < 2) {
// trivial case
continue;
}
@@ -335,7 +335,7 @@ public function similarGraph(int $width, int $height): array {
// Rotate the layout angles to fit this artist in, so that we can
// pick the first and last angles off the layout list below.
$move = (int)ceil(($relatedToPlace + 1) / 2);
- $layout = [...array_slice($layout, $move, NULL, true), ...array_slice($layout, 0, $move, true)];
+ $layout = [...array_slice($layout, $move, null, true), ...array_slice($layout, 0, $move, true)];
}
if (!($relatedTotal > 0 && $seen > 1)) {
$angle = array_shift($layout);
@@ -361,7 +361,7 @@ public function similarGraph(int $width, int $height): array {
$bestPrevAngle = min($bestPrevAngle, $prevAngleDistance);
}
}
- if (fmod($bestNextAngle, 2 * M_PI) < fmod($bestPrevAngle, 2 * M_PI)) {
+ if (fmod($bestNextAngle, 2 * M_PI) < fmod($bestPrevAngle, 2 * M_PI)) {
$angle = array_shift($layout);
$up = false;
} else {
diff --git a/app/ArtistRole.php b/app/ArtistRole.php
index 5def3a34b..051271464 100644
--- a/app/ArtistRole.php
+++ b/app/ArtistRole.php
@@ -80,28 +80,28 @@ protected function renderRole(int $mode): string {
return $link = '';
}
- $and = match($mode) {
+ $and = match ($mode) {
self::RENDER_HTML => ' & ',
default => ' and ',
};
$chunk = [];
if ($djCount > 0) {
- $chunk[] = match($djCount) {
+ $chunk[] = match ($djCount) {
1 => $this->artistLink($mode, $roleList['dj'][0]),
2 => $this->artistLink($mode, $roleList['dj'][0]) . $and . $this->artistLink($mode, $roleList['dj'][1]),
default => $this->various('DJs', $roleList['dj'], $mode),
};
} else {
if ($composerCount > 0) {
- $chunk[] = match($composerCount) {
+ $chunk[] = match ($composerCount) {
1 => $this->artistLink($mode, $roleList['composer'][0]),
2 => $this->artistLink($mode, $roleList['composer'][0]) . $and . $this->artistLink($mode, $roleList['composer'][1]),
default => $this->various('Composers', $roleList['composer'], $mode),
};
if ($arrangerCount > 0) {
$chunk[] = 'arranged by';
- $chunk[] = match($arrangerCount) {
+ $chunk[] = match ($arrangerCount) {
1 => $this->artistLink($mode, $roleList['arranger'][0]),
2 => $this->artistLink($mode, $roleList['arranger'][0]) . $and . $this->artistLink($mode, $roleList['arranger'][1]),
default => $this->various('Arrangers', $roleList['arranger'], $mode),
@@ -119,7 +119,7 @@ protected function renderRole(int $mode): string {
$chunk[] = 'Various Artists';
} else {
if ($mainCount > 0) {
- $chunk[] = match($mainCount) {
+ $chunk[] = match ($mainCount) {
1 => $this->artistLink($mode, $roleList['main'][0]),
2 => $this->artistLink($mode, $roleList['main'][0]) . $and . $this->artistLink($mode, $roleList['main'][1]),
default => $this->various('Artists', $roleList['main'], $mode),
@@ -130,7 +130,7 @@ protected function renderRole(int $mode): string {
if ($mainCount + $composerCount > 0 && ($composerCount < 3 || $mainCount > 0)) {
$chunk[] = 'under';
}
- $chunk[] = match($conductorCount) {
+ $chunk[] = match ($conductorCount) {
1 => $this->artistLink($mode, $roleList['conductor'][0]),
2 => $this->artistLink($mode, $roleList['conductor'][0]) . $and . $this->artistLink($mode, $roleList['conductor'][1]),
default => $this->various('Conductors', $roleList['conductor'], $mode),
diff --git a/app/Better/ArtistCollage.php b/app/Better/ArtistCollage.php
index 6e215d86e..a9edeeadf 100644
--- a/app/Better/ArtistCollage.php
+++ b/app/Better/ArtistCollage.php
@@ -3,7 +3,6 @@
namespace Gazelle\Better;
class ArtistCollage extends AbstractBetter {
-
public function mode(): string {
return 'artist';
}
diff --git a/app/Better/ArtistDescription.php b/app/Better/ArtistDescription.php
index 5e3c9eca2..fbf32642b 100644
--- a/app/Better/ArtistDescription.php
+++ b/app/Better/ArtistDescription.php
@@ -3,7 +3,6 @@
namespace Gazelle\Better;
class ArtistDescription extends AbstractBetter {
-
public function mode(): string {
return 'artist';
}
diff --git a/app/Better/ArtistDiscogs.php b/app/Better/ArtistDiscogs.php
index cdece1dd7..b4da3ce7b 100644
--- a/app/Better/ArtistDiscogs.php
+++ b/app/Better/ArtistDiscogs.php
@@ -3,7 +3,6 @@
namespace Gazelle\Better;
class ArtistDiscogs extends AbstractBetter {
-
public function mode(): string {
return 'artist';
}
diff --git a/app/Better/ArtistImage.php b/app/Better/ArtistImage.php
index 28b3bf691..63b4356d7 100644
--- a/app/Better/ArtistImage.php
+++ b/app/Better/ArtistImage.php
@@ -3,7 +3,6 @@
namespace Gazelle\Better;
class ArtistImage extends AbstractBetter {
-
public function mode(): string {
return 'artist';
}
diff --git a/app/Better/Artwork.php b/app/Better/Artwork.php
index 06b7f740b..ebd8fdeed 100644
--- a/app/Better/Artwork.php
+++ b/app/Better/Artwork.php
@@ -3,7 +3,6 @@
namespace Gazelle\Better;
class Artwork extends AbstractBetter {
-
public function mode(): string {
return 'group';
}
diff --git a/app/Better/Bad.php b/app/Better/Bad.php
index cf828a86f..82a3dbd32 100644
--- a/app/Better/Bad.php
+++ b/app/Better/Bad.php
@@ -10,7 +10,7 @@ public function mode(): string {
}
public function setBadType(string $bad): static {
- $this->torrentFlag = match($bad) { /** @phpstan-ignore-line */
+ $this->torrentFlag = match ($bad) { /** @phpstan-ignore-line */
'files' => \Gazelle\TorrentFlag::badFile,
'folders' => \Gazelle\TorrentFlag::badFolder,
'lineage' => \Gazelle\TorrentFlag::noLineage,
@@ -24,7 +24,7 @@ public function torrentFlag(): \Gazelle\TorrentFlag {
}
public function heading(): string {
- return match($this->torrentFlag) { /** @phpstan-ignore-line */
+ return match ($this->torrentFlag) { /** @phpstan-ignore-line */
\Gazelle\TorrentFlag::badFile => 'Releases with with bad filenames',
\Gazelle\TorrentFlag::badFolder => 'Releases with with bad folders',
\Gazelle\TorrentFlag::noLineage => 'Releases with missing lineage details',
diff --git a/app/BonusPool.php b/app/BonusPool.php
index c8bd786cd..a96f88978 100644
--- a/app/BonusPool.php
+++ b/app/BonusPool.php
@@ -5,7 +5,7 @@
class BonusPool extends Base {
final const CACHE_SENT = 'bonuspool_sent_%d';
- public function __construct (
+ public function __construct(
protected readonly int $id,
) {}
diff --git a/app/Collage.php b/app/Collage.php
index 16a55c060..dfd5beb0f 100644
--- a/app/Collage.php
+++ b/app/Collage.php
@@ -2,8 +2,8 @@
namespace Gazelle;
-use \Gazelle\Enum\LeechType;
-use \Gazelle\Enum\LeechReason;
+use Gazelle\Enum\LeechType;
+use Gazelle\Enum\LeechReason;
class Collage extends BaseObject {
/**
@@ -218,7 +218,7 @@ public function isSubscribed(User $user): bool {
if (empty($this->userSubscriptions)) {
$key = sprintf(self::SUBS_KEY, $user->id());
$subs = self::$cache->get_value($key);
- if ($subs ===false) {
+ if ($subs === false) {
self::$db->prepared_query("
SELECT CollageID FROM users_collage_subs WHERE UserID = ?
", $user->id()
diff --git a/app/Collector/Artist.php b/app/Collector/Artist.php
index 62f29ea28..81e3c71ff 100644
--- a/app/Collector/Artist.php
+++ b/app/Collector/Artist.php
@@ -53,7 +53,7 @@ public function fillZip(\ZipStream\ZipStream $zip): void {
$this->addZip(
$zip,
$info,
- match($this->roleList[$tgroup->id()]) {
+ match ($this->roleList[$tgroup->id()]) {
ARTIST_MAIN => $releaseMan->findNameById($info['ReleaseType']),
ARTIST_GUEST => 'Guest Appearance',
ARTIST_REMIXER => 'Remixed By',
diff --git a/app/Contest.php b/app/Contest.php
index beaf3b8be..abed0ee4d 100644
--- a/app/Contest.php
+++ b/app/Contest.php
@@ -262,7 +262,7 @@ public function calculateLeaderboard(): int {
$n = self::$db->affected_rows();
self::$db->commit();
/* recache the pages */
- $pages = range(0, (int)(ceil($n)/CONTEST_ENTRIES_PER_PAGE) - 1);
+ $pages = range(0, (int)(ceil($n) / CONTEST_ENTRIES_PER_PAGE) - 1);
foreach ($pages as $p) {
self::$cache->delete_value(sprintf(self::CONTEST_LEADERBOARD_CACHE_KEY, $this->id, $p));
$this->type()->leaderboard(CONTEST_ENTRIES_PER_PAGE, $p); /** @phpstan-ignore-line */
@@ -314,7 +314,7 @@ public function doPayout(Manager\User $userMan): int {
if ($p['total_entries']) {
$totalGain += $contestBonus + ($perEntryBonus * $p['total_entries']);
}
- $log = date('Y-m-d H:i:s') ." {$user->label()} n={$p['total_entries']} t={$totalGain}";
+ $log = date('Y-m-d H:i:s') . " {$user->label()} n={$p['total_entries']} t={$totalGain}";
if ($user->hasAttr('no-fl-gifts') || $user->hasAttr('disable-bonus-points')) {
fwrite($report, "$log DECLINED\n");
continue;
diff --git a/app/Contest/AbstractContest.php b/app/Contest/AbstractContest.php
index 29f79b57a..1139135ec 100644
--- a/app/Contest/AbstractContest.php
+++ b/app/Contest/AbstractContest.php
@@ -5,7 +5,7 @@
trait TorrentLeaderboard {
public function leaderboard(int $limit, int $offset): array {
$key = sprintf(\Gazelle\Contest::CONTEST_LEADERBOARD_CACHE_KEY,
- $this->id, (int)($offset/CONTEST_ENTRIES_PER_PAGE)
+ $this->id, (int)($offset / CONTEST_ENTRIES_PER_PAGE)
);
$leaderboard = self::$cache->get_value($key);
if ($leaderboard === false) {
diff --git a/app/DB.php b/app/DB.php
index 077b59a17..e1b694554 100644
--- a/app/DB.php
+++ b/app/DB.php
@@ -3,7 +3,7 @@
namespace Gazelle;
class DB extends Base {
- static public function DB(): DB\Mysql {
+ public static function DB(): DB\Mysql {
return self::$db ??= new DB\Mysql(SQLDB, SQLLOGIN, SQLPASS, SQLHOST, SQLPORT, SQLSOCK);
}
@@ -78,11 +78,9 @@ public function checkStructureMatch(string $schema, string $source, string $dest
if (!$n1) {
return [false, "No such source table $source"];
- }
- elseif (!$n2) {
+ } elseif (!$n2) {
return [false, "No such destination table $destination"];
- }
- elseif ($n1 != $n2) {
+ } elseif ($n1 != $n2) {
// tables do not have the same number of columns
return [false, "$source and $destination column count mismatch ($n1 != $n2)"];
}
@@ -128,7 +126,7 @@ public function softDelete(string $schema, string $table, array $condition, bool
if (self::$db->affected_rows() == 0) {
return [false, "condition selected 0 rows"];
}
- } catch (DB\Mysql_DuplicateKeyException) {
+ } catch (DB\MysqlDuplicateKeyException) {
// do nothing, for some reason it was already deleted
}
diff --git a/app/DB/Mysql.php b/app/DB/Mysql.php
index cf1c15899..688b39d04 100644
--- a/app/DB/Mysql.php
+++ b/app/DB/Mysql.php
@@ -99,8 +99,8 @@
-------------------------------------------------------------------------------------
*///---------------------------------------------------------------------------------
-class Mysql_Exception extends \Exception {}
-class Mysql_DuplicateKeyException extends Mysql_Exception {}
+class MysqlException extends \Exception {}
+class MysqlDuplicateKeyException extends MysqlException {}
class Mysql {
public \mysqli|false $LinkID = false;
@@ -136,11 +136,11 @@ public function enableQueryLog(): void {
private function halt(string $Msg): void {
if ($this->Errno == 1062) {
- throw new Mysql_DuplicateKeyException;
+ throw new MysqlDuplicateKeyException;
}
global $Debug;
$Debug->saveCase("MySQL: error({$this->Errno}) {$this->Error} query=[$this->PreparedQuery]");
- throw new Mysql_Exception("$Msg -- {$this->Error}");
+ throw new MysqlException("$Msg -- {$this->Error}");
}
public function connect(): void {
@@ -149,7 +149,7 @@ public function connect(): void {
if ($this->LinkID === false) {
$this->Errno = mysqli_connect_errno();
$this->Error = mysqli_connect_error();
- $this->halt('Connection failed (host:'.$this->Server.':'.$this->Port.')');
+ $this->halt('Connection failed (host:' . $this->Server . ':' . $this->Port . ')');
}
}
}
@@ -220,24 +220,22 @@ public function execute(mixed ...$Parameters): \mysqli_result|bool {
foreach ($Parameters as $Parameter) {
if (is_integer($Parameter)) {
$Binders .= "i";
- }
- elseif (is_double($Parameter)) {
+ } elseif (is_double($Parameter)) {
$Binders .= "d";
- }
- else {
+ } else {
$Binders .= "s";
}
}
$Statement->bind_param($Binders, ...$Parameters);
}
- $Closure = function() use ($Statement) {
+ $Closure = function () use ($Statement) {
try {
$Statement->execute();
return $Statement->get_result();
} catch (\mysqli_sql_exception) {
if ($this->LinkID && mysqli_error($this->LinkID) == 1062) {
- throw new Mysql_DuplicateKeyException;
+ throw new MysqlDuplicateKeyException;
}
}
};
@@ -260,7 +258,7 @@ public function prepared_query(string $Query, mixed ...$Parameters): bool|\mysql
return $this->execute(...$Parameters);
}
- private function attempt_query(string $Query, Callable $Closure): \mysqli_result|false {
+ private function attempt_query(string $Query, callable $Closure): \mysqli_result|false {
$QueryStartTime = microtime(true);
if ($this->LinkID === false) {
return false;
@@ -279,8 +277,8 @@ private function attempt_query(string $Query, Callable $Closure): \mysqli_result
}
$QueryEndTime = microtime(true);
// Kills admin pages, and prevents Debug->analysis when the whole set exceeds 1 MB
- if (($Len = strlen($Query))>16384) {
- $Query = substr($Query, 0, 16384).'... '.($Len-16384).' bytes trimmed';
+ if (($Len = strlen($Query)) > 16384) {
+ $Query = substr($Query, 0, 16384) . '... ' . ($Len - 16384) . ' bytes trimmed';
}
if ($this->queryLog) {
$this->Queries[] = [$Query, ($QueryEndTime - $QueryStartTime) * 1000, null];
@@ -339,8 +337,7 @@ public function next_record(int $Type = MYSQLI_BOTH, array|bool $escape = true):
public function fetch_record(mixed ...$escape): ?array {
if (count($escape) === 1 && $escape[0] === true) {
$escape = true;
- }
- elseif (count($escape) === 0) {
+ } elseif (count($escape) === 0) {
$escape = false;
}
return $this->next_record(MYSQLI_BOTH, $escape);
diff --git a/app/Debug.php b/app/Debug.php
index 2346feccb..bcb464672 100644
--- a/app/Debug.php
+++ b/app/Debug.php
@@ -2,9 +2,7 @@
namespace Gazelle;
-use \Gazelle\Util\{Irc, Time};
-
-ini_set('max_execution_time',600);
+use Gazelle\Util\{Irc, Time};
class Debug {
protected const MAX_TIME = 20000;
@@ -56,16 +54,16 @@ public function profile(User $user, string $document, string $Automatic = ''): b
$Micro = (microtime(true) - self::$startTime) * 1000;
if ($Micro > self::MAX_TIME && !in_array($document, IGNORE_PAGE_MAX_TIME)) {
- $Reason[] = number_format($Micro, 3).' ms';
+ $Reason[] = number_format($Micro, 3) . ' ms';
}
$Errors = count($this->get_errors());
if ($Errors > self::MAX_ERRORS) {
- $Reason[] = $Errors.' PHP errors';
+ $Reason[] = $Errors . ' PHP errors';
}
$Ram = memory_get_usage(true);
if ($Ram > self::MAX_MEMORY && !in_array($document, IGNORE_PAGE_MAX_MEMORY)) {
- $Reason[] = byte_format($Ram).' RAM used';
+ $Reason[] = byte_format($Ram) . ' RAM used';
}
self::$db->warnings(); // see comment in MYSQL::query
@@ -114,7 +112,7 @@ public function saveCase(string $message): int {
);
self::$cache->cache_value(
- 'analysis_'.$id, [
+ 'analysis_' . $id, [
'URI' => isset($_SERVER['REQUEST_URI']) ? ($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) : 'cli',
'message' => $message,
'time' => time(),
@@ -159,7 +157,7 @@ public function analysis($Message, $Report = '', $Time = 43200): void {
public function saveError(\Exception $e): void {
$this->saveCase(
$e->getMessage() . "\n"
- . str_replace(SERVER_ROOT .'/', '', $e->getTraceAsString())
+ . str_replace(SERVER_ROOT . '/', '', $e->getTraceAsString())
);
}
@@ -212,7 +210,7 @@ protected function format_args(array $Array): string {
} elseif (is_object($Val)) {
$Return[$Key] .= $Val::class;
} elseif (is_array($Val)) {
- $Return[$Key] .= '['.$this->format_args($Val).']';
+ $Return[$Key] .= '[' . $this->format_args($Val) . ']';
}
$LastKey = $Key;
}
@@ -240,7 +238,7 @@ public function php_error_handler($Level, string $Error, $File, $Line): bool {
//At this time ONLY Array strict typing is fully supported.
//Allow us to abuse strict typing (IE: function test(Array))
if (preg_match('/^Argument (\d+) passed to \S+ must be an (array), (array|string|integer|double|object) given, called in (\S+) on line (\d+) and defined$/', $Error, $Matches)) {
- $Error = 'Type hinting failed on arg '.$Matches[1]. ', expected '.$Matches[2].' but found '.$Matches[3];
+ $Error = 'Type hinting failed on arg ' . $Matches[1] . ', expected ' . $Matches[2] . ' but found ' . $Matches[3];
$File = $Matches[4];
$Line = $Matches[5];
}
@@ -252,7 +250,7 @@ public function php_error_handler($Level, string $Error, $File, $Line): bool {
//Class
if (isset($Tracer[$Steps]['class'])) {
- $Call .= $Tracer[$Steps]['class'].'::';
+ $Call .= $Tracer[$Steps]['class'] . '::';
}
//Function & args
@@ -330,10 +328,10 @@ public function get_perf(): array {
$Perf = [
'URI' => $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'Memory usage' => byte_format(memory_get_usage(true)),
- 'Page process time' => number_format($PageTime, 3).' s',
+ 'Page process time' => number_format($PageTime, 3) . ' s',
];
if ($CPUTime) {
- $Perf['CPU time'] = number_format($CPUTime / 1_000_000, 3).' s';
+ $Perf['CPU time'] = number_format($CPUTime / 1_000_000, 3) . ' s';
}
$Perf['Script start'] = Time::sqlTime(self::$startTime);
$Perf['Script end'] = Time::sqlTime(microtime(true));
diff --git a/app/Donate/Bitcoin.php b/app/Donate/Bitcoin.php
index a53059c2b..f19c8a0dd 100644
--- a/app/Donate/Bitcoin.php
+++ b/app/Donate/Bitcoin.php
@@ -2,15 +2,15 @@
namespace Gazelle\Donate;
-use \BitWasp\Bitcoin\Address\AddressCreator;
-use \BitWasp\Bitcoin\Key\Deterministic\HierarchicalKey;
-use \BitWasp\Bitcoin\Network\Slip132\BitcoinRegistry;
-use \BitWasp\Bitcoin\Key\Deterministic\Slip132\Slip132;
-use \BitWasp\Bitcoin\Key\KeyToScript\KeyToScriptHelper;
-use \BitWasp\Bitcoin\Key\Deterministic\HdPrefix\GlobalPrefixConfig;
-use \BitWasp\Bitcoin\Key\Deterministic\HdPrefix\NetworkConfig;
-use \BitWasp\Bitcoin\Serializer\Key\HierarchicalKey\Base58ExtendedKeySerializer;
-use \BitWasp\Bitcoin\Serializer\Key\HierarchicalKey\ExtendedKeySerializer;
+use BitWasp\Bitcoin\Address\AddressCreator;
+use BitWasp\Bitcoin\Key\Deterministic\HierarchicalKey;
+use BitWasp\Bitcoin\Network\Slip132\BitcoinRegistry;
+use BitWasp\Bitcoin\Key\Deterministic\Slip132\Slip132;
+use BitWasp\Bitcoin\Key\KeyToScript\KeyToScriptHelper;
+use BitWasp\Bitcoin\Key\Deterministic\HdPrefix\GlobalPrefixConfig;
+use BitWasp\Bitcoin\Key\Deterministic\HdPrefix\NetworkConfig;
+use BitWasp\Bitcoin\Serializer\Key\HierarchicalKey\Base58ExtendedKeySerializer;
+use BitWasp\Bitcoin\Serializer\Key\HierarchicalKey\ExtendedKeySerializer;
class Bitcoin {
use \Gazelle\Pg;
@@ -32,13 +32,14 @@ class Bitcoin {
* @throws \Exception if $xyzpub is not valid
*/
public function __construct(
- string $xyzpub = BITCOIN_DONATION_XYZPUB,
- protected \Gazelle\Counter $nextKeyCounter = new \Gazelle\Counter("donation-bitcoin")) {
+ protected string $xyzpub = BITCOIN_DONATION_XYZPUB,
+ protected \Gazelle\Counter $nextKeyCounter = new \Gazelle\Counter("donation-bitcoin"),
+ ) {
$adapter = \BitWasp\Bitcoin\Bitcoin::getEcAdapter();
$slip132 = new Slip132(new KeyToScriptHelper($adapter));
$btcPrefixes = new BitcoinRegistry();
- $prefix = match(substr($xyzpub, 0, 4)) {
+ $prefix = match (substr($xyzpub, 0, 4)) {
'xpub' => $slip132->p2pkh($btcPrefixes),
'ypub' => $slip132->p2shP2wpkh($btcPrefixes),
'zpub' => $slip132->p2wpkh($btcPrefixes),
diff --git a/app/Donate/Monero.php b/app/Donate/Monero.php
index 51ec2b4d1..2a9bfe966 100644
--- a/app/Donate/Monero.php
+++ b/app/Donate/Monero.php
@@ -2,7 +2,7 @@
namespace Gazelle\Donate;
use Gazelle\Pg;
-use \MoneroIntegrations\MoneroPhp;
+use MoneroIntegrations\MoneroPhp;
class Monero {
use Pg;
diff --git a/app/Enum/AvatarDisplay.php b/app/Enum/AvatarDisplay.php
index 002318e98..b2976c4b8 100644
--- a/app/Enum/AvatarDisplay.php
+++ b/app/Enum/AvatarDisplay.php
@@ -9,7 +9,7 @@ enum AvatarDisplay: int {
case forceSynthetic = 3;
public function label(): string {
- return match($this) {
+ return match ($this) {
AvatarDisplay::show => 'show',
AvatarDisplay::none => 'none',
AvatarDisplay::fallbackSynthetic => 'fallbackSynthetic',
diff --git a/app/Enum/AvatarSynthetic.php b/app/Enum/AvatarSynthetic.php
index 15f882a32..3452ab263 100644
--- a/app/Enum/AvatarSynthetic.php
+++ b/app/Enum/AvatarSynthetic.php
@@ -12,7 +12,7 @@ enum AvatarSynthetic: int {
case robot3 = 6;
public function label(): string {
- return match($this) {
+ return match ($this) {
AvatarSynthetic::identicon => 'Identicon',
AvatarSynthetic::monster => 'Monsters',
AvatarSynthetic::wavatar => 'Wavatar',
diff --git a/app/Enum/FeaturedAlbumType.php b/app/Enum/FeaturedAlbumType.php
index 5ce428b96..2a4662ac2 100644
--- a/app/Enum/FeaturedAlbumType.php
+++ b/app/Enum/FeaturedAlbumType.php
@@ -2,28 +2,28 @@
namespace Gazelle\Enum;
-use \Gazelle\Enum\LeechReason;
+use Gazelle\Enum\LeechReason;
enum FeaturedAlbumType: int {
case AlbumOfTheMonth = 0;
case Showcase = 1;
public function label(): string {
- return match($this) {
+ return match ($this) {
FeaturedAlbumType::AlbumOfTheMonth => 'Album of the Month',
FeaturedAlbumType::Showcase => 'Showcase', /** @phpstan-ignore-line */
};
}
public function forumId(): int {
- return match($this) {
+ return match ($this) {
FeaturedAlbumType::AlbumOfTheMonth => AOTM_FORUM_ID,
FeaturedAlbumType::Showcase => SHOWCASE_FORUM_ID, /** @phpstan-ignore-line */
};
}
public function leechReason(): LeechReason {
- return match($this) {
+ return match ($this) {
FeaturedAlbumType::AlbumOfTheMonth => LeechReason::AlbumOfTheMonth,
FeaturedAlbumType::Showcase => LeechReason::Showcase, /** @phpstan-ignore-line */
};
diff --git a/app/Enum/LeechReason.php b/app/Enum/LeechReason.php
index f706fa705..6ee8d2a42 100644
--- a/app/Enum/LeechReason.php
+++ b/app/Enum/LeechReason.php
@@ -10,7 +10,7 @@ enum LeechReason: string {
case AlbumOfTheMonth = '4';
public function label(): string {
- return match($this) {
+ return match ($this) {
LeechReason::Normal => 'Normal',
LeechReason::StaffPick => 'Staff Pick',
LeechReason::Permanent => 'Permanent FL',
diff --git a/app/Enum/LeechType.php b/app/Enum/LeechType.php
index 79676bee7..2daa640a1 100644
--- a/app/Enum/LeechType.php
+++ b/app/Enum/LeechType.php
@@ -8,7 +8,7 @@ enum LeechType: string {
case Neutral = '2';
public function label(): string {
- return match($this) {
+ return match ($this) {
LeechType::Normal => 'Normal',
LeechType::Neutral => 'Neutral Leech',
LeechType::Free => 'Freeleech', /** @phpstan-ignore-line */
diff --git a/app/Enum/SearchReportOrder.php b/app/Enum/SearchReportOrder.php
index b9d4c11a0..b20715b06 100644
--- a/app/Enum/SearchReportOrder.php
+++ b/app/Enum/SearchReportOrder.php
@@ -9,7 +9,7 @@ enum SearchReportOrder: int {
case resolvedDesc = 3;
public function label(): string {
- return match($this) {
+ return match ($this) {
self::createdAsc => 'created-asc',
self::createdDesc => 'created-desc',
self::resolvedAsc => 'resolved-asc',
@@ -18,7 +18,7 @@ public function label(): string {
}
public function orderBy(): string {
- return match($this) {
+ return match ($this) {
self::createdAsc,
self::createdDesc => 'created',
self::resolvedAsc,
@@ -27,7 +27,7 @@ public function orderBy(): string {
}
public function direction(): string {
- return match($this) {
+ return match ($this) {
self::createdAsc,
self::resolvedAsc => 'ASC',
self::createdDesc,
diff --git a/app/Enum/UserStatus.php b/app/Enum/UserStatus.php
index b5f5b2d58..39c71f0bb 100644
--- a/app/Enum/UserStatus.php
+++ b/app/Enum/UserStatus.php
@@ -9,7 +9,7 @@ enum UserStatus: string {
case banned = '3';
public function label(): string {
- return match($this) {
+ return match ($this) {
UserStatus::unconfirmed => 'Unconfirmed',
UserStatus::enabled => 'Enabled',
UserStatus::disabled => 'Disabled',
diff --git a/app/Enum/UserTokenType.php b/app/Enum/UserTokenType.php
index 932efc48a..456080b7c 100644
--- a/app/Enum/UserTokenType.php
+++ b/app/Enum/UserTokenType.php
@@ -8,7 +8,7 @@ enum UserTokenType: string {
case password = 'password';
public function interval(): ?string {
- return match($this) {
+ return match ($this) {
self::confirm => '1 day',
self::password => '1 hour',
default => null, // does not expire
diff --git a/app/FeaturedAlbum.php b/app/FeaturedAlbum.php
index 24a5195fa..246c2cf1a 100644
--- a/app/FeaturedAlbum.php
+++ b/app/FeaturedAlbum.php
@@ -11,7 +11,6 @@ class FeaturedAlbum extends BaseObject {
public function __construct(
protected FeaturedAlbumType $type,
protected int $id,
-
) {
parent::__construct($id);
}
@@ -68,7 +67,7 @@ public function thread(): ForumThread {
}
public function type(): FeaturedAlbumType {
- return match((int)$this->info()['type']) {
+ return match ((int)$this->info()['type']) {
1 => FeaturedAlbumType::Showcase,
default => FeaturedAlbumType::AlbumOfTheMonth,
};
diff --git a/app/Feed.php b/app/Feed.php
index 0a3fba93b..010f033d3 100644
--- a/app/Feed.php
+++ b/app/Feed.php
@@ -3,7 +3,7 @@
namespace Gazelle;
class Feed extends Base {
- function header(): string {
+ public function header(): string {
header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
header('Pragma:');
header('Expires: ' . date('D, d M Y H:i:s', time() + (2 * 60 * 60)) . ' GMT');
@@ -13,11 +13,11 @@ function header(): string {
return self::$twig->render('feed/header.twig');
}
- function footer(): string {
+ public function footer(): string {
return self::$twig->render('feed/footer.twig');
}
- function channel(string $title, string $description): string {
+ public function channel(string $title, string $description): string {
return self::$twig->render('feed/channel.twig', [
'date' => date('r'),
'description' => $description,
@@ -25,7 +25,7 @@ function channel(string $title, string $description): string {
]);
}
- function item(string $title, string $description, string $page, string $creator, string $date, string $comments = '', string $category = ''): string {
+ public function item(string $title, string $description, string $page, string $creator, string $date, string $comments = '', string $category = ''): string {
return self::$twig->render('feed/item.twig', [
'category' => $category,
'comments' => $comments,
@@ -37,7 +37,7 @@ function item(string $title, string $description, string $page, string $creator,
]);
}
- function retrieve(User $user, string $key): string {
+ public function retrieve(User $user, string $key): string {
$list = self::$cache->get_value($key);
if ($list === false) {
$list = [];
@@ -46,7 +46,7 @@ function retrieve(User $user, string $key): string {
return implode('', array_map(fn ($item) => str_replace('[[PASSKEY]]', $announceKey, $item), $list));
}
- function populate(string $key, string $item): int {
+ public function populate(string $key, string $item): int {
$list = self::$cache->get_value($key);
if ($list === false) {
$list = [];
@@ -100,7 +100,7 @@ public function bookmark(User $user, string $feedName): string {
public function byFeedName(User $user, string $feedName): string {
return $this->wrap(
$this->channel(
- match($feedName) {
+ match ($feedName) {
'torrents_all' => 'Everything',
'torrents_apps' => 'Applications',
'torrents_abooks' => 'Audiobooks',
@@ -115,7 +115,7 @@ public function byFeedName(User $user, string $feedName): string {
'torrents_vinyl' => 'Vinyl',
'torrents_lossless24' => '24bit Lossless',
},
- match($feedName) {
+ match ($feedName) {
'torrents_all' => 'RSS feed for new uploads',
'torrents_apps' => 'RSS feed for new application uploads',
'torrents_comedy' => 'RSS feed for new comedy uploads',
diff --git a/app/Image.php b/app/Image.php
index af92e08dc..373e1c547 100644
--- a/app/Image.php
+++ b/app/Image.php
@@ -23,15 +23,15 @@ public function __construct(string $data) {
}
}
- function height(): int {
+ public function height(): int {
return $this->height;
}
- function width(): int {
+ public function width(): int {
return $this->width;
}
- function display(): ?bool {
+ public function display(): ?bool {
return match ($this->type) {
IMAGETYPE_BMP => imagebmp($this->image),
IMAGETYPE_GIF => imagegif($this->image),
@@ -43,7 +43,7 @@ function display(): ?bool {
};
}
- function type(): string {
+ public function type(): string {
return match ($this->type) {
IMAGETYPE_BMP => 'bmp',
IMAGETYPE_GIF => 'gif',
diff --git a/app/Json/AddLog.php b/app/Json/AddLog.php
index 436f801ab..4fdfb36cd 100644
--- a/app/Json/AddLog.php
+++ b/app/Json/AddLog.php
@@ -20,7 +20,7 @@ public function payload(): array {
$logSummaries = [];
$checkerVersion = Logchecker::getLogcheckerVersion();
- foreach($this->logfileSummary->all() as $logfile) {
+ foreach ($this->logfileSummary->all() as $logfile) {
$this->torrentLogManager->create($this->torrent, $logfile, $checkerVersion);
$logSummaries[] = [
'score' => $logfile->score(),
diff --git a/app/Json/Inbox.php b/app/Json/Inbox.php
index 873a4d574..ac4887093 100644
--- a/app/Json/Inbox.php
+++ b/app/Json/Inbox.php
@@ -19,7 +19,7 @@ public function __construct(
public function setSearch(string $searchType, string $search): static {
$search = trim($search);
- switch($searchType) {
+ switch ($searchType) {
case 'subject':
$words = array_unique(array_map('trim', explode(' ', $search)));
$this->cond = array_merge($this->cond, array_fill(0, count($words), "c.Subject LIKE concat('%', ?, '%')"));
@@ -31,7 +31,7 @@ public function setSearch(string $searchType, string $search): static {
$this->cond = array_merge($this->cond, array_fill(0, count($words), "m.Body LIKE concat('%', ?, '%')"));
$this->args = array_merge($this->args, $words);
break;
- case 'user':
+ case 'user':
$this->join[] = 'INNER JOIN users_main AS um ON (um.ID = other.UserID)';
$this->cond[] = "um.Username LIKE concat('%', ?, '%')";
$this->args[] = $search;
@@ -60,7 +60,7 @@ public function payload(): array {
INNER JOIN pm_conversations_users AS cu ON (cu.ConvID = c.ID AND cu.UserID = ?)
LEFT JOIN pm_conversations_users AS other ON (other.ConvID = c.ID AND other.UserID != ? AND other.ForwardedTo = 0)
" . implode(' ', $this->join) . "
- WHERE " . implode(' AND ', $this->cond) ."
+ WHERE " . implode(' AND ', $this->cond) . "
", $this->user->id(), $this->user->id(), ...$this->args
);
$paginator = new \Gazelle\Util\Paginator(MESSAGES_PER_PAGE, $this->page);
@@ -80,7 +80,7 @@ public function payload(): array {
INNER JOIN pm_conversations_users AS cu ON (cu.ConvID = c.ID AND cu.UserID = ?)
LEFT JOIN pm_conversations_users AS other ON (other.ConvID = c.ID AND other.UserID != ? AND other.ForwardedTo = 0)
" . implode(' ', $this->join) . "
- WHERE " . implode(' AND ', $this->cond) ."
+ WHERE " . implode(' AND ', $this->cond) . "
GROUP BY c.ID
ORDER BY cu.Sticky, {$orderBy}
LIMIT ? OFFSET ?
diff --git a/app/Json/RipLog.php b/app/Json/RipLog.php
index dd791484a..d30621d59 100644
--- a/app/Json/RipLog.php
+++ b/app/Json/RipLog.php
@@ -36,4 +36,3 @@ public function payload(): array {
];
}
}
-
diff --git a/app/Json/User.php b/app/Json/User.php
index d3a320d06..d9d25c745 100644
--- a/app/Json/User.php
+++ b/app/Json/User.php
@@ -2,7 +2,7 @@
namespace Gazelle\Json;
-use \Gazelle\User\Vote;
+use Gazelle\User\Vote;
class User extends \Gazelle\Json {
public function __construct(
@@ -20,7 +20,7 @@ public function payload(): array {
$stats = $user->stats();
$forumPosts = $stats->forumPostTotal();
- $releaseVotes = (new Vote($user))->userTotal(Vote::UPVOTE|Vote::DOWNVOTE);
+ $releaseVotes = (new Vote($user))->userTotal(Vote::UPVOTE | Vote::DOWNVOTE);
$uploaded = $this->valueOrNull($user->uploadedSize(), 'uploaded');
$downloaded = $this->valueOrNull($user->downloadedSize(), 'downloaded');
$uploads = $this->valueOrNull($stats->uploadTotal(), 'uploads+');
@@ -64,7 +64,7 @@ public function payload(): array {
'profileText' => \Text::full_format($user->profileInfo()),
'stats' => [
'joinedDate' => $user->created(),
- 'lastAccess' => match(true) {
+ 'lastAccess' => match (true) {
$viewer->id() == $user->id() => $user->lastAccessRealtime(),
$viewer->isStaff() => $user->lastAccessRealtime(),
$user->propertyVisible($viewer, 'lastseen') => $user->lastAccess(),
@@ -73,7 +73,7 @@ public function payload(): array {
'uploaded' => $uploaded,
'downloaded' => $downloaded,
'requiredRatio' => $user->propertyVisible($viewer, 'requiredratio') ? $user->requiredRatio() : null,
- 'ratio' => match(true) {
+ 'ratio' => match (true) {
is_null($uploaded) || is_null($downloaded)
=> null,
!$downloaded => 0.0,
diff --git a/app/LoginWatch.php b/app/LoginWatch.php
index 084f5a241..284253051 100644
--- a/app/LoginWatch.php
+++ b/app/LoginWatch.php
@@ -45,7 +45,7 @@ public function increment(int $userId, string $username): int {
UserID = ?,
capture = ?
WHERE ID = ?
- ', $seen ? 60 : LOGIN_ATTEMPT_BACKOFF[min($this->nrAttempts(), count(LOGIN_ATTEMPT_BACKOFF)-1)],
+ ', $seen ? 60 : LOGIN_ATTEMPT_BACKOFF[min($this->nrAttempts(), count(LOGIN_ATTEMPT_BACKOFF) - 1)],
$this->userId, substr(urlencode($username), 0, 20), $this->id
);
return self::$db->affected_rows();
diff --git a/app/Manager/Artist.php b/app/Manager/Artist.php
index 5f3e56f1b..90e8d61b6 100644
--- a/app/Manager/Artist.php
+++ b/app/Manager/Artist.php
@@ -88,7 +88,7 @@ public function findByNameAndRevision(string $name, int $revisionId): ?\Gazelle\
AND RevisionID = ?
", trim($name), $revisionId
);
- return $id ? new \Gazelle\Artist($id, $revisionId): null;
+ return $id ? new \Gazelle\Artist($id, $revisionId) : null;
}
public function findByAliasId(int $aliasId): ?\Gazelle\Artist {
diff --git a/app/Manager/AutoEnable.php b/app/Manager/AutoEnable.php
index accb0e990..2ac136e3d 100644
--- a/app/Manager/AutoEnable.php
+++ b/app/Manager/AutoEnable.php
@@ -125,6 +125,7 @@ public function configureView(string $view, bool $showChecked): static {
break;
case 'ip_overlap':
$this->join[] = "INNER JOIN users_history_ips uhi ON (uhi.IP = uer.IP AND uhi.UserID != uer.UserID)";
+ break;
case 'manual_disable':
$this->cond[] = "ui.BanReason != '3'";
break;
diff --git a/app/Manager/Collage.php b/app/Manager/Collage.php
index 0c0292e8e..0cd7b45df 100644
--- a/app/Manager/Collage.php
+++ b/app/Manager/Collage.php
@@ -194,7 +194,7 @@ public function addToArtistCollageDefault(int $userId, int $artistId): array {
self::$cache->cache_value($key, $default, 86400);
}
$list = [];
- foreach($default as $id) {
+ foreach ($default as $id) {
$collage = $this->findById($id);
if ($collage) {
$list[] = $collage;
@@ -249,7 +249,7 @@ public function addToCollageDefault(int $userId, int $groupId): array {
self::$cache->cache_value($key, $default, 86400);
}
$list = [];
- foreach($default as $id) {
+ foreach ($default as $id) {
$collage = $this->findById($id);
if ($collage) {
$list[] = $collage;
@@ -289,7 +289,7 @@ public function autocomplete(string $text): array {
);
$pairs = self::$db->to_pair('ID', 'Name', false);
$autocomplete = [];
- foreach($pairs as $key => $value) {
+ foreach ($pairs as $key => $value) {
$autocomplete[] = ['data' => $key, 'value' => $value];
}
self::$cache->cache_value($key, $autocomplete, 1800 + 7200 * ($maxLength - $length));
diff --git a/app/Manager/Comment.php b/app/Manager/Comment.php
index 3cfbe20c4..e578e1ab1 100644
--- a/app/Manager/Comment.php
+++ b/app/Manager/Comment.php
@@ -18,9 +18,12 @@ protected function className(string $page): string {
/**
* Post a comment on an artist, request or torrent page.
*/
- public function create(\Gazelle\User $user, string $page, int $pageId, string $body):
- \Gazelle\Comment\Artist|\Gazelle\Comment\Collage|\Gazelle\Comment\Request|\Gazelle\Comment\Torrent
- {
+ public function create(
+ \Gazelle\User $user,
+ string $page,
+ int $pageId,
+ string $body,
+ ): \Gazelle\Comment\Artist|\Gazelle\Comment\Collage|\Gazelle\Comment\Request|\Gazelle\Comment\Torrent {
self::$db->prepared_query("
INSERT INTO comments
(Page, PageID, AuthorID, Body)
@@ -49,9 +52,9 @@ public function create(\Gazelle\User $user, string $page, int $pageId, string $b
return new $className($pageId, 0, $postId); /** @phpstan-ignore-line */
}
- public function findById(int $postId):
- \Gazelle\Comment\Artist|\Gazelle\Comment\Collage|\Gazelle\Comment\Request|\Gazelle\Comment\Torrent|null
- {
+ public function findById(
+ int $postId,
+ ): \Gazelle\Comment\Artist|\Gazelle\Comment\Collage|\Gazelle\Comment\Request|\Gazelle\Comment\Torrent|null {
[$page, $pageId] = self::$db->row("
SELECT Page, PageID FROM comments WHERE ID = ?
", $postId
diff --git a/app/Manager/Contest.php b/app/Manager/Contest.php
index 7b60beb83..b9229035a 100644
--- a/app/Manager/Contest.php
+++ b/app/Manager/Contest.php
@@ -3,7 +3,7 @@
namespace Gazelle\Manager;
class Contest extends \Gazelle\Base {
- public function create (
+ public function create(
string $banner,
string $dateBegin,
string $dateEnd,
diff --git a/app/Manager/ErrorLog.php b/app/Manager/ErrorLog.php
index 1dbaa4194..66af7c166 100644
--- a/app/Manager/ErrorLog.php
+++ b/app/Manager/ErrorLog.php
@@ -6,8 +6,17 @@ class ErrorLog extends \Gazelle\BaseManager {
protected string $filter;
public function create(
- string $uri, int $userId, float $duration, int $memory, int $nrQuery, int $nrCache,
- string $digest, string $trace, string $request, string $errorList, string $loggedVar
+ string $uri,
+ int $userId,
+ float $duration,
+ int $memory,
+ int $nrQuery,
+ int $nrCache,
+ string $digest,
+ string $trace,
+ string $request,
+ string $errorList,
+ string $loggedVar
): int {
self::$db->begin_transaction();
$id = (int)self::$db->scalar("
diff --git a/app/Manager/FeaturedAlbum.php b/app/Manager/FeaturedAlbum.php
index 78e97e17a..9d4db4ee6 100644
--- a/app/Manager/FeaturedAlbum.php
+++ b/app/Manager/FeaturedAlbum.php
@@ -93,7 +93,7 @@ public function findById(int $tgroupId): ?\Gazelle\FeaturedAlbum {
return null;
}
return new \Gazelle\FeaturedAlbum(
- match((int)$type) {
+ match ((int)$type) {
1 => FeaturedAlbumType::Showcase,
default => FeaturedAlbumType::AlbumOfTheMonth,
},
diff --git a/app/Manager/IRC.php b/app/Manager/IRC.php
index 18b097e39..330401491 100644
--- a/app/Manager/IRC.php
+++ b/app/Manager/IRC.php
@@ -31,7 +31,7 @@ public function list(): array {
return $list;
}
- public function modify (int $id, string $name, int $sort, int $minLevel, array $classList): int {
+ public function modify(int $id, string $name, int $sort, int $minLevel, array $classList): int {
self::$db->prepared_query("
UPDATE irc_channels SET
Name = ?,
diff --git a/app/Manager/Notification.php b/app/Manager/Notification.php
index 8cef4a1d1..da6701900 100644
--- a/app/Manager/Notification.php
+++ b/app/Manager/Notification.php
@@ -2,7 +2,7 @@
namespace Gazelle\Manager;
-use \Gazelle\NotificationTicketState;
+use Gazelle\NotificationTicketState;
class Notification extends \Gazelle\Base {
use \Gazelle\Pg;
diff --git a/app/Manager/NotificationTicket.php b/app/Manager/NotificationTicket.php
index a914bf7be..baf12c577 100644
--- a/app/Manager/NotificationTicket.php
+++ b/app/Manager/NotificationTicket.php
@@ -2,7 +2,7 @@
namespace Gazelle\Manager;
-use \Gazelle\NotificationTicketState;
+use Gazelle\NotificationTicketState;
class NotificationTicket {
use \Gazelle\Pg;
diff --git a/app/Manager/Payment.php b/app/Manager/Payment.php
index 1dd66c8db..ba121ca36 100644
--- a/app/Manager/Payment.php
+++ b/app/Manager/Payment.php
@@ -2,7 +2,7 @@
namespace Gazelle\Manager;
-use \Gazelle\Exception\PaymentFetchForexException;
+use Gazelle\Exception\PaymentFetchForexException;
class Payment extends \Gazelle\Base {
final const LIST_KEY = 'payment_list';
diff --git a/app/Manager/PermissionRateLimit.php b/app/Manager/PermissionRateLimit.php
index 228f6b1c6..a3cf7c694 100644
--- a/app/Manager/PermissionRateLimit.php
+++ b/app/Manager/PermissionRateLimit.php
@@ -3,7 +3,6 @@
namespace Gazelle\Manager;
class PermissionRateLimit extends \Gazelle\Base {
-
public function list(): array {
self::$db->prepared_query('
SELECT p.ID, p.Name, prl.factor, prl.overshoot
diff --git a/app/Manager/Recovery.php b/app/Manager/Recovery.php
index 25f8903a8..59a60e9e8 100644
--- a/app/Manager/Recovery.php
+++ b/app/Manager/Recovery.php
@@ -97,7 +97,7 @@ public function saveScreenshot(array $upload): array {
if ($file['size'] > 10 * 1024 * 1024) {
return [false, "File was too large, please make sure it is less than 10MB in size."];
}
- $filename = sha1(RECOVERY_SALT . random_int(0, 10_000_000). sha1_file($file['tmp_name']));
+ $filename = sha1(RECOVERY_SALT . random_int(0, 10_000_000) . sha1_file($file['tmp_name']));
$destination = sprintf('%s/%s/%s/%s/%s',
RECOVERY_PATH, substr($filename, 0, 1), substr($filename, 1, 1), substr($filename, 2, 1), $filename
);
@@ -328,7 +328,7 @@ public function search(array $terms): ?array {
}
protected function candidateSql(): string {
- return match(true) {
+ return match (true) {
self::$db->entityExists('users_main', 'Uploaded') =>
sprintf('
SELECT m.Username, m.torrent_pass, m.Email, m.Uploaded, m.Downloaded, m.Enabled, m.PermissionID, m.ID as UserID,
@@ -350,7 +350,6 @@ protected function candidateSql(): string {
),
default => throw new \Exception('Cannot determine recovery schema')
};
-
}
public function findCandidate(string $username): ?array {
@@ -365,8 +364,7 @@ protected function userDetailsSql($schema = null): string {
$permission_t = "$schema.permissions";
$users_main_t = "$schema.users_main";
$torrents_t = "$schema.torrents";
- }
- else {
+ } else {
$permission_t = 'permissions';
$users_main_t = 'users_main';
$torrents_t = 'torrents';
@@ -493,12 +491,10 @@ public function boostUpload(): void {
$irc_message = "Upscaled from $uploaded to $rescale_uploaded from final irc userclass $irc_userclass";
$final += 1.5 * ($rescale_uploaded - $final);
$irc_change = "\n\nThe above buffer calculation takes into account your final recorded userclass on IRC '$irc_userclass'";
- }
- else {
+ } else {
$irc_message = "No change from logged irc userclass $irc_userclass";
}
- }
- else {
+ } else {
$irc_message = 'never joined #APOLLO';
}
diff --git a/app/Manager/Referral.php b/app/Manager/Referral.php
index ad4ddef14..5a3519205 100644
--- a/app/Manager/Referral.php
+++ b/app/Manager/Referral.php
@@ -218,7 +218,7 @@ public function getReferredUsers(string $startDate, string $endDate, ?string $si
if ($view === 'pending') {
$filter[] = 'ru.Active = 0';
- } else if ($view === 'processed') {
+ } elseif ($view === 'processed') {
$filter[] = 'ru.Active = 1';
}
@@ -476,7 +476,7 @@ private function verifyGGNAccount(array $acc, string $user, string $key): string
);
$json = json_decode($result["response"], true);
- return str_contains($json["response"]["profileText"], $key) ? true :"Token not found. Please try again.";
+ return str_contains($json["response"]["profileText"], $key) ? true : "Token not found. Please try again.";
}
private function verifyTentacleAccount(array $acc, string $user, string $key): string|true {
@@ -487,7 +487,7 @@ private function verifyTentacleAccount(array $acc, string $user, string $key): s
$url = $acc["URL"] . 'user/profile/' . $user;
$result = $this->proxy->fetch($url, [], $acc["Cookie"], false);
- return str_contains($result["response"], $key) ? true :"Token not found. Please try again.";
+ return str_contains($result["response"], $key) ? true : "Token not found. Please try again.";
}
private function verifyLuminanceAccount(array $acc, string $user, string $key): string|true {
@@ -498,7 +498,7 @@ private function verifyLuminanceAccount(array $acc, string $user, string $key):
$url = $acc["URL"] . 'user.php';
$result = $this->proxy->fetch($url, ["id" => $user], $acc["Cookie"], false);
- return str_contains($result["response"], $key) ? true :"Token not found. Please try again.";
+ return str_contains($result["response"], $key) ? true : "Token not found. Please try again.";
}
private function verifyGazelleHTMLAccount(array $acc, string $user, string $key): string|true {
@@ -509,7 +509,7 @@ private function verifyGazelleHTMLAccount(array $acc, string $user, string $key)
$url = $acc["URL"] . 'user.php';
$result = $this->proxy->fetch($url, ["id" => $user], $acc["Cookie"], false);
- return str_contains($result["response"], $key) ? true :"Token not found. Please try again.";
+ return str_contains($result["response"], $key) ? true : "Token not found. Please try again.";
}
private function verifyPTPAccount(array $acc, string $user, string $key): string|true {
@@ -519,7 +519,7 @@ private function verifyPTPAccount(array $acc, string $user, string $key): string
$url = $acc["URL"] . 'user.php';
$result = $this->proxy->fetch($url, ["id" => $user], $acc["Cookie"], false);
- return str_contains($result["response"], $key) ? true :"Token not found. Please try again.";
+ return str_contains($result["response"], $key) ? true : "Token not found. Please try again.";
}
public function generateInvite(array $acc, string $username, string $email): array {
diff --git a/app/Manager/SiteLog.php b/app/Manager/SiteLog.php
index bb5178081..7b04e4b30 100644
--- a/app/Manager/SiteLog.php
+++ b/app/Manager/SiteLog.php
@@ -7,7 +7,7 @@ class SiteLog extends \Gazelle\Base {
protected array $result = [];
protected array $usernames = [];
- public function __construct (
+ public function __construct(
protected \Gazelle\Manager\User $userMan,
) {}
@@ -115,21 +115,21 @@ public function colorize(string $message): array {
for ($i = 0, $n = count($parts); $i < $n; $i++) {
if (str_starts_with($parts[$i], SITE_URL)) {
$offset = strlen(SITE_URL) + 1; // trailing slash
- $parts[$i] = ''.substr($parts[$i], $offset).'';
+ $parts[$i] = '' . substr($parts[$i], $offset) . '';
}
switch (strtolower($parts[$i])) {
case 'artist':
$id = $parts[$i + 1];
if ((int)$id) {
- $message .= ' ' .$parts[$i++]." $id";
+ $message .= ' ' . $parts[$i++] . " $id";
} else {
- $message .= ' ' .$parts[$i];
+ $message .= ' ' . $parts[$i];
}
break;
case 'collage':
$id = $parts[$i + 1];
if ((int)$id) {
- $message .= ' ' .$parts[$i]." $id";
+ $message .= ' ' . $parts[$i] . " $id";
$i++;
} else {
$message .= " {$parts[$i]}";
@@ -138,18 +138,18 @@ public function colorize(string $message): array {
case 'group':
$id = $parts[$i + 1];
if ((int)$id) {
- $message .= ' ' .$parts[$i]." $id";
+ $message .= ' ' . $parts[$i] . " $id";
} else {
- $message .= ' ' .$parts[$i];
+ $message .= ' ' . $parts[$i];
}
$i++;
break;
case 'request':
$id = $parts[$i + 1];
if ((int)$id) {
- $message .= ' ' .$parts[$i++]." $id";
+ $message .= ' ' . $parts[$i++] . " $id";
} else {
- $message .= ' ' .$parts[$i];
+ $message .= ' ' . $parts[$i];
}
break;
case 'torrent':
@@ -168,7 +168,7 @@ public function colorize(string $message): array {
if ((int)($parts[$i + 1])) {
$userId = $parts[++$i];
}
- $URL = "user $userId (".substr($parts[++$i], 1, -1).')';
+ $URL = "user $userId (" . substr($parts[++$i], 1, -1) . ')';
} elseif (in_array($parts[$i - 1], ['deleted', 'uploaded', 'edited', 'created', 'recovered'])) {
$username = $parts[++$i];
if (str_ends_with($username, ':')) {
@@ -176,7 +176,7 @@ public function colorize(string $message): array {
$colon = true;
}
$userId = $this->usernameLookup($username);
- $URL = $userId ? "$username".($colon ? ':' : '') : $username;
+ $URL = $userId ? "$username" . ($colon ? ':' : '') : $username;
}
$message .= " by $URL";
break;
diff --git a/app/Manager/SiteOption.php b/app/Manager/SiteOption.php
index 3a2013b31..9c9e7c415 100644
--- a/app/Manager/SiteOption.php
+++ b/app/Manager/SiteOption.php
@@ -18,7 +18,7 @@ public function create(string $name, string $value, string $comment): ?int {
VALUES (?, ?, ?)
', $name, $value, $comment
);
- } catch (\Gazelle\DB\Mysql_DuplicateKeyException) {
+ } catch (\Gazelle\DB\MysqlDuplicateKeyException) {
return null;
}
self::$cache->cache_value(sprintf(self::CACHE_KEY, $name), $value);
diff --git a/app/Manager/StaffPM.php b/app/Manager/StaffPM.php
index 45fd9b699..1bccfdaab 100644
--- a/app/Manager/StaffPM.php
+++ b/app/Manager/StaffPM.php
@@ -180,7 +180,7 @@ public function staffHistory(int $classLevel, array $userIds, int $interval): ar
LEFT JOIN staff_pm_conversations spc ON (spc.ResolverID = um.ID AND spc.Status = 'Resolved' AND spc.Date > now() - INTERVAL ? DAY)
WHERE spm.SentDate > now() - INTERVAL ? DAY
AND p.Level <= ?
- AND um.ID IN (" . placeholders($userIds) .")
+ AND um.ID IN (" . placeholders($userIds) . ")
GROUP BY um.ID
ORDER BY total DESC, total2 DESC
", $interval, $interval, $classLevel, ...$userIds);
@@ -198,7 +198,7 @@ public function userHistory(int $classLevel, array $userIds, int $interval): arr
LEFT JOIN staff_pm_conversations spc ON (spc.UserID = um.ID AND spc.Date > now() - INTERVAL ? DAY)
WHERE spm.SentDate > now() - INTERVAL ? DAY
AND p.Level <= ?
- AND um.ID NOT IN (" . placeholders($userIds) .")
+ AND um.ID NOT IN (" . placeholders($userIds) . ")
GROUP BY um.ID
ORDER BY total DESC, total2 DESC
", $interval, $interval, $classLevel, ...$userIds);
diff --git a/app/Manager/Stylesheet.php b/app/Manager/Stylesheet.php
index 7ae39c148..d4b2d291a 100644
--- a/app/Manager/Stylesheet.php
+++ b/app/Manager/Stylesheet.php
@@ -2,7 +2,7 @@
namespace Gazelle\Manager;
-use \Gazelle\Enum\UserStatus;
+use Gazelle\Enum\UserStatus;
class Stylesheet extends \Gazelle\Base {
final const CACHE_KEY = 'csslist';
diff --git a/app/Manager/TGroup.php b/app/Manager/TGroup.php
index 4176e7fd7..a73efdb5c 100644
--- a/app/Manager/TGroup.php
+++ b/app/Manager/TGroup.php
@@ -83,7 +83,6 @@ public function createFromTorrent(
$new->flush()->refresh();
$torrent->flush();
return $new;
-
}
public function findById(int $tgroupId): ?\Gazelle\TGroup {
diff --git a/app/Manager/Tag.php b/app/Manager/Tag.php
index b72a56205..846afaad5 100644
--- a/app/Manager/Tag.php
+++ b/app/Manager/Tag.php
@@ -355,7 +355,7 @@ public function aliasList(): array {
");
$aliasList = self::$db->to_array(false, MYSQLI_ASSOC, false);
// Unify tag aliases to be in_this_format as tags not in.this.format
- array_walk_recursive($aliasList, function(&$val, $key) {
+ array_walk_recursive($aliasList, function (&$val, $key) {
$val = strtr($val, '.', '_');
});
// Clean up the array for smaller cache size
@@ -396,7 +396,7 @@ public function replaceAliasList(array $Tags): array {
for ($i = 0; $i < $End; $i++) {
foreach ($TagAliases as $TagAlias) {
if (substr($Tags['exclude'][$i], 1) === $TagAlias['BadTag']) {
- $Tags['exclude'][$i] = '!'.$TagAlias['AliasTag'];
+ $Tags['exclude'][$i] = '!' . $TagAlias['AliasTag'];
break;
}
}
diff --git a/app/Manager/Torrent.php b/app/Manager/Torrent.php
index 30e1447fb..a8bc9f5ea 100644
--- a/app/Manager/Torrent.php
+++ b/app/Manager/Torrent.php
@@ -58,7 +58,7 @@ public function create(
?, ?
)", $tgroup->id(), $user->id(), $media, $format, $encoding,
$isRemaster ? '1' : '0', $remasterYear, $remasterTitle, $remasterRecordLabel, $remasterCatalogueNumber,
- $infohash, $isScene ? '1': '0', $logScore, $hasChecksum ? '1' : '0', $hasLog ? '1' : '0',
+ $infohash, $isScene ? '1' : '0', $logScore, $hasChecksum ? '1' : '0', $hasLog ? '1' : '0',
$hasCue ? '1' : '0', $hasLogInDB ? '1' : '0', $filePath, count($fileList), implode("\n", $fileList),
$size, $description,
);
@@ -252,8 +252,7 @@ public function setSourceFlag(\OrpheusNET\BencodeTorrent\BencodeTorrent $torrent
if (!is_null($creationDate)) {
if (is_null($torrentSource) && $creationDate <= GRANDFATHER_OLD_SOURCE) {
return false;
- }
- elseif (!is_null($torrentSource) && $torrentSource === GRANDFATHER_SOURCE && $creationDate <= GRANDFATHER_OLD_SOURCE) {
+ } elseif (!is_null($torrentSource) && $torrentSource === GRANDFATHER_SOURCE && $creationDate <= GRANDFATHER_OLD_SOURCE) {
return false;
}
}
diff --git a/app/Manager/User.php b/app/Manager/User.php
index 340dffc80..b04944222 100644
--- a/app/Manager/User.php
+++ b/app/Manager/User.php
@@ -576,7 +576,7 @@ public function sendSnatchPm(\Gazelle\User $viewer, \Gazelle\Torrent $torrent,
$this->sendPM($userId, 0, $subject, $body);
}
$total = count($snatchers);
- (new \Gazelle\Log)->general($viewer->username()." sent a mass PM to $total snatcher" . plural($total)
+ (new \Gazelle\Log)->general($viewer->username() . " sent a mass PM to $total snatcher" . plural($total)
. " of torrent " . $torrent->id() . " (" . $torrent->group()->text() . ")"
);
return $total;
diff --git a/app/Manager/UserLink.php b/app/Manager/UserLink.php
index 29116c9dc..7fa06a5c6 100644
--- a/app/Manager/UserLink.php
+++ b/app/Manager/UserLink.php
@@ -95,7 +95,7 @@ public function dupe(\Gazelle\User $target, string $adminUsername, bool $updateN
return true;
}
- function addGroupComments(string $comments, string $adminName, bool $updateNote): void {
+ public function addGroupComments(string $comments, string $adminName, bool $updateNote): void {
$groupId = $this->groupId($this->user);
$oldHash = self::$db->scalar("
SELECT sha1(Comments) AS CommentHash
@@ -124,7 +124,7 @@ function addGroupComments(string $comments, string $adminName, bool $updateNote)
}
}
- function info(): array {
+ public function info(): array {
$sourceId = $this->user->id();
[$linkedGroupId, $comments] = self::$db->row("
SELECT d.ID, d.Comments
@@ -146,7 +146,7 @@ function info(): array {
return [$linkedGroupId, $comments ?? '', self::$db->to_array(false, MYSQLI_ASSOC, false)];
}
- function remove(\Gazelle\User $target, string $adminName): int {
+ public function remove(\Gazelle\User $target, string $adminName): int {
$targetId = $target->id();
self::$db->prepared_query("
UPDATE users_info AS i
@@ -170,7 +170,7 @@ function remove(\Gazelle\User $target, string $adminName): int {
return self::$db->affected_rows();
}
- function removeGroup(int $linkGroupId): int {
+ public function removeGroup(int $linkGroupId): int {
self::$db->prepared_query("
DELETE FROM dupe_groups WHERE ID = ?
", $linkGroupId
diff --git a/app/Manager/UserToken.php b/app/Manager/UserToken.php
index 55ee6f038..0da4ac11d 100644
--- a/app/Manager/UserToken.php
+++ b/app/Manager/UserToken.php
@@ -2,7 +2,7 @@
namespace Gazelle\Manager;
-use \Gazelle\Enum\UserTokenType;
+use Gazelle\Enum\UserTokenType;
class UserToken extends \Gazelle\BaseManager {
use \Gazelle\Pg;
diff --git a/app/Notification/Upload.php b/app/Notification/Upload.php
index 9d3173afd..f63a5d640 100644
--- a/app/Notification/Upload.php
+++ b/app/Notification/Upload.php
@@ -2,8 +2,8 @@
namespace Gazelle\Notification;
-use \Gazelle\Util\Irc;
-use \Gazelle\Util\IrcText;
+use Gazelle\Util\Irc;
+use Gazelle\Util\IrcText;
// NB: if you receive failures running this locally, the most likely cause is the
// presence of users_notify_filters rows that match the uploads created here.
@@ -299,7 +299,7 @@ public function sendIrcNotification(): void {
public function ircNotification(): string {
$torrent = $this->torrent;
$tgroup = $torrent->group();
- return match($tgroup->categoryName()) {
+ return match ($tgroup->categoryName()) {
'Music' => Irc::render(
IrcText::Bold,
'TORRENT:',
diff --git a/app/NotificationTicket.php b/app/NotificationTicket.php
index 9bb51367f..65d84cfd8 100644
--- a/app/NotificationTicket.php
+++ b/app/NotificationTicket.php
@@ -134,7 +134,7 @@ public function setStale(): static {
}
public function ticketState(string $state): NotificationTicketState {
- return match($state) {
+ return match ($state) {
'pending' => NotificationTicketState::Pending,
'stale' => NotificationTicketState::Stale,
'active' => NotificationTicketState::Active,
diff --git a/app/Report/AbstractReport.php b/app/Report/AbstractReport.php
index 9aa086084..f9a672f95 100644
--- a/app/Report/AbstractReport.php
+++ b/app/Report/AbstractReport.php
@@ -3,7 +3,6 @@
namespace Gazelle\Report;
abstract class AbstractReport extends \Gazelle\Base {
-
/**
* The context array is used to stash away pieces of information that will
* be needed in the template, but are too complicated to derive within the
diff --git a/app/Report/ForumPost.php b/app/Report/ForumPost.php
index 79bb7f619..39454d031 100644
--- a/app/Report/ForumPost.php
+++ b/app/Report/ForumPost.php
@@ -3,7 +3,6 @@
namespace Gazelle\Report;
class ForumPost extends AbstractReport {
-
public function __construct(
protected int $reportId,
protected \Gazelle\ForumPost $subject
diff --git a/app/Request.php b/app/Request.php
index 60d8f9eb6..a1982a694 100644
--- a/app/Request.php
+++ b/app/Request.php
@@ -29,7 +29,7 @@ public function location(): string { return 'requests.php?action=view&id=' . $th
*/
public function selfLink(): string {
$title = display_str($this->title());
- return match($this->categoryName()) {
+ return match ($this->categoryName()) {
'Music' =>
"{$this->artistRole()->link()} – "
. ($this->isFilled()
@@ -52,7 +52,7 @@ public function selfLink(): string {
* Display the title of a request, with all fields linkified where it makes sense.
*/
public function smartLink(): string {
- return match($this->categoryName()) {
+ return match ($this->categoryName()) {
'Music' => "{$this->artistRole()->link()} – {$this->link()} [{$this->year()}]",
'Audiobooks', 'Comedy' => "{$this->link()} [{$this->year()}]",
default => $this->link(),
@@ -63,7 +63,7 @@ public function smartLink(): string {
* Display the full title of the request with no links.
*/
public function text(): string {
- return match($this->categoryName()) {
+ return match ($this->categoryName()) {
'Music' => "{$this->artistRole()->text()} – {$this->title()} [{$this->year()}]",
'Audiobooks',
'Comedy' => "{$this->title()} [{$this->year()}]",
@@ -564,7 +564,7 @@ public function fill(User $user, Torrent $torrent): int {
$user->addBounty($bounty);
$name = $torrent->group()->text();
$message = "One of your requests — [url={$this->location()}]{$name}[/url] — has been filled."
- ." You can view it here: [pl]{$torrent->id()}[/pl]";
+ . " You can view it here: [pl]{$torrent->id()}[/pl]";
self::$db->prepared_query("
SELECT UserID FROM requests_votes WHERE RequestID = ?
", $this->id
diff --git a/app/Router.php b/app/Router.php
index 6994d301d..6cdd3037f 100644
--- a/app/Router.php
+++ b/app/Router.php
@@ -33,12 +33,10 @@ public function addRoute(string|array $methods, string $action, string $path, bo
foreach ($methods as $method) {
$this->addRoute($method, $action, $path, $authorize);
}
- }
- else {
+ } else {
if (strtoupper($methods) === 'GET') {
$this->addGet($action, $path, $authorize);
- }
- elseif (strtoupper($methods) === 'POST') {
+ } elseif (strtoupper($methods) === 'POST') {
$this->addPost($action, $path, $authorize);
}
}
@@ -81,8 +79,7 @@ public function getRoute(string $action): string {
if (($this->authorize[$request_method] || $method['authorize']) && !$this->authorized()) {
throw new InvalidAccessException();
- }
- else {
+ } else {
return $method['file'];
}
}
diff --git a/app/Search/ASN.php b/app/Search/ASN.php
index fc30fa855..8f3f2075a 100644
--- a/app/Search/ASN.php
+++ b/app/Search/ASN.php
@@ -38,7 +38,7 @@ public function findByIpList(array $ipList): array {
coalesce(a.name, 'unknown') AS name,
a.id_asn AS n,
(t.id_tor_node IS NOT NULL) AS is_tor
- FROM (SELECT unnest(ARRAY[" . placeholders($ipList, "?::inet"). "]) as ip) AS lu
+ FROM (SELECT unnest(ARRAY[" . placeholders($ipList, "?::inet") . "]) as ip) AS lu
LEFT JOIN geo.asn_network an ON (an.network >>= lu.ip)
LEFT JOIN geo.asn a USING (id_asn)
LEFT JOIN tor_node t ON (t.ipv4 = lu.ip)
diff --git a/app/Search/Report.php b/app/Search/Report.php
index dc7bb2fb1..b9a620462 100644
--- a/app/Search/Report.php
+++ b/app/Search/Report.php
@@ -2,7 +2,7 @@
namespace Gazelle\Search;
-use \Gazelle\Enum\SearchReportOrder;
+use Gazelle\Enum\SearchReportOrder;
class Report extends \Gazelle\Base {
protected array $args = [];
diff --git a/app/Search/Request.php b/app/Search/Request.php
index 933c68ebd..0dbc2942b 100644
--- a/app/Search/Request.php
+++ b/app/Search/Request.php
@@ -244,7 +244,7 @@ public function limit(int $offset, int $limit, int $end): static {
public function execute(string $orderBy, string $direction): int {
if (isset($this->bookmarkerId)) {
- switch($orderBy) {
+ switch ($orderBy) {
case 'bounty':
$needVoteTable = true;
$orderBy = 'sum(rv.Bounty)';
diff --git a/app/Search/Torrent.php b/app/Search/Torrent.php
index 11ddb0aa1..c360fe35b 100644
--- a/app/Search/Torrent.php
+++ b/app/Search/Torrent.php
@@ -191,7 +191,7 @@ public function __construct(
) {
$ErrMsg = "Search\Torrent constructor arguments:\n" . print_r(func_get_args(), true);
global $Debug;
- $Debug->analysis('Bad arguments in Search\Torrent constructor', $ErrMsg, 3600*24);
+ $Debug->analysis('Bad arguments in Search\Torrent constructor', $ErrMsg, 3600 * 24);
error('-1');
}
$this->Page = $searchMany ? $Page : min($Page, SPHINX_MAX_MATCHES / $PageSize);
@@ -312,7 +312,7 @@ private function build_query(): void {
if (isset($Words['operator'])) {
// Is the operator already specified?
$Operator = $Words['operator'];
- } elseif(isset(self::$FieldOperators[$Field])) {
+ } elseif (isset(self::$FieldOperators[$Field])) {
// Does this field have a non-standard operator?
$Operator = self::$FieldOperators[$Field];
} else {
diff --git a/app/Staff.php b/app/Staff.php
index 6dc350207..3022a1dc4 100644
--- a/app/Staff.php
+++ b/app/Staff.php
@@ -10,7 +10,7 @@ public function link(): string { return $this->user()->link(); }
public function location(): string { return $this->user()->location(); }
public function blogAlert(): bool {
- if (($readTime = self::$cache->get_value('staff_blog_read_'. $this->user->id())) === false) {
+ if (($readTime = self::$cache->get_value('staff_blog_read_' . $this->user->id())) === false) {
$readTime = self::$db->scalar('
SELECT unix_timestamp(Time)
FROM staff_blog_visits
diff --git a/app/Stats/Artist.php b/app/Stats/Artist.php
index bb084fca3..87b8e98aa 100644
--- a/app/Stats/Artist.php
+++ b/app/Stats/Artist.php
@@ -18,7 +18,7 @@ public function info(): array {
return $this->info;
}
$key = sprintf(self::CACHE_KEY, $this->id);
- $info =self::$cache->get_value($key);
+ $info = self::$cache->get_value($key);
if ($info === false) {
$info = self::$db->rowAssoc("
SELECT count(*) AS torrent_total,
diff --git a/app/Stats/Artists.php b/app/Stats/Artists.php
index 9840f41c8..f5b3bb79b 100644
--- a/app/Stats/Artists.php
+++ b/app/Stats/Artists.php
@@ -3,7 +3,6 @@
namespace Gazelle\Stats;
class Artists extends \Gazelle\Base {
-
public function updateUsage(): int {
self::$db->begin_transaction();
self::$db->prepared_query("
diff --git a/app/Stats/Economic.php b/app/Stats/Economic.php
index 83518a43d..a2e13f32d 100644
--- a/app/Stats/Economic.php
+++ b/app/Stats/Economic.php
@@ -100,4 +100,3 @@ public function info(): array {
return $this->info;
}
}
-
diff --git a/app/Stats/User.php b/app/Stats/User.php
index b707f0682..42a628280 100644
--- a/app/Stats/User.php
+++ b/app/Stats/User.php
@@ -267,9 +267,9 @@ public function timeline(): array {
);
$stats = array_reverse(self::$db->to_array(false, MYSQLI_ASSOC, false));
$timeline = array_column($stats, 'epoch');
- foreach(['data_up', 'data_down', 'buffer', 'bp', 'uploads', 'perfect'] as $dimension) {
+ foreach (['data_up', 'data_down', 'buffer', 'bp', 'uploads', 'perfect'] as $dimension) {
$series = array_column($stats, $dimension);
- $chart[$dimension] = array_map(fn($n) => [$timeline[$n], $series[$n]], range(0, count($series)-1));
+ $chart[$dimension] = array_map(fn($n) => [$timeline[$n], $series[$n]], range(0, count($series) - 1));
}
$chart['start'] = $timeline[0] ?? null;
unset($chart);
diff --git a/app/TGroup.php b/app/TGroup.php
index 2e4ddba4c..043e24fea 100644
--- a/app/TGroup.php
+++ b/app/TGroup.php
@@ -35,7 +35,7 @@ public function flush(): static {
public function link(): string {
$url = "url()}\" title=\"" . ($this->hashTag() ?: 'View torrent group') . '" dir="ltr">'
. display_str($this->name()) . '';
- return match($this->categoryName()) {
+ return match ($this->categoryName()) {
'Music' => "{$this->artistRole()->link()} – $url [{$this->year()} {$this->releaseTypeName()}]",
'Audiobooks',
'Comedy' => "$url [{$this->year()}]",
@@ -48,7 +48,7 @@ public function location(): string { return "torrents.php?id={$this->id}"; }
public function torrentLink(int $torrentId): string {
$url = '"
. display_str($this->name()) . '';
- return match($this->categoryName()) {
+ return match ($this->categoryName()) {
'Music' => "{$this->artistRole()->link()} – $url [{$this->year()} {$this->releaseTypeName()}]",
'Audiobooks',
'Comedy' => "$url [{$this->year()}]",
@@ -57,7 +57,7 @@ public function torrentLink(int $torrentId): string {
}
public function text(): string {
- return match($this->categoryName()) {
+ return match ($this->categoryName()) {
'Music' => "{$this->artistRole()->text()} – {$this->name()} [{$this->year()} {$this->releaseTypeName()}]"
. ($this->isShowcase() ? '[Showcase]' : ''),
'Audiobooks',
diff --git a/app/Task.php b/app/Task.php
index 1c5cc7d93..d5341dbda 100644
--- a/app/Task.php
+++ b/app/Task.php
@@ -2,7 +2,7 @@
namespace Gazelle;
-use \Gazelle\Util\Irc;
+use Gazelle\Util\Irc;
abstract class Task extends Base {
protected array $events = [];
@@ -40,7 +40,7 @@ public function end(bool $sane): int {
', 'completed', $errorCount, $this->processed, $elapsed, $this->historyId
);
- echo("DONE! (".number_format(microtime(true) - $this->startTime, 3).")\n");
+ echo("DONE! (" . number_format(microtime(true) - $this->startTime, 3) . ")\n");
foreach ($this->events as $event) {
printf("%s [%s] (%d) %s\n", $event->timestamp, $event->severity, $event->reference, $event->event);
@@ -61,7 +61,7 @@ public function end(bool $sane): int {
Irc::sendMessage(LAB_CHAN, 'Task ' . $this->name . ' is no longer sane ' . SITE_URL . '/tools.php?action=periodic&mode=detail&id=' . $this->taskId);
// todo: send notifications to appropriate users
- } else if ($errorCount == 0 && !$sane) {
+ } elseif ($errorCount == 0 && !$sane) {
self::$db->prepared_query('
UPDATE periodic_task SET
is_sane = TRUE
diff --git a/app/Task/Peerupdate.php b/app/Task/Peerupdate.php
index 2cfc4b4c0..0891cb36c 100644
--- a/app/Task/Peerupdate.php
+++ b/app/Task/Peerupdate.php
@@ -8,4 +8,3 @@ public function run(): void {
$this->processed += $updated;
}
}
-
diff --git a/app/Task/UploadNotifier.php b/app/Task/UploadNotifier.php
index cca12ce39..d8555c2e9 100644
--- a/app/Task/UploadNotifier.php
+++ b/app/Task/UploadNotifier.php
@@ -11,4 +11,3 @@ public function run(): void {
);
}
}
-
diff --git a/app/Task/UserLastAccess.php b/app/Task/UserLastAccess.php
index 2201e21f8..f3637fa35 100644
--- a/app/Task/UserLastAccess.php
+++ b/app/Task/UserLastAccess.php
@@ -7,4 +7,3 @@ public function run(): void {
$this->processed += (new \Gazelle\Manager\User)->updateLastAccess();
}
}
-
diff --git a/app/TaskScheduler.php b/app/TaskScheduler.php
index b4ffe9dcd..c193de037 100644
--- a/app/TaskScheduler.php
+++ b/app/TaskScheduler.php
@@ -2,7 +2,7 @@
namespace Gazelle;
-use \Gazelle\Util\Irc;
+use Gazelle\Util\Irc;
class TaskScheduler extends Base {
final const CACHE_TASKS = 'scheduled_tasks';
@@ -33,7 +33,7 @@ public function getInsaneTasks(): int {
}
public static function isClassValid(string $class): bool {
- $class = 'Gazelle\\Task\\'.$class;
+ $class = 'Gazelle\\Task\\' . $class;
return class_exists($class);
}
diff --git a/app/Top10/Torrent.php b/app/Top10/Torrent.php
index edd6757c3..b69dc9f5d 100644
--- a/app/Top10/Torrent.php
+++ b/app/Top10/Torrent.php
@@ -16,7 +16,7 @@ class Torrent extends \Gazelle\Base {
ORDER BY %s
LIMIT %s";
- public function __construct (
+ public function __construct(
protected readonly array $formats,
protected readonly \Gazelle\User $viewer,
) {}
@@ -172,7 +172,7 @@ private function tagWhere(string $getParameters, bool $any = false): array {
private function flatten(array $array): array {
$return = [];
- array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; });
+ array_walk_recursive($array, function ($a) use (&$return) { $return[] = $a; });
return $return;
}
}
diff --git a/app/Top10/User.php b/app/Top10/User.php
index 8079c0b80..9df409397 100644
--- a/app/Top10/User.php
+++ b/app/Top10/User.php
@@ -72,4 +72,3 @@ public function fetch(string $type, int $limit): array {
return $results;
}
}
-
diff --git a/app/Torrent.php b/app/Torrent.php
index 1530508d4..2f6f68e14 100644
--- a/app/Torrent.php
+++ b/app/Torrent.php
@@ -100,7 +100,7 @@ public function hasToken(int $userId): bool {
public function torrentFilename(bool $asText, int $maxLength): string {
$tgroup = $this->group();
$filename = implode('.',
- match($tgroup->categoryName()) {
+ match ($tgroup->categoryName()) {
'Music' => [
$tgroup->artistRole()->text(), $tgroup->year(), $tgroup->name(),
'(' . implode('-', [$this->media(), $this->format(), $this->encoding()]) . ')'
diff --git a/app/Torrent/Deleted.php b/app/Torrent/Deleted.php
index bb8ea375d..7bb6bf13b 100644
--- a/app/Torrent/Deleted.php
+++ b/app/Torrent/Deleted.php
@@ -9,7 +9,7 @@ class Deleted extends \Gazelle\Base {
*
* @return array of many things
*/
- static public function info(int $torrentId): array {
+ public static function info(int $torrentId): array {
$template = "SELECT t.GroupID, t.UserID, t.Media, t.Format, t.Encoding,
t.Remastered, t.RemasterYear, t.RemasterTitle, t.RemasterCatalogueNumber, t.RemasterRecordLabel,
t.Scene, t.HasLog, t.HasCue, t.HasLogDB, t.LogScore, t.LogChecksum,
diff --git a/app/Torrent/Reaper.php b/app/Torrent/Reaper.php
index 7dd953a41..2ecdca2d5 100644
--- a/app/Torrent/Reaper.php
+++ b/app/Torrent/Reaper.php
@@ -554,17 +554,14 @@ public function stats(): array {
GROUP BY notify, state
");
$results = self::$db->to_array(false, MYSQLI_ASSOC, false);
- foreach($results as $r) {
+ foreach ($results as $r) {
if ($r['state'] == ReaperState::UNSEEDED->value && $r['notify'] == ReaperNotify::INITIAL->value) {
$stats['unseeded_initial'] = $r['total'];
- }
- elseif ($r['state'] == ReaperState::UNSEEDED->value && $r['notify'] == ReaperNotify::FINAL->value) {
+ } elseif ($r['state'] == ReaperState::UNSEEDED->value && $r['notify'] == ReaperNotify::FINAL->value) {
$stats['unseeded_final'] = $r['total'];
- }
- elseif ($r['state'] == ReaperState::NEVER->value && $r['notify'] == ReaperNotify::INITIAL->value) {
+ } elseif ($r['state'] == ReaperState::NEVER->value && $r['notify'] == ReaperNotify::INITIAL->value) {
$stats['never_seeded_initial'] = $r['total'];
- }
- else {
+ } else {
$stats['never_seeded_final'] = $r['total'];
}
}
diff --git a/app/Torrent/ReaperState.php b/app/Torrent/ReaperState.php
index dd4e1442e..1ab1aa28e 100644
--- a/app/Torrent/ReaperState.php
+++ b/app/Torrent/ReaperState.php
@@ -7,7 +7,7 @@ enum ReaperState: string {
case UNSEEDED = 'unseeded';
public function notifyAttr(): string {
- return match($this) {
+ return match ($this) {
ReaperState::NEVER => 'no-pm-unseeded-upload',
ReaperState::UNSEEDED => 'no-pm-unseeded-snatch', /** @phpstan-ignore-line */
};
diff --git a/app/TorrentAbstract.php b/app/TorrentAbstract.php
index e1d490d23..3154e461b 100644
--- a/app/TorrentAbstract.php
+++ b/app/TorrentAbstract.php
@@ -87,19 +87,13 @@ public function info(): array {
if (is_null($info)) {
return $this->info = [];
}
- foreach (['last_action', 'LastReseedRequest', 'RemasterCatalogueNumber', 'RemasterRecordLabel', 'RemasterTitle', 'RemasterYear']
- as $nullable
- ) {
+ foreach (['last_action', 'LastReseedRequest', 'RemasterCatalogueNumber', 'RemasterRecordLabel', 'RemasterTitle', 'RemasterYear'] as $nullable) {
$info[$nullable] = $info[$nullable] == '' ? null : $info[$nullable];
}
- foreach (['LogChecksum', 'HasCue', 'HasLog', 'HasLogDB', 'Remastered', 'Scene']
- as $zerotruth
- ) {
+ foreach (['LogChecksum', 'HasCue', 'HasLog', 'HasLogDB', 'Remastered', 'Scene'] as $zerotruth) {
$info[$zerotruth] = !($info[$zerotruth] == '0');
}
- foreach (['BadFiles', 'BadFolders', 'BadTags', 'CassetteApproved', 'LossymasterApproved', 'LossywebApproved', 'MissingLineage']
- as $emptytruth
- ) {
+ foreach (['BadFiles', 'BadFolders', 'BadTags', 'CassetteApproved', 'LossymasterApproved', 'LossywebApproved', 'MissingLineage'] as $emptytruth) {
$info[$emptytruth] = !($info[$emptytruth] == '');
}
@@ -253,7 +247,7 @@ public function format(): ?string {
}
public function leechType(): LeechType {
- return match($this->info()['FreeTorrent']) {
+ return match ($this->info()['FreeTorrent']) {
LeechType::Free->value => LeechType::Free,
LeechType::Neutral->value => LeechType::Neutral,
default => LeechType::Normal,
@@ -261,7 +255,7 @@ public function leechType(): LeechType {
}
public function leechReason(): LeechReason {
- return match($this->info()['FreeLeechType']) {
+ return match ($this->info()['FreeLeechType']) {
LeechReason::AlbumOfTheMonth->value => LeechReason::AlbumOfTheMonth,
LeechReason::Permanent->value => LeechReason::Permanent,
LeechReason::Showcase->value => LeechReason::Showcase,
@@ -582,8 +576,8 @@ public function isReseedRequestAllowed(): bool {
$lastActiveDate = (int)strtotime($this->lastActiveDate());
$createdDate = (int)strtotime($this->created());
- return match(true) {
- !$lastActiveDate && !$lastRequestDate => (time() >= strtotime(RESEED_NEVER_ACTIVE_TORRENT .' days', $createdDate)),
+ return match (true) {
+ !$lastActiveDate && !$lastRequestDate => (time() >= strtotime(RESEED_NEVER_ACTIVE_TORRENT . ' days', $createdDate)),
!$lastRequestDate => (time() >= strtotime(RESEED_TORRENT . 'days', $lastActiveDate)),
default => false,
};
diff --git a/app/TorrentFlag.php b/app/TorrentFlag.php
index a51992b0a..4e2aaca1f 100644
--- a/app/TorrentFlag.php
+++ b/app/TorrentFlag.php
@@ -12,7 +12,7 @@ enum TorrentFlag: string {
case noLineage = 'torrents_missing_lineage';
public function label(): string {
- return match($this) {
+ return match ($this) {
TorrentFlag::badFile => 'Bad Files',
TorrentFlag::badFolder => 'Bad Folders',
TorrentFlag::badTag => 'Bad Tags',
diff --git a/app/Upload.php b/app/Upload.php
index e1f7e0c33..017ac74cb 100644
--- a/app/Upload.php
+++ b/app/Upload.php
@@ -14,8 +14,8 @@
namespace Gazelle;
-use \Gazelle\Util\Textarea;
-use \OrpheusNET\Logchecker\Logchecker;
+use Gazelle\Util\Textarea;
+use OrpheusNET\Logchecker\Logchecker;
class Upload extends \Gazelle\Base {
protected int $categoryId = 0;
@@ -129,7 +129,8 @@ public function music_form(array $GenreTags, \Gazelle\Manager\TGroup $manager):
-