Skip to content

Commit

Permalink
remove old phpcs exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
Spine committed Oct 15, 2023
1 parent da510ae commit 267f2e1
Show file tree
Hide file tree
Showing 320 changed files with 1,081 additions and 1,115 deletions.
21 changes: 3 additions & 18 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

<file>.</file>
<exclude-pattern>cache/*</exclude-pattern>
<exclude-pattern>lib/override.config.php</exclude-pattern>
<exclude-pattern>*/.docker/*</exclude-pattern>
<exclude-pattern>*/.git/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
Expand All @@ -17,46 +16,32 @@
<exclude-pattern>*/vendor/*</exclude-pattern>

<rule ref="PSR12">
<exclude name="Generic.ControlStructures.InlineControlStructure" />
<exclude name="Generic.Files.LineLength" />
<exclude name="Generic.Formatting.DisallowMultipleStatements" />
<exclude name="Generic.Functions.FunctionCallArgumentSpacing" />
<exclude name="Generic.NamingConventions.UpperCaseConstantName" />
<exclude name="Generic.PHP.LowerCaseConstant" />
<exclude name="Generic.PHP.LowerCaseKeyword" />
<exclude name="Generic.PHP.LowerCaseType" />
<exclude name="Generic.WhiteSpace.ScopeIndent" />

<exclude name="PEAR.Functions.ValidDefaultValue" />
<exclude name="PSR1.Classes.ClassDeclaration" />
<exclude name="PSR1.Files.SideEffects" />
<exclude name="PSR1.Methods.CamelCapsMethodName" />

<exclude name="PSR2.Classes.ClassDeclaration" />
<exclude name="PSR2.Classes.PropertyDeclaration" />
<exclude name="PSR2.ControlStructures.ElseIfDeclaration" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration" />
<exclude name="PSR2.Files.ClosingTag" />
<exclude name="PSR2.Files.EndFileNewline" />
<exclude name="PSR2.Methods.FunctionCallSignature" />
<exclude name="PSR2.Methods.FunctionClosingBrace" />
<exclude name="PSR2.Methods.MethodDeclaration" />

<exclude name="PSR12.Classes.ClassInstantiation" />
<exclude name="PSR12.Classes.ClosingBrace" />
<exclude name="PSR12.ControlStructures.ControlStructureSpacing" />
<exclude name="PSR12.Files.FileHeader" />
<exclude name="PSR12.Files.ImportStatement" />
<exclude name="PSR12.Operators.OperatorSpacing" />
<exclude name="PSR12.Properties.ConstantVisibility" />
<exclude name="PSR12.Traits.UseDeclaration" />

<exclude name="Squiz.Classes.ValidClassName" />
<exclude name="Squiz.ControlStructures.ControlSignature" />
<exclude name="Squiz.ControlStructures.ForEachLoopDeclaration" />
<exclude name="Squiz.Functions.FunctionDeclaration" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration" />
<exclude name="Squiz.Scope.MethodScope" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace" />
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing" />
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace" />
</rule>
Expand Down
2 changes: 1 addition & 1 deletion app/API/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions app/Artist/Similar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions app/ArtistRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,28 @@ protected function renderRole(int $mode): string {
return $link = '';
}

$and = match($mode) {
$and = match ($mode) {
self::RENDER_HTML => ' &amp; ',
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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down
1 change: 0 additions & 1 deletion app/Better/ArtistCollage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Gazelle\Better;

class ArtistCollage extends AbstractBetter {

public function mode(): string {
return 'artist';
}
Expand Down
1 change: 0 additions & 1 deletion app/Better/ArtistDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Gazelle\Better;

class ArtistDescription extends AbstractBetter {

public function mode(): string {
return 'artist';
}
Expand Down
1 change: 0 additions & 1 deletion app/Better/ArtistDiscogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Gazelle\Better;

class ArtistDiscogs extends AbstractBetter {

public function mode(): string {
return 'artist';
}
Expand Down
1 change: 0 additions & 1 deletion app/Better/ArtistImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Gazelle\Better;

class ArtistImage extends AbstractBetter {

public function mode(): string {
return 'artist';
}
Expand Down
1 change: 0 additions & 1 deletion app/Better/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Gazelle\Better;

class Artwork extends AbstractBetter {

public function mode(): string {
return 'group';
}
Expand Down
4 changes: 2 additions & 2 deletions app/Better/Bad.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/BonusPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {}

Expand Down
6 changes: 3 additions & 3 deletions app/Collage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion app/Collector/Artist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions app/Contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/Contest/AbstractContest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 4 additions & 6 deletions app/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)"];
}
Expand Down Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit 267f2e1

Please sign in to comment.