add some phpstan array types

This commit is contained in:
Dylan K. Taylor
2020-01-30 22:06:21 +00:00
parent 4ff4434a22
commit 260ac47588
39 changed files with 177 additions and 27 deletions

View File

@ -163,7 +163,10 @@ class AddActorPacket extends DataPacket{
/** @var Attribute[] */
public $attributes = [];
/** @var mixed[][] */
/**
* @var mixed[][]
* @phpstan-var array<int, array{0: int, 1: mixed}>
*/
public $metadata = [];
/** @var EntityLink[] */
public $links = [];

View File

@ -42,7 +42,10 @@ class AddItemActorPacket extends DataPacket{
public $position;
/** @var Vector3|null */
public $motion;
/** @var mixed[][] */
/**
* @var mixed[][]
* @phpstan-var array<int, array{0: int, 1: mixed}>
*/
public $metadata = [];
/** @var bool */
public $isFromFishing = false;

View File

@ -57,7 +57,10 @@ class AddPlayerPacket extends DataPacket{
public $headYaw = null; //TODO
/** @var Item */
public $item;
/** @var mixed[][] */
/**
* @var mixed[][]
* @phpstan-var array<int, array{0: int, 1: mixed}>
*/
public $metadata = [];
//TODO: adventure settings stuff

View File

@ -362,6 +362,7 @@ class AvailableCommandsPacket extends DataPacket{
/**
* @param string[] $postfixes
* @phpstan-param array<int, string> $postfixes
*/
private function argTypeToString(int $argtype, array $postfixes) : string{
if($argtype & self::ARG_FLAG_VALID){

View File

@ -30,7 +30,10 @@ use pocketmine\network\mcpe\NetworkSession;
class GameRulesChangedPacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::GAME_RULES_CHANGED_PACKET;
/** @var mixed[][] */
/**
* @var mixed[][]
* @phpstan-var array<string, array{0: int, 1: bool|int|float}>
*/
public $gameRules = [];
protected function decodePayload(){

View File

@ -54,11 +54,17 @@ class LoginPacket extends DataPacket{
/** @var string */
public $locale;
/** @var string[][] (the "chain" index contains one or more JWTs) */
/**
* @var string[][] (the "chain" index contains one or more JWTs)
* @phpstan-var array{chain?: list<string>}
*/
public $chainData = [];
/** @var string */
public $clientDataJwt;
/** @var mixed[] decoded payload of the clientData JWT */
/**
* @var mixed[] decoded payload of the clientData JWT
* @phpstan-var array<string, mixed>
*/
public $clientData = [];
/**

View File

@ -32,7 +32,10 @@ class SetActorDataPacket extends DataPacket{
/** @var int */
public $entityRuntimeId;
/** @var mixed[][] */
/**
* @var mixed[][]
* @phpstan-var array<int, array{0: int, 1: mixed}>
*/
public $metadata;
protected function decodePayload(){

View File

@ -102,7 +102,10 @@ class StartGamePacket extends DataPacket{
public $commandsEnabled;
/** @var bool */
public $isTexturePacksRequired = true;
/** @var mixed[][] */
/**
* @var mixed[][]
* @phpstan-var array<string, array{0: int, 1: bool|int|float}>
*/
public $gameRules = [ //TODO: implement this
"naturalregeneration" => [1, false] //Hack for client side regeneration
];
@ -152,7 +155,10 @@ class StartGamePacket extends DataPacket{
/** @var ListTag|null */
public $blockTable = null;
/** @var int[]|null string (name) => int16 (legacyID) */
/**
* @var int[]|null string (name) => int16 (legacyID)
* @phpstan-var array<string, int>|null
*/
public $itemTable = null;
protected function decodePayload(){
@ -301,6 +307,7 @@ class StartGamePacket extends DataPacket{
/**
* @param int[] $table
* @phpstan-param array<string, int> $table
*/
private static function serializeItemTable(array $table) : string{
$stream = new NetworkBinaryStream();