diff --git a/gatherling/Models/Matchup.php b/gatherling/Models/Matchup.php
index 8a7b2a21d..63a937be1 100644
--- a/gatherling/Models/Matchup.php
+++ b/gatherling/Models/Matchup.php
@@ -388,7 +388,7 @@ public function updateScores(string $structure): void
$playera_standing->score += 3;
} elseif ($structure == 'League' || $structure == 'League Match') {
$playera_standing->score += 3;
- $playerb_standing->score += (int) $seasonRules['loss_pts'];
+ $playerb_standing->score += $seasonRules['loss_pts'];
}
$this->result = 'A';
} else {
@@ -398,7 +398,7 @@ public function updateScores(string $structure): void
$playerb_standing->score += 3;
} elseif ($structure == 'League' || $structure == 'League Match') {
$playerb_standing->score += 3;
- $playera_standing->score += (int) $seasonRules['loss_pts'];
+ $playera_standing->score += $seasonRules['loss_pts'];
}
$this->result = 'B';
}
@@ -462,7 +462,7 @@ public function fixScores(string $structure): void
$playera_standing->score += 3;
$playera_standing->matches_won += 1;
if ($structure == 'League' || $structure == 'League Match') {
- $playerb_standing->score += (int) $seasonRules['loss_pts'];
+ $playerb_standing->score += $seasonRules['loss_pts'];
}
if ($structure == 'Single Elimination') {
$playerb_standing->active = 0;
@@ -472,7 +472,7 @@ public function fixScores(string $structure): void
$playerb_standing->score += 3;
$playerb_standing->matches_won += 1;
if ($structure == 'League' || $structure == 'League Match') {
- $playera_standing->score += (int) $seasonRules['loss_pts'];
+ $playera_standing->score += $seasonRules['loss_pts'];
}
if ($structure == 'Single Elimination') {
$playera_standing->active = 0;
diff --git a/gatherling/Models/Standings.php b/gatherling/Models/Standings.php
index 4458c8a0c..5d9798fdc 100644
--- a/gatherling/Models/Standings.php
+++ b/gatherling/Models/Standings.php
@@ -10,27 +10,29 @@
class Standings
{
+ public int $id;
public ?string $event = null; // belongs_to event
public ?string $player = null; // belongs_to player
- public int $active;
- public int $score;
- public int $matches_played;
- public int $matches_won;
- public int $draws;
- public int $games_won;
- public int $games_played;
- public int $byes;
- public float $OP_Match;
- public float $PL_Game;
- public float $OP_Game;
- public int $seed;
- public int $matched;
+ public ?int $active = null;
+ public ?int $score;
+ public ?int $matches_played;
+ public ?int $matches_won;
+ public ?int $draws;
+ public ?int $games_won;
+ public ?int $games_played;
+ public ?int $byes;
+ public ?float $OP_Match;
+ public ?float $PL_Game;
+ public ?float $OP_Game;
+ public ?int $seed;
+ public ?int $matched;
public ?bool $new = null;
public function __construct(string $eventname, string $playername, int $initial_seed = 127)
{
// Check to see if we are doing event standings of player standings
if ($playername == '0') {
+ $this->id = 0;
$this->new = true;
return;
@@ -50,19 +52,9 @@ public function __construct(string $eventname, string $playername, int $initial_
$this->seed = $initial_seed;
return;
}
- $this->active = $standings->active;
- $this->matches_played = $standings->matches_played;
- $this->games_won = $standings->games_won;
- $this->games_played = $standings->games_played;
- $this->byes = $standings->byes;
- $this->OP_Match = $standings->OP_Match;
- $this->PL_Game = $standings->PL_Game;
- $this->OP_Game = $standings->OP_Game;
- $this->score = $standings->score;
- $this->seed = $standings->seed;
- $this->matched = $standings->matched;
- $this->matches_won = $standings->matches_won;
- $this->draws = $standings->draws;
+ foreach (get_object_vars($standings) as $key => $value) {
+ $this->$key = $value;
+ }
}
}
@@ -87,10 +79,13 @@ public function save(): void
$this->draws = 0;
$sql = '
- INSERT INTO standings (player, event, active, matches_played, draws, games_won, games_played,
- matches_won, byes, OP_Match, PL_Game, OP_Game, score, seed, matched)
- VALUES (:player, :event, :active, :matches_played, :draws, :games_won, :games_played,
- :matches_won, :byes, :OP_Match, :PL_Game, :OP_Game, :score, :seed, :matched)';
+ INSERT INTO
+ standings
+ (player, event, active, matches_played, draws, games_won, games_played, matches_won, byes, OP_Match, PL_Game,
+ OP_Game, score, seed, matched)
+ VALUES
+ (:player, :event, :active, :matches_played, :draws, :games_won, :games_played, :matches_won, :byes, :OP_Match, :PL_Game,
+ :OP_Game, :score, :seed, :matched)';
$params = [
'player' => $this->player,
'event' => $this->event,
@@ -111,12 +106,15 @@ public function save(): void
db()->execute($sql, $params);
} else {
$sql = '
- UPDATE standings
- SET player = :player, event = :event, active = :active, matches_played = :matches_played,
- games_won = :games_won, games_played = :games_played, byes = :byes, OP_Match = :OP_Match,
- PL_Game = :PL_Game, OP_Game = :OP_Game, score = :score, seed = :seed, matched = :matched,
- matches_won = :matches_won, draws = :draws
- WHERE player = :player AND event = :event';
+ UPDATE
+ standings
+ SET
+ player = :player, event = :event, active = :active, matches_played = :matches_played,
+ games_won = :games_won, games_played = :games_played, byes = :byes, OP_Match = :OP_Match,
+ PL_Game = :PL_Game, OP_Game = :OP_Game, score = :score, seed = :seed, matched = :matched,
+ matches_won = :matches_won, draws = :draws
+ WHERE
+ player = :player AND event = :event';
$params = [
'player' => $this->player,
'event' => $this->event,
diff --git a/gatherling/Models/StandingsDto.php b/gatherling/Models/StandingsDto.php
index d49b583ad..246ec1eac 100644
--- a/gatherling/Models/StandingsDto.php
+++ b/gatherling/Models/StandingsDto.php
@@ -6,15 +6,15 @@
class StandingsDto extends Dto
{
- public int $active;
- public int $matches_played;
- public int $games_won;
- public int $games_played;
- public int $byes;
- public float $OP_Match;
- public float $PL_Game;
- public float $OP_Game;
- public int $score;
+ public ?int $active;
+ public ?int $matches_played;
+ public ?int $games_won;
+ public ?int $games_played;
+ public ?int $byes;
+ public ?float $OP_Match;
+ public ?float $PL_Game;
+ public ?float $OP_Game;
+ public ?int $score;
public int $seed;
public int $matched;
public int $matches_won;
diff --git a/gatherling/Views/Components/EventStandings.php b/gatherling/Views/Components/EventStandings.php
index 29466a730..3add8ecfd 100644
--- a/gatherling/Views/Components/EventStandings.php
+++ b/gatherling/Views/Components/EventStandings.php
@@ -15,9 +15,9 @@ class EventStandings extends Component
rank: int,
gameName: GameName,
matchScore: int,
- opMatch: string,
- plGame: string,
- opGame: string,
+ opMatch: ?string,
+ plGame: ?string,
+ opGame: ?string,
matchesPlayed: int,
byes: int,
}> */
@@ -37,12 +37,12 @@ public function __construct(
'shouldHighlight' => $standing->player == $playerName,
'rank' => $rank,
'gameName' => new GameName($sp, $event->client),
- 'matchScore' => $standing->score,
- 'opMatch' => number_format($standing->OP_Match, 3),
- 'plGame' => number_format($standing->PL_Game, 3),
- 'opGame' => number_format($standing->OP_Game, 3),
- 'matchesPlayed' => $standing->matches_played,
- 'byes' => $standing->byes,
+ 'matchScore' => $standing->score ?? 0,
+ 'opMatch' => $standing->OP_Match !== null ? number_format($standing->OP_Match, 3) : null,
+ 'plGame' => $standing->PL_Game !== null ? number_format($standing->PL_Game, 3) : null,
+ 'opGame' => $standing->OP_Game !== null ? number_format($standing->OP_Game, 3) : null,
+ 'matchesPlayed' => $standing->matches_played ?? 0,
+ 'byes' => $standing->byes ?? 0,
];
$rank++;
$standingInfoList[] = $standingInfo;
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 376a51377..2b62a3d8a 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -400,6 +400,11 @@ parameters:
count: 2
path: gatherling/Models/Formats.php
+ -
+ message: "#^Binary operation \"\\+\\=\" between int\\|null and int\\|string results in an error\\.$#"
+ count: 4
+ path: gatherling/Models/Matchup.php
+
-
message: "#^Parameter \\#1 \\$event_id of class Gatherling\\\\Models\\\\Entry constructor expects int, int\\|null given\\.$#"
count: 1
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 396027378..48f3662d1 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -872,6 +872,12 @@
+
+
+
+
+
+
event_id]]>
eventname]]>
@@ -890,6 +896,43 @@
subevent]]>
subevent]]>
+
+ draws]]>
+ games_played]]>
+ games_played]]>
+ games_won]]>
+ games_won]]>
+ matches_played]]>
+ matches_played]]>
+ matches_won]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ byes]]>
+ byes]]>
+ draws]]>
+ games_played]]>
+ games_played]]>
+ games_won]]>
+ games_won]]>
+ matches_played]]>
+ matches_played]]>
+ matches_won]]>
+ matches_won]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+ score]]>
+
@@ -1448,7 +1491,37 @@
player]]>
player]]>
player]]>
+
+
+ draws]]>
+ draws]]>
+ games_played]]>
+ games_played]]>
+ games_won]]>
+ games_won]]>
+ matches_played]]>
+ matches_played]]>
+ matches_won]]>
+ matches_won]]>
+ games_played]]>
+ games_won]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+