Skip to content

Commit

Permalink
apply phpcs PSR2.Methods.FunctionClosingBrace PSR12.Classes.ClassInst…
Browse files Browse the repository at this point in the history
…antiation
  • Loading branch information
Spine committed Apr 7, 2024
1 parent b9d7b93 commit 338a1fe
Show file tree
Hide file tree
Showing 596 changed files with 1,624 additions and 1,628 deletions.
6 changes: 2 additions & 4 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
<exclude name="PSR1.Files.SideEffects" />
<exclude name="PSR1.Methods.CamelCapsMethodName" />

<exclude name="PSR2.Classes.ClassDeclaration" />
<exclude name="PSR2.Classes.PropertyDeclaration" />
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
<exclude name="PSR2.Classes.PropertyDeclaration.SpacingAfterType" />
<exclude name="PSR2.Methods.FunctionCallSignature" />
<exclude name="PSR2.Methods.FunctionClosingBrace" />

<exclude name="PSR12.Classes.ClassInstantiation" />
<exclude name="PSR12.Classes.ClosingBrace" />
<exclude name="PSR12.ControlStructures.ControlStructureSpacing" />
<exclude name="PSR12.Files.FileHeader" />
Expand Down
4 changes: 2 additions & 2 deletions app/API/GenerateInvite.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class GenerateInvite extends AbstractAPI {
public function run() {
$userMan = new \Gazelle\Manager\User;
$userMan = new \Gazelle\Manager\User();
$interviewer = null;
if (isset($_GET['interviewer_id'])) {
$interviewer = $userMan->findById((int)$_GET['interviewer_id']);
Expand Down Expand Up @@ -39,7 +39,7 @@ public function run() {
$interviewer->id(), $key, $email, "Passed Interview"
);
if (!empty($_GET['email'])) {
(new Mail)->send($email, 'New account confirmation at ' . SITE_NAME,
(new Mail())->send($email, 'New account confirmation at ' . SITE_NAME,
self::$twig->render('email/invite-interviewer.twig', [
'inviter_name' => $interviewer->username(),
'inviter_key' => $key,
Expand Down
2 changes: 1 addition & 1 deletion app/API/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Request extends AbstractAPI {
public function run() {
$request = (new \Gazelle\Manager\Request)->findById((int)($_GET['request_id'] ?? 0));
$request = (new \Gazelle\Manager\Request())->findById((int)($_GET['request_id'] ?? 0));
if (is_null($request)) {
json_error('Missing request id');
}
Expand Down
4 changes: 2 additions & 2 deletions app/API/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function run() {
}

protected function torrent(int $id): array {
$torrent = (new \Gazelle\Manager\Torrent)->findById($id);
$torrent = (new \Gazelle\Manager\Torrent())->findById($id);
if (is_null($torrent)) {
json_error('Torrent not found');
}
Expand Down Expand Up @@ -45,7 +45,7 @@ protected function torrent(int $id): array {
}

protected function tgroup(int $id): array {
$tgroup = (new \Gazelle\Manager\TGroup)->findById($id);
$tgroup = (new \Gazelle\Manager\TGroup())->findById($id);
if (is_null($tgroup)) {
json_error('Group not found');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Applicant.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Applicant extends BaseObject {
final public const ENTRIES_PER_PAGE = 1000; // TODO: change to 50 and implement pagination

public function flush(): static {
(new Manager\Applicant)->flush();
(new Manager\Applicant())->flush();
if (isset($this->info)) {
self::$cache->delete_value("user_applicant_{$this->userId()}");
}
Expand Down
10 changes: 5 additions & 5 deletions app/ApplicantRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ public function apply(User $user, string $body): Applicant {
", $this->id, $user->id(), $body,
(new Manager\Thread())->createThread('staff-role')->id()
);
(new Manager\Applicant)->flush();
(new Manager\ApplicantRole)->flush();
(new Manager\Applicant())->flush();
(new Manager\ApplicantRole())->flush();
return new \Gazelle\Applicant(self::$db->inserted_id());
}

public function modify(): bool {
$modified = false;
$userMan = new Manager\User;
$userMan = new Manager\User();
$list = preg_split('/\s+/', $this->clearField('viewer_list'));
$viewerList = empty($list)
? []
Expand Down Expand Up @@ -141,8 +141,8 @@ public function remove(): int {
", $this->id
);
$affected = self::$db->affected_rows();
(new Manager\Applicant)->flush();
(new Manager\ApplicantRole)->flush();
(new Manager\Applicant())->flush();
(new Manager\ApplicantRole())->flush();
$this->flush();
return $affected;
}
Expand Down
8 changes: 4 additions & 4 deletions app/Artist.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public function aliasInfo(): array {
}

// go through the list and tie the alias to its non-redirecting ancestor
$userMan = new Manager\User;
$userMan = new Manager\User();
$alias = [];
foreach ($result as $aliasId => $info) {
if ($info['redirectId']) {
Expand All @@ -494,7 +494,7 @@ public function aliasInfo(): array {
'alias_id' => $aliasId,
'name' => $info['aliasName'],
'user' => $userMan->findById($info['userId']),
];
];
} else {
$alias[$aliasId] = [
'alias' => [],
Expand Down Expand Up @@ -796,7 +796,7 @@ public function rename(int $aliasId, string $name, Manager\Request $reqMan, User
UPDATE IGNORE torrents_artists SET AliasID = ? WHERE AliasID = ?
", $newId, $aliasId
);
$tgMan = new Manager\TGroup;
$tgMan = new Manager\TGroup();
foreach ($groups as $groupId) {
$tgMan->findById($groupId)?->refresh();
}
Expand Down Expand Up @@ -984,7 +984,7 @@ public function remove(User $user, Log $logger): int {
self::$db->prepared_query("DELETE FROM artists_tags WHERE ArtistID = ?", $id);
self::$db->prepared_query("DELETE FROM wiki_artists WHERE PageID = ?", $id);

(new \Gazelle\Manager\Comment)->remove('artist', $id);
(new \Gazelle\Manager\Comment())->remove('artist', $id);
$logger->general("Artist $id ($name) was deleted by " . $user->username());
self::$db->commit();

Expand Down
2 changes: 1 addition & 1 deletion app/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function get_value(string $key): mixed {
$begin = microtime(true);
if (empty($key)) {
$value = false;
} else {
} else {
$value = $this->get($key);
if (!isset($this->hit[$key])) {
$this->hit[$key] = 0;
Expand Down
4 changes: 2 additions & 2 deletions app/Collage/AbstractCollage.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function addEntry(int $entryId, \Gazelle\User $user): int {
/**
* Remove an entry from a collage
*/
public function removeEntry(int $entryId): int {
public function removeEntry(int $entryId): int {
self::$db->begin_transaction();
self::$db->prepared_query("
DELETE FROM {$this->entryTable()}
Expand Down Expand Up @@ -204,7 +204,7 @@ public function updateSequenceEntry(int $entryId, int $sequence): int {
return $affected;
}

public function remove(): int {
public function remove(): int {
self::$db->prepared_query("
UPDATE collages SET
Deleted = '1'
Expand Down
4 changes: 2 additions & 2 deletions app/Collage/TGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function load(): int {
$this->groupIds = [];
$this->contributors = [];
$this->created = [];
$tgMan = new \Gazelle\Manager\TGroup;
$tgMan = new \Gazelle\Manager\TGroup();
foreach ($groupIds as $groupId) {
$tgroup = $tgMan->findById($groupId);
if (is_null($tgroup)) {
Expand Down Expand Up @@ -135,7 +135,7 @@ public function remove(): int {
if (!$this->holder->isPersonal()) {
$rows = parent::remove();
} else {
(new \Gazelle\Manager\Comment)->remove('collages', $this->id);
(new \Gazelle\Manager\Comment())->remove('collages', $this->id);
self::$db->prepared_query("
DELETE FROM collages_torrents WHERE CollageID = ?
", $this->id
Expand Down
2 changes: 1 addition & 1 deletion app/Collector/Artist.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function prepare(array $list): bool {
}

public function fillZip(\ZipStream\ZipStream $zip): void {
$releaseMan = new \Gazelle\ReleaseType;
$releaseMan = new \Gazelle\ReleaseType();
while (($downloadList = $this->process('GroupID')) != null) {
foreach ($downloadList as $download) {
$torrent = $this->torMan->findById($download['TorrentID']);
Expand Down
2 changes: 1 addition & 1 deletion app/Comment/AbstractComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public function remove(): bool {
);
self::$db->commit();

(new \Gazelle\Manager\Subscription)->flushPage($page, $this->pageId);
(new \Gazelle\Manager\Subscription())->flushPage($page, $this->pageId);

self::$cache->delete_multi([
"edit_{$page}_" . $this->id,
Expand Down
2 changes: 1 addition & 1 deletion app/Contest/AbstractContest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function leaderboard(int $limit, int $offset): array {
);
$leaderboard = self::$db->to_array(false, MYSQLI_ASSOC, false);

$torMan = new \Gazelle\Manager\Torrent;
$torMan = new \Gazelle\Manager\Torrent();
for ($i = 0, $leaderboardCount = count($leaderboard); $i < $leaderboardCount; $i++) {
$torrent = $torMan->findById($leaderboard[$i]['last_entry_id']);
$leaderboard[$i]['last_entry_link']
Expand Down
4 changes: 2 additions & 2 deletions app/DB/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function enableQueryLog(): void {

private function halt(string $Msg): void {
if ($this->Errno == 1062) {
throw new MysqlDuplicateKeyException;
throw new MysqlDuplicateKeyException();
}
global $Debug;
$Debug->saveCase("MySQL: error({$this->Errno}) {$this->Error} query=[$this->PreparedQuery]");
Expand Down Expand Up @@ -235,7 +235,7 @@ public function execute(mixed ...$Parameters): \mysqli_result|bool {
return $Statement->get_result();
} catch (\mysqli_sql_exception) {
if ($this->LinkID && mysqli_error($this->LinkID) == 1062) {
throw new MysqlDuplicateKeyException;
throw new MysqlDuplicateKeyException();
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions app/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function saveCase(string $message): int {
$userId = (int)$Viewer?->id();
}

$id = (new \Gazelle\Manager\ErrorLog)->create(
$id = (new \Gazelle\Manager\ErrorLog())->create(
uri: $uri,
userId: $userId,
duration: $duration,
Expand All @@ -121,7 +121,7 @@ public function saveCase(string $message): int {
'includes' => $this->get_includes(),
'vars' => $this->get_logged_vars(),
'perf' => $this->get_perf(),
'ocelot' => (new \Gazelle\Tracker)->requestList(),
'ocelot' => (new \Gazelle\Tracker())->requestList(),
'searches' => class_exists('Sphinxql') ? \Sphinxql::$Queries : [],
'searches_time' => class_exists('Sphinxql') ? \Sphinxql::$Time : 0.0,
'queries' => $this->get_queries(),
Expand Down
2 changes: 1 addition & 1 deletion app/Donate/Bitcoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
'zpub' => $slip132->p2wpkh($btcPrefixes),
default => throw new DonationException("invalid xyzpub key $xyzpub"),
};
$network = new \BitWasp\Bitcoin\Network\Networks\Bitcoin;
$network = new \BitWasp\Bitcoin\Network\Networks\Bitcoin();
$config = new GlobalPrefixConfig([
new NetworkConfig($network, [$prefix])
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function authorize(): DownloadStatus {
self::$db->rollback();
return DownloadStatus::no_tokens;
}
if (!(new \Gazelle\Tracker)->addToken($this->torrent, $user)) {
if (!(new \Gazelle\Tracker())->addToken($this->torrent, $user)) {
self::$db->rollback();
return DownloadStatus::tracker;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function link(): string {

public function flush(): static {
$this->info = [];
(new Manager\Forum)->flushToc();
(new Manager\Forum())->flushToc();
self::$cache->delete_multi([
sprintf(self::CACHE_FORUM, $this->id),
sprintf(self::CACHE_TOC_FORUM, $this->id),
Expand Down
4 changes: 2 additions & 2 deletions app/ForumPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function pin(User $user, bool $set): int {
*/
public function remove(): bool {
self::$db->begin_transaction();
$db = new DB;
$db = new DB();
$db->relaxConstraints(true);
self::$db->prepared_query("
DELETE fp, unq
Expand Down Expand Up @@ -190,7 +190,7 @@ public function remove(): bool {
self::$db->commit();

$this->thread()->forum()->adjust();
(new \Gazelle\Manager\Subscription)->flushPage('forums', $threadId);
(new \Gazelle\Manager\Subscription())->flushPage('forums', $threadId);

$thread->flush();
$pageOffset = $this->page() - 1;
Expand Down
10 changes: 5 additions & 5 deletions app/ForumThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ForumThread extends BaseObject {
public function flush(): static {
self::$cache->delete_value(sprintf(self::CACHE_KEY, $this->id));
self::$cache->delete_value("edit_forums_{$this->id}");
(new Manager\Forum)->flushToc();
(new Manager\Forum())->flushToc();
$last = $this->lastPage();
$this->flushCatalog($last, $last);
return $this;
Expand Down Expand Up @@ -195,7 +195,7 @@ public function slice(int $page, int $perPage): array {
}

public function addPost(User $user, string $body): ForumPost {
$post = (new Manager\ForumPost)->create($this, $user, $body);
$post = (new Manager\ForumPost())->create($this, $user, $body);
$this->info();
$this->info['post_total_summary']++;
$this->info['last_post_id'] = $post->id();
Expand Down Expand Up @@ -281,7 +281,7 @@ public function editThread(Forum $forum, bool $pinned, int $rank, bool $locked,
public function remove(): int {
// LastPostID is a chicken and egg situation when removing a thread,
// so foreign key constraints need to be igored temporarily.
$db = new \Gazelle\DB;
$db = new \Gazelle\DB();
$db->relaxConstraints(true);
self::$db->prepared_query("
DELETE ft, fp, unq
Expand All @@ -295,7 +295,7 @@ public function remove(): int {
$db->relaxConstraints(false);
$this->forum()->adjust();

(new Manager\Subscription)->move('forums', $this->id, null);
(new Manager\Subscription())->move('forums', $this->id, null);

$previousPost = self::$db->rowAssoc("
SELECT AuthorID AS user_id,
Expand Down Expand Up @@ -348,7 +348,7 @@ protected function updateThread(User $user, int $postId): int {
$affected = self::$db->affected_rows();
if ($affected) {
$this->updateRoot($user->id(), $postId);
(new Manager\Forum)->flushToc();
(new Manager\Forum())->flushToc();
$this->forum()->flush();
$this->flush();
}
Expand Down
2 changes: 1 addition & 1 deletion app/Json/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function payload(): array {
$r['created'],
time_diff($r['created'], 2, false),
],
(new \Gazelle\Manager\News)->list($this->limit, $this->offset)
(new \Gazelle\Manager\News())->list($this->limit, $this->offset)
)
];
}
Expand Down
2 changes: 1 addition & 1 deletion app/Json/PM.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Gazelle\Json;

class PM extends \Gazelle\Json {
class PM extends \Gazelle\Json {
public function __construct(
protected \Gazelle\PM $pm,
protected \Gazelle\Manager\User $userMan,
Expand Down
2 changes: 1 addition & 1 deletion app/Json/RipLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function __construct(
) {}

public function payload(): array {
$filer = new \Gazelle\File\RipLog;
$filer = new \Gazelle\File\RipLog();
if (!$filer->exists([$this->torrentId, $this->logId])) {
return [
'id' => $this->torrentId,
Expand Down
Loading

0 comments on commit 338a1fe

Please sign in to comment.