1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-04 10:24:07 +02:00

type hint all the things

This commit is contained in:
Robin Appelman 2020-11-28 23:37:02 +01:00
commit 3f9e613e77
34 changed files with 287 additions and 309 deletions

View file

@ -7,26 +7,16 @@ namespace Demostf\API\Data;
use JsonSerializable;
class DemoPlayer implements JsonSerializable {
/** @var int */
private $id;
/** @var int */
private $userId;
/** @var string */
private $name;
/** @var string */
private $team;
/** @var string */
private $class;
/** @var string */
private $steamId;
/** @var string */
private $avatar;
/** @var int */
private $kills;
/** @var int */
private $assists;
/** @var int */
private $deaths;
private int $id;
private int $userId;
private string $name;
private string $team;
private string $class;
private string $steamId;
private string $avatar;
private int $kills;
private int $assists;
private int $deaths;
public function __construct(int $id, int $userId, string $name, string $team, string $class, string $steamId, string $avatar, int $kills, int $assists, int $deaths) {
$this->id = $id;
@ -81,7 +71,12 @@ class DemoPlayer implements JsonSerializable {
return $this->deaths;
}
public static function fromRow($row): self {
/**
* @param mixed[] $row
*
* @return DemoPlayer
*/
public static function fromRow(array $row): self {
return new self(
$row['id'],
$row['user_id'],

View file

@ -5,17 +5,12 @@ declare(strict_types=1);
namespace Demostf\API\Data;
class Kill {
private $id;
private $demoId;
private $attackerId;
private $assisterId;
private $victimId;
private $weapon;
private int $id;
private int $demoId;
private int $attackerId;
private int $assisterId;
private int $victimId;
private string $weapon;
public function __construct(int $id, int $demoId, int $attackerId, int $assisterId, int $victimId, string $weapon) {
$this->id = $id;

View file

@ -7,16 +7,14 @@ namespace Demostf\API\Data;
use Demostf\API\Demo\ChatMessage;
class ParsedDemo {
/** @var int */
private $redScore;
/** @var int */
private $blueScore;
private int $redScore;
private int $blueScore;
/** @var ChatMessage[] */
private $chat;
private array $chat;
/** @var ParsedPlayer[] */
private $players;
private array $players;
/** @var ParsedKill[] */
private $kills;
private array $kills;
/**
* ParsedDemo constructor.

View file

@ -5,13 +5,10 @@ declare(strict_types=1);
namespace Demostf\API\Data;
class ParsedKill {
private $attackerDemoId;
private $assisterDemoId;
private $victimDemoId;
private $weapon;
private int $attackerDemoId;
private int $assisterDemoId;
private int $victimDemoId;
private string $weapon;
public function __construct(int $attackerDemoId, int $assisterDemoId, int $victimDemoId, string $weapon) {
$this->attackerDemoId = $attackerDemoId;

View file

@ -5,16 +5,11 @@ declare(strict_types=1);
namespace Demostf\API\Data;
class ParsedPlayer {
/** @var string */
private $name;
/** @var int */
private $demoUserId;
/** @var string */
private $steamId;
/** @var string */
private $team;
/** @var string` */
private $class;
private string $name;
private int $demoUserId;
private string $steamId;
private string $team;
private string $class;
public function __construct(string $name, int $demoUserId, string $steamId, string $team, string $class) {
$this->name = $name;

View file

@ -5,26 +5,13 @@ declare(strict_types=1);
namespace Demostf\API\Data;
class Player {
/** @var int */
private $id;
/** @var int */
private $demoId;
/** @var int */
private $demoUserId;
/** @var int */
private $userId;
/** @var string */
private $name;
/** @var string */
private $team;
/** @var string */
private $class;
private int $id;
private int $demoId;
private int $demoUserId;
private int $userId;
private string $name;
private string $team;
private string $class;
public function __construct(int $id, int $demoId, int $demoUserId, int $userId, string $name, string $team, string $class) {
$this->id = $id;

View file

@ -40,6 +40,11 @@ class SteamUser implements JsonSerializable {
];
}
/**
* @param mixed[] $row
*
* @return SteamUser
*/
public static function fromRow(array $row): self {
return new self(
(int) $row['id'],

View file

@ -5,12 +5,9 @@ declare(strict_types=1);
namespace Demostf\API\Data;
class StoredDemo {
/** @var string */
private $url;
/** @var string */
private $backend;
/** @var string */
private $path;
private string $url;
private string $backend;
private string $path;
public function __construct(string $url, string $backend, string $path) {
$this->url = $url;

View file

@ -5,16 +5,11 @@ declare(strict_types=1);
namespace Demostf\API\Data;
class Upload {
/** @var string */
private $name;
/** @var string */
private $red;
/** @var string */
private $blue;
/** @var int */
private $uploaderId;
/** @var string */
private $hash;
private string $name;
private string $red;
private string $blue;
private int $uploaderId;
private string $hash;
public function __construct(string $name, string $red, string $blue, int $uploaderId, string $hash) {
$this->name = $name;

View file

@ -7,16 +7,11 @@ namespace Demostf\API\Data;
use JsonSerializable;
class User implements JsonSerializable {
/** @var int */
private $id;
/** @var string */
private $steamId;
/** @var string */
private $name;
/** @var string */
private $avatar;
/** @var string */
private $token;
private int $id;
private string $steamId;
private string $name;
private string $avatar;
private string $token;
public function __construct(int $id, string $steamId, string $name, string $avatar, string $token) {
$this->id = $id;
@ -55,6 +50,11 @@ class User implements JsonSerializable {
];
}
/**
* @param mixed[] $row
*
* @return User
*/
public static function fromRow(array $row): self {
return new self(
(int) $row['id'],