Merge commit '260ac47588c76a2e6814cfba46773a990fb8c5da'

# Conflicts:
#	resources/vanilla
#	src/Server.php
#	src/lang/Language.php
#	src/network/mcpe/protocol/AddItemActorPacket.php
#	src/network/mcpe/protocol/AddPlayerPacket.php
#	src/network/mcpe/protocol/SetActorDataPacket.php
#	src/network/mcpe/serializer/NetworkBinaryStream.php
#	src/permission/Permission.php
#	src/pocketmine/block/Leaves.php
#	src/pocketmine/entity/DataPropertyManager.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/item/Banner.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/io/LevelProvider.php
#	src/pocketmine/level/format/io/LevelProviderManager.php
#	src/pocketmine/network/mcpe/protocol/AddActorPacket.php
#	src/pocketmine/network/mcpe/protocol/LoginPacket.php
#	src/pocketmine/tile/Banner.php
#	src/scheduler/BulkCurlTask.php
#	src/updater/AutoUpdater.php
#	src/utils/Config.php
#	src/utils/Utils.php
#	src/world/generator/Flat.php
#	src/world/generator/Generator.php
This commit is contained in:
Dylan K. Taylor 2020-01-31 21:07:34 +00:00
commit cb16f5c142
39 changed files with 164 additions and 25 deletions

View File

@ -45,6 +45,7 @@ function preg_quote_array(array $strings, string $delim = null) : array{
* @param string $stub
* @param int $signatureAlgo
* @param int|null $compression
* @phpstan-param array<string, mixed> $metadata
*
* @return \Generator|string[]
*/

View File

@ -86,7 +86,10 @@ class CrashDump{
private $fp;
/** @var int */
private $time;
/** @var mixed[] */
/**
* @var mixed[]
* @phpstan-var array<string, mixed>
*/
private $data = [];
/** @var string */
private $encodedData = "";
@ -129,6 +132,7 @@ class CrashDump{
/**
* @return mixed[]
* @phpstan-return array<string, mixed>
*/
public function getData() : array{
return $this->data;

View File

@ -267,7 +267,10 @@ class Server{
/** @var string */
private $pluginPath;
/** @var string[] */
/**
* @var string[]
* @phpstan-var array<string, string>
*/
private $uniquePlayers = [];
/** @var QueryRegenerateEvent */
@ -1417,6 +1420,7 @@ class Server{
/**
* @param mixed[][]|null $trace
* @phpstan-param list<array<string, mixed>>|null $trace
*/
public function exceptionHandler(\Throwable $e, $trace = null) : void{
while(@ob_end_flush()){}

View File

@ -112,6 +112,7 @@ abstract class BaseRail extends Flowable{
/**
* @param int[] $connections
* @param int[][] $lookup
* @phpstan-param array<int, list<int>> $lookup
*/
protected static function searchState(array $connections, array $lookup) : int{
$meta = array_search($connections, $lookup, true);
@ -180,6 +181,7 @@ abstract class BaseRail extends Flowable{
* @param int[] $constraints
*
* @return true[]
* @phpstan-return array<int, true>
*/
private function getPossibleConnectionDirections(array $constraints) : array{
switch(count($constraints)){
@ -207,6 +209,7 @@ abstract class BaseRail extends Flowable{
/**
* @return true[]
* @phpstan-return array<int, true>
*/
protected function getPossibleConnectionDirectionsOneConstraint(int $constraint) : array{
$opposite = Facing::opposite($constraint & ~self::FLAG_ASCEND);

View File

@ -69,6 +69,7 @@ class Leaves extends Transparent{
/**
* @param true[] $visited reference parameter
* @phpstan-param array<string, true> $visited
*/
protected function findLog(Vector3 $pos, array &$visited = [], int $distance = 0) : bool{
$index = World::blockHash($pos->x, $pos->y, $pos->z);

View File

@ -129,6 +129,7 @@ class TimingsCommand extends VanillaCommand{
/**
* @param string[] $data
* @phpstan-param array<string, string> $data
*/
public function __construct(CommandSender $sender, string $host, string $agent, array $data){
parent::__construct([

View File

@ -1636,6 +1636,7 @@ abstract class Entity{
/**
* @param Player[]|Player $player
* @param MetadataProperty[] $data Properly formatted entity data, defaults to everything
* @phpstan-param array<int, MetadataProperty> $data
*/
public function sendData($player, ?array $data = null) : void{
if(!is_array($player)){

View File

@ -65,9 +65,15 @@ final class EntityFactory{
private static $entityCount = 1;
/** @var string[] base class => currently used class for construction */
private static $classMapping = [];
/** @var string[] */
/**
* @var string[]
* @phpstan-var array<int|string, class-string<Entity>>
*/
private static $knownEntities = [];
/** @var string[][] */
/**
* @var string[][]
* @phpstan-var array<class-string<Entity>, list<string>>
*/
private static $saveNames = [];
private function __construct(){

View File

@ -632,6 +632,7 @@ abstract class Living extends Entity{
/**
* @param true[] $transparent
* @phpstan-param array<int, true> $transparent
*
* @return Block[]
*/
@ -674,6 +675,7 @@ abstract class Living extends Entity{
/**
* @param true[] $transparent
* @phpstan-param array<int, true> $transparent
*/
public function getTargetBlock(int $maxDistance, array $transparent = []) : ?Block{
$line = $this->getLineOfSight($maxDistance, 1, $transparent);

View File

@ -63,7 +63,10 @@ class QueryRegenerateEvent extends ServerEvent{
/** @var string */
private $ip;
/** @var string[] */
/**
* @var string[]
* @phpstan-var array<string, string>
*/
private $extraData = [];
/** @var string|null */
@ -174,6 +177,7 @@ class QueryRegenerateEvent extends ServerEvent{
* Returns the extra Query data in key => value form
*
* @return string[]
* @phpstan-return array<string, string>
*/
public function getExtraData() : array{
return $this->extraData;
@ -181,6 +185,7 @@ class QueryRegenerateEvent extends ServerEvent{
/**
* @param string[] $extraData
* @phpstan-param array<string, string> $extraData
*/
public function setExtraData(array $extraData) : void{
$this->extraData = $extraData;

View File

@ -575,6 +575,7 @@ class Item implements \JsonSerializable{
* Returns an array of item stack properties that can be serialized to json.
*
* @return mixed[]
* @phpstan-return array{id: int, damage?: int, count?: int, nbt_b64?: string}
*/
final public function jsonSerialize() : array{
$data = [
@ -599,6 +600,14 @@ class Item implements \JsonSerializable{
/**
* Returns an Item from properties created in an array by {@link Item#jsonSerialize}
* @param mixed[] $data
* @phpstan-param array{
* id: int,
* damage?: int,
* count?: int,
* nbt?: string,
* nbt_hex?: string,
* nbt_b64?: string
* } $data
*
* @throws NbtDataException
* @throws \InvalidArgumentException

View File

@ -45,6 +45,7 @@ class Language{
/**
* @return string[]
* @phpstan-return array<string, string>
*
* @throws LanguageNotFoundException
*/

View File

@ -165,7 +165,10 @@ class AddActorPacket extends DataPacket implements ClientboundPacket{
/** @var Attribute[] */
public $attributes = [];
/** @var MetadataProperty[] */
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
public $metadata = [];
/** @var EntityLink[] */
public $links = [];

View File

@ -43,7 +43,10 @@ class AddItemActorPacket extends DataPacket implements ClientboundPacket{
public $position;
/** @var Vector3|null */
public $motion;
/** @var MetadataProperty[] */
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
public $metadata = [];
/** @var bool */
public $isFromFishing = false;

View File

@ -58,7 +58,10 @@ class AddPlayerPacket extends DataPacket implements ClientboundPacket{
public $headYaw = null; //TODO
/** @var Item */
public $item;
/** @var MetadataProperty[] */
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
public $metadata = [];
//TODO: adventure settings stuff

View File

@ -371,6 +371,7 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
/**
* @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\handler\PacketHandler;
class GameRulesChangedPacket extends DataPacket implements ClientboundPacket{
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() : void{

View File

@ -87,7 +87,10 @@ class LoginPacket extends DataPacket implements ServerboundPacket{
public $extraData = null;
/** @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

@ -33,7 +33,10 @@ class SetActorDataPacket extends DataPacket implements ClientboundPacket, Server
/** @var int */
public $entityRuntimeId;
/** @var MetadataProperty[] */
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
public $metadata;
public static function create(int $entityRuntimeId, array $metadata) : self{

View File

@ -103,7 +103,10 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
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
];
@ -153,7 +156,10 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
/** @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() : void{
@ -302,6 +308,7 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
/**
* @param int[] $table
* @phpstan-param array<string, int> $table
*/
private static function serializeItemTable(array $table) : string{
$stream = new NetworkBinaryStream();

View File

@ -29,9 +29,15 @@ use function get_class;
class EntityMetadataCollection{
/** @var MetadataProperty[] */
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
private $properties = [];
/** @var MetadataProperty[] */
/**
* @var MetadataProperty[]
* @phpstan-var array<int, MetadataProperty>
*/
private $dirtyProperties = [];
public function __construct(){
@ -121,6 +127,7 @@ class EntityMetadataCollection{
* Returns all properties.
*
* @return MetadataProperty[]
* @phpstan-return array<int, MetadataProperty>
*/
public function getAll() : array{
return $this->properties;
@ -130,6 +137,7 @@ class EntityMetadataCollection{
* Returns properties that have changed and need to be broadcasted.
*
* @return MetadataProperty[]
* @phpstan-return array<int, MetadataProperty>
*/
public function getDirty() : array{
return $this->dirtyProperties;

View File

@ -297,6 +297,7 @@ class NetworkBinaryStream extends BinaryStream{
* Decodes entity metadata from the stream.
*
* @return MetadataProperty[]
* @phpstan-return array<int, MetadataProperty>
*
* @throws BadPacketException
* @throws BinaryDataException
@ -334,6 +335,7 @@ class NetworkBinaryStream extends BinaryStream{
* Writes entity metadata to the packet buffer.
*
* @param MetadataProperty[] $metadata
* @phpstan-param array<int, MetadataProperty> $metadata
*/
public function putEntityMetadata(array $metadata) : void{
$this->putUnsignedVarInt(count($metadata));
@ -530,6 +532,7 @@ class NetworkBinaryStream extends BinaryStream{
* TODO: implement this properly
*
* @return mixed[][], members are in the structure [name => [type, value]]
* @phpstan-return array<string, array{0: int, 1: bool|int|float}>
*
* @throws BadPacketException
* @throws BinaryDataException
@ -566,6 +569,7 @@ class NetworkBinaryStream extends BinaryStream{
* TODO: implement this properly
*
* @param mixed[][] $rules
* @phpstan-param array<string, array{0: int, 1: bool|int|float}> $rules
*/
public function putGameRules(array $rules) : void{
$this->putUnsignedVarInt(count($rules));

View File

@ -45,7 +45,10 @@ class Permission{
/** @var string */
private $description;
/** @var bool[] */
/**
* @var bool[]
* @phpstan-var array<string, bool>
*/
private $children;
/** @var string */
@ -55,6 +58,7 @@ class Permission{
* Creates a new Permission object to be attached to Permissible objects
*
* @param bool[] $children
* @phpstan-param array<string, bool> $children
*/
public function __construct(string $name, ?string $description = null, ?string $defaultValue = null, array $children = []){
$this->name = $name;
@ -71,6 +75,7 @@ class Permission{
/**
* @return bool[]
* @phpstan-return array<string, bool>
*/
public function &getChildren() : array{
return $this->children;

View File

@ -71,6 +71,7 @@ class PermissionParser{
/**
* @param mixed[][] $data
* @phpstan-param array<string, array<string, mixed>> $data
*
* @return Permission[]
*/
@ -86,6 +87,7 @@ class PermissionParser{
/**
* @param mixed[] $data
* @param Permission[] $output reference parameter
* @phpstan-param array<string, mixed> $data
*
* @throws \Exception
*/

View File

@ -39,7 +39,10 @@ use function version_compare;
use function yaml_parse;
class PluginDescription{
/** @var mixed[] */
/**
* @var mixed[]
* @phpstan-var array<string, mixed>
*/
private $map;
/** @var string */
@ -50,7 +53,10 @@ class PluginDescription{
private $api;
/** @var int[] */
private $compatibleMcpeProtocols = [];
/** @var string[][] */
/**
* @var string[][]
* @phpstan-var array<string, list<mixed>>
*/
private $extensions = [];
/** @var string[] */
private $depend = [];
@ -60,7 +66,10 @@ class PluginDescription{
private $loadBefore = [];
/** @var string */
private $version;
/** @var mixed[][] */
/**
* @var mixed[][]
* @phpstan-var array<string, array<string, mixed>>
*/
private $commands = [];
/** @var string */
private $description = "";
@ -78,6 +87,7 @@ class PluginDescription{
/**
* @param string|mixed[] $yamlString
* @phpstan-param string|array<string, mixed> $yamlString
*/
public function __construct($yamlString){
$this->loadMap(!is_array($yamlString) ? yaml_parse($yamlString) : $yamlString);
@ -85,6 +95,7 @@ class PluginDescription{
/**
* @param mixed[] $plugin
* @phpstan-param array<string, mixed> $plugin
* @throws PluginException
*/
private function loadMap(array $plugin) : void{
@ -189,6 +200,7 @@ class PluginDescription{
/**
* @return mixed[][]
* @phpstan-return array<string, array<string, mixed>>
*/
public function getCommands() : array{
return $this->commands;
@ -196,6 +208,7 @@ class PluginDescription{
/**
* @return string[][]
* @phpstan-return array<string, list<string>>
*/
public function getRequiredExtensions() : array{
return $this->extensions;
@ -289,6 +302,7 @@ class PluginDescription{
/**
* @return mixed[]
* @phpstan-return array<string, mixed>
*/
public function getMap() : array{
return $this->map;

View File

@ -45,12 +45,14 @@ class BulkCurlTask extends AsyncTask{
* {@link Utils::simpleCurl}.
*
* @param mixed[][] $operations
* @phpstan-param list<array{page: string, timeout?: float, extraHeaders?: list<string>, extraOpts?: array<int, mixed>}> $operations
*/
public function __construct(array $operations){
$this->operations = serialize($operations);
}
public function onRun() : void{
/** @phpstan-var list<array{page: string, timeout?: float, extraHeaders?: list<string>, extraOpts?: array<int, mixed>}> $operations */
$operations = unserialize($this->operations);
$results = [];
foreach($operations as $op){

View File

@ -54,6 +54,7 @@ class SendUsageTask extends AsyncTask{
/**
* @param string[] $playerList
* @phpstan-param array<string, string> $playerList
*/
public function __construct(Server $server, int $type, array $playerList = []){
$endpoint = "http://" . $server->getProperty("anonymous-statistics.host", "stats.pocketmine.net") . "/";

View File

@ -41,7 +41,10 @@ class AutoUpdater{
protected $server;
/** @var string */
protected $endpoint;
/** @var mixed[]|null */
/**
* @var mixed[]|null
* @phpstan-var array<string, mixed>|null
*/
protected $updateInfo = null;
/** @var VersionString|null */
protected $newVersion;
@ -67,6 +70,7 @@ class AutoUpdater{
* Callback used at the end of the update checking task
*
* @param mixed[] $updateInfo
* @phpstan-param array<string, mixed> $updateInfo
*/
public function checkUpdateCallback(array $updateInfo) : void{
$this->updateInfo = $updateInfo;
@ -145,6 +149,7 @@ class AutoUpdater{
* Returns the last retrieved update data.
*
* @return mixed[]|null
* @phpstan-return array<string, mixed>|null
*/
public function getUpdateInfo() : ?array{
return $this->updateInfo;

View File

@ -68,10 +68,16 @@ class Config{
public const ENUM = 5; // .txt, .list, .enum
public const ENUMERATION = Config::ENUM;
/** @var mixed[] */
/**
* @var mixed[]
* @phpstan-var array<string, mixed>
*/
private $config = [];
/** @var mixed[] */
/**
* @var mixed[]
* @phpstan-var array<string, mixed>
*/
private $nestedCache = [];
/** @var string */
@ -107,6 +113,7 @@ class Config{
* @param string $file Path of the file to be loaded
* @param int $type Config type to load, -1 by default (detect)
* @param mixed[] $default Array with the default values that will be written to the file if it did not exist
* @phpstan-param array<string, mixed> $default
*/
public function __construct(string $file, int $type = Config::DETECT, array $default = []){
$this->load($file, $type, $default);
@ -135,6 +142,7 @@ class Config{
/**
* @param mixed[] $default
* @phpstan-param array<string, mixed> $default
*
* @throws \InvalidArgumentException if config type could not be auto-detected
* @throws \InvalidStateException if config type is invalid
@ -428,6 +436,7 @@ class Config{
/**
* @param mixed[] $v
* @phpstan-param array<string, mixed> $v
*/
public function setAll(array $v) : void{
$this->config = $v;
@ -458,6 +467,7 @@ class Config{
/**
* @return mixed[]
* @phpstan-return list<string>|array<string, mixed>
*/
public function getAll(bool $keys = false) : array{
return ($keys ? array_keys($this->config) : $this->config);
@ -465,6 +475,7 @@ class Config{
/**
* @param mixed[] $defaults
* @phpstan-param array<string, mixed> $defaults
*/
public function setDefaults(array $defaults) : void{
$this->fillDefaults($defaults, $this->config);
@ -473,6 +484,8 @@ class Config{
/**
* @param mixed[] $default
* @param mixed[] $data reference parameter
* @phpstan-param array<string, mixed> $default
* @phpstan-param array<string, mixed> $data
*/
private function fillDefaults(array $default, &$data) : int{
$changed = 0;

View File

@ -140,6 +140,7 @@ class MainLogger extends \AttachableThreadedLogger{
/**
* @param mixed[][]|null $trace
* @phpstan-param list<array<string, mixed>>|null $trace
*
* @return void
*/

View File

@ -354,6 +354,7 @@ class Utils{
/**
* @return mixed[] array of claims
* @phpstan-return array<string, mixed>
*
* @throws \UnexpectedValueException
*/
@ -392,6 +393,7 @@ class Utils{
/**
* @param mixed[][] $trace
* @phpstan-param list<array<string, mixed>> $trace
*
* @return string[]
*/
@ -426,6 +428,7 @@ class Utils{
/**
* @return mixed[][]
* @phpstan-return list<array<string, mixed>>
*/
public static function currentTrace(int $skipFrames = 0) : array{
++$skipFrames; //omit this frame from trace, in addition to other skipped frames

View File

@ -32,7 +32,10 @@ use function strtolower;
use function trim;
abstract class WorldProviderManager{
/** @var string[] */
/**
* @var string[]
* @phpstan-var array<string, class-string<WorldProvider>>
*/
protected static $providers = [];
/** @var string|WorldProvider */

View File

@ -30,6 +30,7 @@ interface WritableWorldProvider extends WorldProvider{
* Generate the needed files in the path given
*
* @param mixed[] $options
* @phpstan-param array<string, mixed> $options
*/
public static function generate(string $path, string $name, int $seed, string $generator, array $options = []) : void;

View File

@ -41,7 +41,10 @@ class Flat extends Generator{
private $chunk;
/** @var Populator[] */
private $populators = [];
/** @var int[] */
/**
* @var int[]
* @phpstan-var array<int, int>
*/
private $structure;
/** @var int */
private $floorLevel;
@ -52,6 +55,7 @@ class Flat extends Generator{
/**
* @param mixed[] $options
* @phpstan-param array<string, mixed> $options
*
* @throws InvalidGeneratorOptionsException
*/
@ -87,6 +91,8 @@ class Flat extends Generator{
/**
* @return int[]
* @phpstan-return array<int, int>
*
* @throws InvalidGeneratorOptionsException
*/
public static function parseLayers(string $layers) : array{

View File

@ -62,6 +62,7 @@ abstract class Generator{
* @throws InvalidGeneratorOptionsException
*
* @param mixed[] $options
* @phpstan-param array<string, mixed> $options
*/
public function __construct(ChunkManager $world, int $seed, array $options = []){
$this->world = $world;

View File

@ -30,7 +30,10 @@ use function array_keys;
use function strtolower;
final class GeneratorManager{
/** @var string[] name => classname mapping */
/**
* @var string[] name => classname mapping
* @phpstan-var array<string, class-string<Generator>>
*/
private static $list = [];
/**

View File

@ -45,6 +45,7 @@ class GeneratorRegisterTask extends AsyncTask{
/**
* @param mixed[] $generatorSettings
* @phpstan-param array<string, mixed> $generatorSettings
*/
public function __construct(World $world, string $generatorClass, array $generatorSettings = []){
$this->generatorClass = $generatorClass;

View File

@ -52,6 +52,7 @@ class Nether extends Generator{
/**
* @param mixed[] $options
* @phpstan-param array<string, mixed> $options
*
* @throws InvalidGeneratorOptionsException
*/

View File

@ -59,6 +59,7 @@ class Normal extends Generator{
/**
* @param mixed[] $options
* @phpstan-param array<string, mixed> $options
*
* @throws InvalidGeneratorOptionsException
*/