mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
always set players
This commit is contained in:
parent
47d7d24f30
commit
9c61c483fb
2 changed files with 6 additions and 5 deletions
|
|
@ -26,7 +26,7 @@ class Demo implements JsonSerializable {
|
|||
private int $uploader;
|
||||
private ?User $uploaderUser;
|
||||
/** @var DemoPlayer[] */
|
||||
private array $players;
|
||||
private ?array $players;
|
||||
private string $hash;
|
||||
private string $backend;
|
||||
private string $path;
|
||||
|
|
@ -67,7 +67,7 @@ class Demo implements JsonSerializable {
|
|||
$this->hash = $hash;
|
||||
$this->backend = $backend;
|
||||
$this->path = $path;
|
||||
$this->players = [];
|
||||
$this->players = null;
|
||||
$this->uploaderUser = null;
|
||||
}
|
||||
|
||||
|
|
@ -163,9 +163,9 @@ class Demo implements JsonSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return DemoPlayer[]
|
||||
* @return DemoPlayer[]|null
|
||||
*/
|
||||
public function getPlayers(): array {
|
||||
public function getPlayers(): ?array {
|
||||
return $this->players;
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ class Demo implements JsonSerializable {
|
|||
'backend' => $this->getBackend(),
|
||||
'path' => $this->getPath(),
|
||||
];
|
||||
if ($this->players) {
|
||||
if (is_array($this->players)) {
|
||||
$data['players'] = $this->getPlayers();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class DemoProviderTest extends TestCase {
|
|||
|
||||
$storedData = $demo->jsonSerialize();
|
||||
$storedData['id'] = $id;
|
||||
$storedData['players'] = [];
|
||||
|
||||
$this->assertEquals($storedData, $retrieved->jsonSerialize());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue