mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
more type hints
This commit is contained in:
parent
376d7e79ca
commit
4f617d12d4
11 changed files with 700 additions and 546 deletions
|
|
@ -27,5 +27,10 @@
|
|||
"phpunit/phpunit": "^9",
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"phpstan/phpstan": "^0.12.57"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
1118
composer.lock
generated
1118
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -84,7 +84,11 @@ class DemoPlayer implements JsonSerializable {
|
|||
);
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
/**
|
||||
* @return array{'id': int, 'user_id': int, 'name': string, 'team': string, 'class': string, 'steamid': string, 'kills': int, 'assists': int, 'deaths': int}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize():array {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'user_id' => $this->getUserId(),
|
||||
|
|
|
|||
|
|
@ -7,12 +7,9 @@ namespace Demostf\API\Data;
|
|||
use JsonSerializable;
|
||||
|
||||
class SteamUser implements JsonSerializable {
|
||||
/** @var int */
|
||||
private $id;
|
||||
/** @var string */
|
||||
private $steamId;
|
||||
/** @var string */
|
||||
private $name;
|
||||
private int $id;
|
||||
private string $steamId;
|
||||
private string $name;
|
||||
|
||||
public function __construct(int $id, string $steamId, string $name) {
|
||||
$this->id = $id;
|
||||
|
|
@ -31,7 +28,10 @@ class SteamUser implements JsonSerializable {
|
|||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{'id': int, 'name': string, 'steamid': string}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
|
|
|
|||
|
|
@ -34,7 +34,10 @@ class User implements JsonSerializable {
|
|||
public function getToken(): string {
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{'id': int, 'name': string, 'steamid': string}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
|
|
|
|||
|
|
@ -7,14 +7,9 @@ namespace Demostf\API\Demo;
|
|||
use JsonSerializable;
|
||||
|
||||
class ChatMessage implements JsonSerializable {
|
||||
/** @var string */
|
||||
private $user;
|
||||
|
||||
/** @var int */
|
||||
private $time;
|
||||
|
||||
/** @var string */
|
||||
private $message;
|
||||
private string $user;
|
||||
private int $time;
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* ChatMessage constructor.
|
||||
|
|
@ -37,6 +32,10 @@ class ChatMessage implements JsonSerializable {
|
|||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{'user': string, 'time': int, 'message': string}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'user' => $this->user,
|
||||
|
|
|
|||
|
|
@ -188,6 +188,16 @@ class Demo implements JsonSerializable {
|
|||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* 'id': int, 'url': string, 'name': string,
|
||||
* 'server': string, 'duration': float, 'nick': string,
|
||||
* 'map': string, 'time': int, 'red': string, 'blue': string,
|
||||
* 'redScore': int, 'blueScore': int, 'playerCount': int,
|
||||
* 'uploader': array, 'hash': string, 'backend': string, 'path': string
|
||||
* }
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
$data = [
|
||||
'id' => $this->getId(),
|
||||
|
|
|
|||
|
|
@ -7,10 +7,8 @@ namespace Demostf\API\Demo;
|
|||
use Demostf\API\Data\StoredDemo;
|
||||
|
||||
class DemoStore {
|
||||
/** @var string */
|
||||
private $root;
|
||||
/** @var string */
|
||||
private $webRoot;
|
||||
private string $root;
|
||||
private string $webRoot;
|
||||
|
||||
public function __construct(string $root, string $webRoot) {
|
||||
$this->root = $root;
|
||||
|
|
|
|||
|
|
@ -8,60 +8,17 @@ namespace Demostf\API\Demo;
|
|||
* HL2 demo metadata.
|
||||
*/
|
||||
class Header {
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $protocol;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $nick;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $map;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $game;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
protected $duration;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $ticks;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $frames;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $sigon;
|
||||
protected string $type;
|
||||
protected int $version;
|
||||
protected int $protocol;
|
||||
protected string $server;
|
||||
protected string $nick;
|
||||
protected string $map;
|
||||
protected string $game;
|
||||
protected float $duration;
|
||||
protected int $ticks;
|
||||
protected int $frames;
|
||||
protected int $sigon;
|
||||
|
||||
public function __construct(
|
||||
string $type,
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ class Parser {
|
|||
9 => 'engineer',
|
||||
];
|
||||
|
||||
/** @var RawParser */
|
||||
private $rawParser;
|
||||
private RawParser $rawParser;
|
||||
|
||||
public function __construct(RawParser $rawParser) {
|
||||
$this->rawParser = $rawParser;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,7 @@ use GuzzleHttp\Exception\RequestException;
|
|||
* Doesn't do any post-processing on the result
|
||||
*/
|
||||
class RawParser {
|
||||
/** @var string */
|
||||
private $parserPath;
|
||||
private string $parserPath;
|
||||
|
||||
public function __construct(string $parserPath) {
|
||||
$this->parserPath = $parserPath;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue