From ccbcc14600e5683d61d3229f033d91f61f1ff710 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:02:03 +0000 Subject: [PATCH 01/28] Block: populate missing return type info --- src/pocketmine/block/Bed.php | 5 +++++ src/pocketmine/block/Liquid.php | 3 +++ src/pocketmine/block/TNT.php | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index 626d7a63a..1b98226da 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -76,6 +76,11 @@ class Bed extends Transparent{ return ($this->meta & self::BITFLAG_OCCUPIED) !== 0; } + /** + * @param bool $occupied + * + * @return void + */ public function setOccupied(bool $occupied = true){ if($occupied){ $this->meta |= self::BITFLAG_OCCUPIED; diff --git a/src/pocketmine/block/Liquid.php b/src/pocketmine/block/Liquid.php index b2f26f727..d5fdec753 100644 --- a/src/pocketmine/block/Liquid.php +++ b/src/pocketmine/block/Liquid.php @@ -434,6 +434,9 @@ abstract class Liquid extends Transparent{ return ($decay >= 0 && $blockDecay >= $decay) ? $decay : $blockDecay; } + /** + * @return void + */ protected function checkForHarden(){ } diff --git a/src/pocketmine/block/TNT.php b/src/pocketmine/block/TNT.php index 5ca3f9d0e..9dee707a5 100644 --- a/src/pocketmine/block/TNT.php +++ b/src/pocketmine/block/TNT.php @@ -74,6 +74,11 @@ class TNT extends Solid{ } } + /** + * @param int $fuse + * + * @return void + */ public function ignite(int $fuse = 80){ $this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR), true); From e328d00cca7e3f97e42ca72f1bbfb4a1d6ecc86a Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:02:55 +0000 Subject: [PATCH 02/28] command: populate missing return type info --- src/pocketmine/command/Command.php | 12 ++++++++++++ src/pocketmine/command/CommandMap.php | 2 ++ src/pocketmine/command/CommandReader.php | 8 +++++++- src/pocketmine/command/CommandSender.php | 4 ++++ src/pocketmine/command/ConsoleCommandSender.php | 4 ++++ src/pocketmine/command/PluginCommand.php | 2 ++ .../command/RemoteConsoleCommandSender.php | 3 +++ src/pocketmine/command/SimpleCommandMap.php | 2 +- src/pocketmine/command/defaults/BanIpCommand.php | 2 +- src/pocketmine/command/defaults/VersionCommand.php | 2 +- 10 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 33b8a645b..048e80a03 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -114,6 +114,8 @@ abstract class Command{ /** * @param string|null $permission + * + * @return void */ public function setPermission(string $permission = null){ $this->permission = $permission; @@ -259,6 +261,8 @@ abstract class Command{ /** * @param string[] $aliases + * + * @return void */ public function setAliases(array $aliases){ $this->aliases = $aliases; @@ -269,6 +273,8 @@ abstract class Command{ /** * @param string $description + * + * @return void */ public function setDescription(string $description){ $this->description = $description; @@ -276,6 +282,8 @@ abstract class Command{ /** * @param string $permissionMessage + * + * @return void */ public function setPermissionMessage(string $permissionMessage){ $this->permissionMessage = $permissionMessage; @@ -283,6 +291,8 @@ abstract class Command{ /** * @param string $usage + * + * @return void */ public function setUsage(string $usage){ $this->usageMessage = $usage; @@ -292,6 +302,8 @@ abstract class Command{ * @param CommandSender $source * @param TextContainer|string $message * @param bool $sendToSource + * + * @return void */ public static function broadcastCommandMessage(CommandSender $source, $message, bool $sendToSource = true){ if($message instanceof TextContainer){ diff --git a/src/pocketmine/command/CommandMap.php b/src/pocketmine/command/CommandMap.php index 837d6e2bd..a0efb5fa3 100644 --- a/src/pocketmine/command/CommandMap.php +++ b/src/pocketmine/command/CommandMap.php @@ -29,6 +29,8 @@ interface CommandMap{ /** * @param string $fallbackPrefix * @param Command[] $commands + * + * @return void */ public function registerAll(string $fallbackPrefix, array $commands); diff --git a/src/pocketmine/command/CommandReader.php b/src/pocketmine/command/CommandReader.php index a313ade4f..e3829ab09 100644 --- a/src/pocketmine/command/CommandReader.php +++ b/src/pocketmine/command/CommandReader.php @@ -73,6 +73,9 @@ class CommandReader extends Thread{ } } + /** + * @return void + */ public function shutdown(){ $this->shutdown = true; } @@ -96,7 +99,7 @@ class CommandReader extends Thread{ throw new \ThreadException($message); } - private function initStdin(){ + private function initStdin() : void{ if(is_resource(self::$stdin)){ fclose(self::$stdin); } @@ -187,6 +190,9 @@ class CommandReader extends Thread{ return null; } + /** + * @return void + */ public function run(){ $this->registerClassLoader(); diff --git a/src/pocketmine/command/CommandSender.php b/src/pocketmine/command/CommandSender.php index 97fed1b29..17e9c69b5 100644 --- a/src/pocketmine/command/CommandSender.php +++ b/src/pocketmine/command/CommandSender.php @@ -31,6 +31,8 @@ interface CommandSender extends Permissible{ /** * @param TextContainer|string $message + * + * @return void */ public function sendMessage($message); @@ -56,6 +58,8 @@ interface CommandSender extends Permissible{ * Sets the line height used for command output pagination for this command sender. `null` will reset it to default. * * @param int|null $height + * + * @return void */ public function setScreenLineHeight(int $height = null); } diff --git a/src/pocketmine/command/ConsoleCommandSender.php b/src/pocketmine/command/ConsoleCommandSender.php index 090f52c75..5fdc05eee 100644 --- a/src/pocketmine/command/ConsoleCommandSender.php +++ b/src/pocketmine/command/ConsoleCommandSender.php @@ -105,6 +105,8 @@ class ConsoleCommandSender implements CommandSender{ /** * @param TextContainer|string $message + * + * @return void */ public function sendMessage($message){ if($message instanceof TextContainer){ @@ -134,6 +136,8 @@ class ConsoleCommandSender implements CommandSender{ /** * @param bool $value + * + * @return void */ public function setOp(bool $value){ diff --git a/src/pocketmine/command/PluginCommand.php b/src/pocketmine/command/PluginCommand.php index 4c7757b59..6ee4e1926 100644 --- a/src/pocketmine/command/PluginCommand.php +++ b/src/pocketmine/command/PluginCommand.php @@ -70,6 +70,8 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{ /** * @param CommandExecutor $executor + * + * @return void */ public function setExecutor(CommandExecutor $executor){ $this->executor = $executor; diff --git a/src/pocketmine/command/RemoteConsoleCommandSender.php b/src/pocketmine/command/RemoteConsoleCommandSender.php index 054d7ad88..48e33a127 100644 --- a/src/pocketmine/command/RemoteConsoleCommandSender.php +++ b/src/pocketmine/command/RemoteConsoleCommandSender.php @@ -41,6 +41,9 @@ class RemoteConsoleCommandSender extends ConsoleCommandSender{ $this->messages .= trim($message, "\r\n") . "\n"; } + /** + * @return string + */ public function getMessage(){ return $this->messages; } diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index 9f534ff5a..fb3a52a4d 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -92,7 +92,7 @@ class SimpleCommandMap implements CommandMap{ $this->setDefaultCommands(); } - private function setDefaultCommands(){ + private function setDefaultCommands() : void{ $this->registerAll("pocketmine", [ new BanCommand("ban"), new BanIpCommand("ban-ip"), diff --git a/src/pocketmine/command/defaults/BanIpCommand.php b/src/pocketmine/command/defaults/BanIpCommand.php index 38c8d5f45..e60b9b219 100644 --- a/src/pocketmine/command/defaults/BanIpCommand.php +++ b/src/pocketmine/command/defaults/BanIpCommand.php @@ -75,7 +75,7 @@ class BanIpCommand extends VanillaCommand{ return true; } - private function processIPBan(string $ip, CommandSender $sender, string $reason){ + private function processIPBan(string $ip, CommandSender $sender, string $reason) : void{ $sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName()); foreach($sender->getServer()->getOnlinePlayers() as $player){ diff --git a/src/pocketmine/command/defaults/VersionCommand.php b/src/pocketmine/command/defaults/VersionCommand.php index b6140939b..e132671bd 100644 --- a/src/pocketmine/command/defaults/VersionCommand.php +++ b/src/pocketmine/command/defaults/VersionCommand.php @@ -84,7 +84,7 @@ class VersionCommand extends VanillaCommand{ return true; } - private function describeToSender(Plugin $plugin, CommandSender $sender){ + private function describeToSender(Plugin $plugin, CommandSender $sender) : void{ $desc = $plugin->getDescription(); $sender->sendMessage(TextFormat::DARK_GREEN . $desc->getName() . TextFormat::WHITE . " version " . TextFormat::DARK_GREEN . $desc->getVersion()); From 205e47c0c4eb6d0e89eb491d56f9d94ac2afd187 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:03:54 +0000 Subject: [PATCH 03/28] entity: populate missing return type information --- src/pocketmine/entity/Entity.php | 1 + src/pocketmine/entity/Explosive.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index c46fa9e2a..bf2a88de0 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -2285,6 +2285,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{ * @param string $name * @param mixed $value * + * @return void * @throws \ErrorException * @throws \InvalidArgumentException */ diff --git a/src/pocketmine/entity/Explosive.php b/src/pocketmine/entity/Explosive.php index 77099ef58..9f3ba65ae 100644 --- a/src/pocketmine/entity/Explosive.php +++ b/src/pocketmine/entity/Explosive.php @@ -26,5 +26,8 @@ namespace pocketmine\entity; interface Explosive{ + /** + * @return void + */ public function explode(); } From 0db7e57a15bd307e69fe613e22babd486f19238e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:04:25 +0000 Subject: [PATCH 04/28] lang: populate missing return type information --- src/pocketmine/lang/BaseLang.php | 11 +++++++++++ src/pocketmine/lang/TextContainer.php | 2 ++ src/pocketmine/lang/TranslationContainer.php | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/src/pocketmine/lang/BaseLang.php b/src/pocketmine/lang/BaseLang.php index 0ec3a68f2..972aebe14 100644 --- a/src/pocketmine/lang/BaseLang.php +++ b/src/pocketmine/lang/BaseLang.php @@ -105,6 +105,12 @@ class BaseLang{ return $this->langName; } + /** + * @param string $path + * @param string[] $d reference parameter + * + * @return bool + */ protected static function loadLang(string $path, array &$d){ if(file_exists($path)){ $d = array_map('\stripcslashes', parse_ini_file($path, false, INI_SCANNER_RAW)); @@ -132,6 +138,11 @@ class BaseLang{ return $baseText; } + /** + * @param TextContainer $c + * + * @return string + */ public function translate(TextContainer $c){ if($c instanceof TranslationContainer){ $baseText = $this->internalGet($c->getText()); diff --git a/src/pocketmine/lang/TextContainer.php b/src/pocketmine/lang/TextContainer.php index 99504d0ae..7e572b7cc 100644 --- a/src/pocketmine/lang/TextContainer.php +++ b/src/pocketmine/lang/TextContainer.php @@ -37,6 +37,8 @@ class TextContainer{ /** * @param string $text + * + * @return void */ public function setText(string $text){ $this->text = $text; diff --git a/src/pocketmine/lang/TranslationContainer.php b/src/pocketmine/lang/TranslationContainer.php index 69461b281..93e43eea7 100644 --- a/src/pocketmine/lang/TranslationContainer.php +++ b/src/pocketmine/lang/TranslationContainer.php @@ -59,6 +59,8 @@ class TranslationContainer extends TextContainer{ /** * @param int $i * @param string $str + * + * @return void */ public function setParameter(int $i, string $str){ if($i < 0 or $i > count($this->params)){ //Intended, allow to set the last @@ -70,6 +72,8 @@ class TranslationContainer extends TextContainer{ /** * @param string[] $params + * + * @return void */ public function setParameters(array $params){ $i = 0; From 05c602a0449251fb86efb33e8f1fb428cc0e4e7f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:05:01 +0000 Subject: [PATCH 05/28] event: populate missing return type information --- src/pocketmine/event/Cancellable.php | 2 ++ src/pocketmine/event/player/PlayerCreationEvent.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/pocketmine/event/Cancellable.php b/src/pocketmine/event/Cancellable.php index f4017a199..b86ff9d9a 100644 --- a/src/pocketmine/event/Cancellable.php +++ b/src/pocketmine/event/Cancellable.php @@ -35,6 +35,8 @@ interface Cancellable{ /** * @param bool $value + * + * @return void */ public function setCancelled(bool $value = true); } diff --git a/src/pocketmine/event/player/PlayerCreationEvent.php b/src/pocketmine/event/player/PlayerCreationEvent.php index f79a3411d..b1a0593b2 100644 --- a/src/pocketmine/event/player/PlayerCreationEvent.php +++ b/src/pocketmine/event/player/PlayerCreationEvent.php @@ -99,6 +99,8 @@ class PlayerCreationEvent extends Event{ /** * @param string $class + * + * @return void */ public function setBaseClass($class){ if(!is_a($class, $this->baseClass, true)){ @@ -117,6 +119,8 @@ class PlayerCreationEvent extends Event{ /** * @param string $class + * + * @return void */ public function setPlayerClass($class){ if(!is_a($class, $this->baseClass, true)){ From 36cde9f352a43524c710fd51450b3490ebcfba62 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:05:31 +0000 Subject: [PATCH 06/28] inventory: populate missing return type information --- src/pocketmine/inventory/BaseInventory.php | 2 ++ src/pocketmine/inventory/DoubleChestInventory.php | 3 +++ src/pocketmine/inventory/EnderChestInventory.php | 2 ++ src/pocketmine/inventory/FurnaceRecipe.php | 2 ++ src/pocketmine/inventory/PlayerInventory.php | 8 +++++++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index 4702f90ee..2fb27d85e 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -84,6 +84,8 @@ abstract class BaseInventory implements Inventory{ * WARNING: If the size is smaller, any items past the new size will be lost. * * @param int $size + * + * @return void */ public function setSize(int $size){ $this->slots->setSize($size); diff --git a/src/pocketmine/inventory/DoubleChestInventory.php b/src/pocketmine/inventory/DoubleChestInventory.php index 45df2d92d..ab5bf8be8 100644 --- a/src/pocketmine/inventory/DoubleChestInventory.php +++ b/src/pocketmine/inventory/DoubleChestInventory.php @@ -142,6 +142,9 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ return $this->right; } + /** + * @return void + */ public function invalidate(){ $this->left = null; $this->right = null; diff --git a/src/pocketmine/inventory/EnderChestInventory.php b/src/pocketmine/inventory/EnderChestInventory.php index ce0f1e51e..4a0186f6d 100644 --- a/src/pocketmine/inventory/EnderChestInventory.php +++ b/src/pocketmine/inventory/EnderChestInventory.php @@ -53,6 +53,8 @@ class EnderChestInventory extends ChestInventory{ * Set the holder's position to that of a tile * * @param EnderChest $enderChest + * + * @return void */ public function setHolderPosition(EnderChest $enderChest){ $this->holder->setComponents($enderChest->getFloorX(), $enderChest->getFloorY(), $enderChest->getFloorZ()); diff --git a/src/pocketmine/inventory/FurnaceRecipe.php b/src/pocketmine/inventory/FurnaceRecipe.php index c8ed4be61..983a2b9d9 100644 --- a/src/pocketmine/inventory/FurnaceRecipe.php +++ b/src/pocketmine/inventory/FurnaceRecipe.php @@ -44,6 +44,8 @@ class FurnaceRecipe implements Recipe{ /** * @param Item $item + * + * @return void */ public function setInput(Item $item){ $this->ingredient = clone $item; diff --git a/src/pocketmine/inventory/PlayerInventory.php b/src/pocketmine/inventory/PlayerInventory.php index 6ffca62df..6f9576595 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -97,7 +97,7 @@ class PlayerInventory extends BaseInventory{ * * @throws \InvalidArgumentException */ - private function throwIfNotHotbarSlot(int $slot){ + private function throwIfNotHotbarSlot(int $slot) : void{ if(!$this->isHotbarSlot($slot)){ throw new \InvalidArgumentException("$slot is not a valid hotbar slot index (expected 0 - " . ($this->getHotbarSize() - 1) . ")"); } @@ -132,6 +132,7 @@ class PlayerInventory extends BaseInventory{ * @param bool $send Whether to send updates back to the inventory holder. This should usually be true for plugin calls. * It should only be false to prevent feedback loops of equipment packets between client and server. * + * @return void * @throws \InvalidArgumentException if the hotbar slot is out of range */ public function setHeldItemIndex(int $hotbarSlot, bool $send = true){ @@ -170,6 +171,8 @@ class PlayerInventory extends BaseInventory{ * Sends the currently-held item to specified targets. * * @param Player|Player[] $target + * + * @return void */ public function sendHeldItem($target){ $item = $this->getItemInHand(); @@ -201,6 +204,9 @@ class PlayerInventory extends BaseInventory{ return 9; } + /** + * @return void + */ public function sendCreativeContents(){ //TODO: this mess shouldn't be in here $holder = $this->getHolder(); From e419d76367345311a4970e9f0dc086e689fc1189 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:06:48 +0000 Subject: [PATCH 07/28] metadata: populate missing return type information --- .../metadata/BlockMetadataStore.php | 20 +++++++++++++++++++ .../metadata/EntityMetadataStore.php | 20 +++++++++++++++++++ .../metadata/LevelMetadataStore.php | 20 +++++++++++++++++++ src/pocketmine/metadata/MetadataStore.php | 6 ++++++ src/pocketmine/metadata/MetadataValue.php | 2 ++ src/pocketmine/metadata/Metadatable.php | 4 ++++ .../metadata/PlayerMetadataStore.php | 20 +++++++++++++++++++ 7 files changed, 92 insertions(+) diff --git a/src/pocketmine/metadata/BlockMetadataStore.php b/src/pocketmine/metadata/BlockMetadataStore.php index 58adf2e54..d60ce2c06 100644 --- a/src/pocketmine/metadata/BlockMetadataStore.php +++ b/src/pocketmine/metadata/BlockMetadataStore.php @@ -42,6 +42,12 @@ class BlockMetadataStore extends MetadataStore{ return $block->x . ":" . $block->y . ":" . $block->z . ":" . $metadataKey; } + /** + * @param Block $subject + * @param string $metadataKey + * + * @return MetadataValue[] + */ public function getMetadata(Block $subject, string $metadataKey){ return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey)); } @@ -50,10 +56,24 @@ class BlockMetadataStore extends MetadataStore{ return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey)); } + /** + * @param Block $subject + * @param string $metadataKey + * @param Plugin $owningPlugin + * + * @return void + */ public function removeMetadata(Block $subject, string $metadataKey, Plugin $owningPlugin){ $this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin); } + /** + * @param Block $subject + * @param string $metadataKey + * @param MetadataValue $newMetadataValue + * + * @return void + */ public function setMetadata(Block $subject, string $metadataKey, MetadataValue $newMetadataValue){ $this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue); } diff --git a/src/pocketmine/metadata/EntityMetadataStore.php b/src/pocketmine/metadata/EntityMetadataStore.php index 681ecf7f2..fce6c267f 100644 --- a/src/pocketmine/metadata/EntityMetadataStore.php +++ b/src/pocketmine/metadata/EntityMetadataStore.php @@ -32,6 +32,12 @@ class EntityMetadataStore extends MetadataStore{ return $entity->getId() . ":" . $metadataKey; } + /** + * @param Entity $subject + * @param string $metadataKey + * + * @return MetadataValue[] + */ public function getMetadata(Entity $subject, string $metadataKey){ return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey)); } @@ -40,10 +46,24 @@ class EntityMetadataStore extends MetadataStore{ return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey)); } + /** + * @param Entity $subject + * @param string $metadataKey + * @param Plugin $owningPlugin + * + * @return void + */ public function removeMetadata(Entity $subject, string $metadataKey, Plugin $owningPlugin){ $this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin); } + /** + * @param Entity $subject + * @param string $metadataKey + * @param MetadataValue $newMetadataValue + * + * @return void + */ public function setMetadata(Entity $subject, string $metadataKey, MetadataValue $newMetadataValue){ $this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue); } diff --git a/src/pocketmine/metadata/LevelMetadataStore.php b/src/pocketmine/metadata/LevelMetadataStore.php index 790c5221c..0b045f7ee 100644 --- a/src/pocketmine/metadata/LevelMetadataStore.php +++ b/src/pocketmine/metadata/LevelMetadataStore.php @@ -33,6 +33,12 @@ class LevelMetadataStore extends MetadataStore{ return strtolower($level->getName()) . ":" . $metadataKey; } + /** + * @param Level $subject + * @param string $metadataKey + * + * @return MetadataValue[] + */ public function getMetadata(Level $subject, string $metadataKey){ return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey)); } @@ -41,10 +47,24 @@ class LevelMetadataStore extends MetadataStore{ return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey)); } + /** + * @param Level $subject + * @param string $metadataKey + * @param Plugin $owningPlugin + * + * @return void + */ public function removeMetadata(Level $subject, string $metadataKey, Plugin $owningPlugin){ $this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin); } + /** + * @param Level $subject + * @param string $metadataKey + * @param MetadataValue $newMetadataValue + * + * @return void + */ public function setMetadata(Level $subject, string $metadataKey, MetadataValue $newMetadataValue){ $this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue); } diff --git a/src/pocketmine/metadata/MetadataStore.php b/src/pocketmine/metadata/MetadataStore.php index 7d2519c8a..be3023198 100644 --- a/src/pocketmine/metadata/MetadataStore.php +++ b/src/pocketmine/metadata/MetadataStore.php @@ -37,6 +37,8 @@ abstract class MetadataStore{ * * @param string $key * @param MetadataValue $newMetadataValue + * + * @return void */ protected function setMetadataInternal(string $key, MetadataValue $newMetadataValue){ $owningPlugin = $newMetadataValue->getOwningPlugin(); @@ -82,6 +84,8 @@ abstract class MetadataStore{ * * @param string $key * @param Plugin $owningPlugin + * + * @return void */ protected function removeMetadataInternal(string $key, Plugin $owningPlugin){ if(isset($this->metadataMap[$key])){ @@ -98,6 +102,8 @@ abstract class MetadataStore{ * be recalculated the next time it is accessed. * * @param Plugin $owningPlugin + * + * @return void */ public function invalidateAll(Plugin $owningPlugin){ /** @var \SplObjectStorage|MetadataValue[] $values */ diff --git a/src/pocketmine/metadata/MetadataValue.php b/src/pocketmine/metadata/MetadataValue.php index 6d3ab6d85..46622002d 100644 --- a/src/pocketmine/metadata/MetadataValue.php +++ b/src/pocketmine/metadata/MetadataValue.php @@ -50,6 +50,8 @@ abstract class MetadataValue{ /** * Invalidates this metadata item, forcing it to recompute when next * accessed. + * + * @return void */ abstract public function invalidate(); } diff --git a/src/pocketmine/metadata/Metadatable.php b/src/pocketmine/metadata/Metadatable.php index 802071b03..ca74456f5 100644 --- a/src/pocketmine/metadata/Metadatable.php +++ b/src/pocketmine/metadata/Metadatable.php @@ -32,6 +32,8 @@ interface Metadatable{ * * @param string $metadataKey * @param MetadataValue $newMetadataValue + * + * @return void */ public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue); @@ -61,6 +63,8 @@ interface Metadatable{ * * @param string $metadataKey * @param Plugin $owningPlugin + * + * @return void */ public function removeMetadata(string $metadataKey, Plugin $owningPlugin); diff --git a/src/pocketmine/metadata/PlayerMetadataStore.php b/src/pocketmine/metadata/PlayerMetadataStore.php index 7c4fce37d..dbea075b8 100644 --- a/src/pocketmine/metadata/PlayerMetadataStore.php +++ b/src/pocketmine/metadata/PlayerMetadataStore.php @@ -33,6 +33,12 @@ class PlayerMetadataStore extends MetadataStore{ return strtolower($player->getName()) . ":" . $metadataKey; } + /** + * @param IPlayer $subject + * @param string $metadataKey + * + * @return MetadataValue[] + */ public function getMetadata(IPlayer $subject, string $metadataKey){ return $this->getMetadataInternal($this->disambiguate($subject, $metadataKey)); } @@ -41,10 +47,24 @@ class PlayerMetadataStore extends MetadataStore{ return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey)); } + /** + * @param IPlayer $subject + * @param string $metadataKey + * @param Plugin $owningPlugin + * + * @return void + */ public function removeMetadata(IPlayer $subject, string $metadataKey, Plugin $owningPlugin){ $this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin); } + /** + * @param IPlayer $subject + * @param string $metadataKey + * @param MetadataValue $newMetadataValue + * + * @return void + */ public function setMetadata(IPlayer $subject, string $metadataKey, MetadataValue $newMetadataValue){ $this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue); } From 0b9d0f3cdc0d2dc0817fa33fa95eb12e1abe6413 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:07:48 +0000 Subject: [PATCH 08/28] utils: populate missing return type information --- src/pocketmine/utils/Color.php | 8 ++++++++ src/pocketmine/utils/Config.php | 14 ++++++++++++++ src/pocketmine/utils/MainLogger.php | 17 +++++++++++++++++ src/pocketmine/utils/Random.php | 2 ++ src/pocketmine/utils/ServerKiller.php | 3 +++ src/pocketmine/utils/Terminal.php | 6 ++++++ 6 files changed, 50 insertions(+) diff --git a/src/pocketmine/utils/Color.php b/src/pocketmine/utils/Color.php index ad45ef14e..44483aa49 100644 --- a/src/pocketmine/utils/Color.php +++ b/src/pocketmine/utils/Color.php @@ -57,6 +57,8 @@ class Color{ * Sets the alpha (opacity) value of this colour, lower = more transparent * * @param int $a + * + * @return void */ public function setA(int $a){ $this->a = $a & 0xff; @@ -74,6 +76,8 @@ class Color{ * Sets the red value of this colour. * * @param int $r + * + * @return void */ public function setR(int $r){ $this->r = $r & 0xff; @@ -91,6 +95,8 @@ class Color{ * Sets the green value of this colour. * * @param int $g + * + * @return void */ public function setG(int $g){ $this->g = $g & 0xff; @@ -108,6 +114,8 @@ class Color{ * Sets the blue value of this colour. * * @param int $b + * + * @return void */ public function setB(int $b){ $this->b = $b & 0xff; diff --git a/src/pocketmine/utils/Config.php b/src/pocketmine/utils/Config.php index 6110e47d2..0264fbb68 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -118,6 +118,8 @@ class Config{ /** * Removes all the changes in memory and loads the file again + * + * @return void */ public function reload(){ $this->config = []; @@ -333,6 +335,8 @@ class Config{ /** * @param string $k * @param mixed $v + * + * @return void */ public function __set($k, $v){ $this->set($k, $v); @@ -357,6 +361,8 @@ class Config{ /** * @param string $key * @param mixed $value + * + * @return void */ public function setNested($key, $value){ $vars = explode(".", $key); @@ -446,6 +452,8 @@ class Config{ /** * @param string $k key to be set * @param mixed $v value to set key + * + * @return void */ public function set($k, $v = true){ $this->config[$k] = $v; @@ -459,6 +467,8 @@ class Config{ /** * @param array $v + * + * @return void */ public function setAll(array $v){ $this->config = $v; @@ -483,6 +493,8 @@ class Config{ /** * @param string $k + * + * @return void */ public function remove($k){ unset($this->config[$k]); @@ -500,6 +512,8 @@ class Config{ /** * @param array $defaults + * + * @return void */ public function setDefaults(array $defaults){ $this->fillDefaults($defaults, $this->config); diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index 14ba183ba..6b7debf14 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -121,6 +121,8 @@ class MainLogger extends \AttachableThreadedLogger{ * * WARNING: Because static properties are thread-local, this MUST be called from the body of every Thread if you * want the logger to be accessible via {@link MainLogger#getLogger}. + * + * @return void */ public function registerStatic(){ if(static::$logger === null){ @@ -191,6 +193,8 @@ class MainLogger extends \AttachableThreadedLogger{ /** * @param bool $logDebug + * + * @return void */ public function setLogDebug(bool $logDebug){ $this->logDebug = $logDebug; @@ -199,6 +203,8 @@ class MainLogger extends \AttachableThreadedLogger{ /** * @param \Throwable $e * @param array|null $trace + * + * @return void */ public function logException(\Throwable $e, $trace = null){ if($trace === null){ @@ -281,6 +287,9 @@ class MainLogger extends \AttachableThreadedLogger{ } } + /** + * @return void + */ public function shutdown(){ $this->shutdown = true; $this->notify(); @@ -291,6 +300,8 @@ class MainLogger extends \AttachableThreadedLogger{ * @param string $level * @param string $prefix * @param string $color + * + * @return void */ protected function send($message, $level, $prefix, $color){ /** @var \DateTime|null $time */ @@ -326,6 +337,9 @@ class MainLogger extends \AttachableThreadedLogger{ }); } + /** + * @return void + */ public function syncFlushBuffer(){ $this->syncFlush = true; $this->synchronized(function(){ @@ -352,6 +366,9 @@ class MainLogger extends \AttachableThreadedLogger{ } } + /** + * @return void + */ public function run(){ $logResource = fopen($this->logFile, "ab"); if(!is_resource($logResource)){ diff --git a/src/pocketmine/utils/Random.php b/src/pocketmine/utils/Random.php index b92763125..546c7b3ac 100644 --- a/src/pocketmine/utils/Random.php +++ b/src/pocketmine/utils/Random.php @@ -71,6 +71,8 @@ class Random{ /** * @param int $seed Integer to be used as seed. + * + * @return void */ public function setSeed(int $seed){ $this->seed = $seed; diff --git a/src/pocketmine/utils/ServerKiller.php b/src/pocketmine/utils/ServerKiller.php index 934585a9c..6f9e84f71 100644 --- a/src/pocketmine/utils/ServerKiller.php +++ b/src/pocketmine/utils/ServerKiller.php @@ -42,6 +42,9 @@ class ServerKiller extends Thread{ $this->time = $time; } + /** + * @return void + */ public function run(){ $this->registerClassLoader(); $start = time(); diff --git a/src/pocketmine/utils/Terminal.php b/src/pocketmine/utils/Terminal.php index c30f08e56..f368d5823 100644 --- a/src/pocketmine/utils/Terminal.php +++ b/src/pocketmine/utils/Terminal.php @@ -101,6 +101,9 @@ abstract class Terminal{ return $result; } + /** + * @return void + */ protected static function getFallbackEscapeCodes(){ self::$FORMAT_BOLD = "\x1b[1m"; self::$FORMAT_OBFUSCATED = ""; @@ -128,6 +131,9 @@ abstract class Terminal{ self::$COLOR_WHITE = "\x1b[38;5;231m"; } + /** + * @return void + */ protected static function getEscapeCodes(){ self::$FORMAT_BOLD = `tput bold`; self::$FORMAT_OBFUSCATED = `tput smacs`; From 8776b71d63252479931a2ca510af61b2d423c984 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:08:40 +0000 Subject: [PATCH 09/28] tile: populate missing return type information --- src/pocketmine/tile/Bed.php | 3 +++ src/pocketmine/tile/Chest.php | 14 +++++++++++++- src/pocketmine/tile/FlowerPot.php | 8 ++++++++ src/pocketmine/tile/Furnace.php | 5 +++++ src/pocketmine/tile/ItemFrame.php | 15 +++++++++++++++ src/pocketmine/tile/Nameable.php | 2 ++ src/pocketmine/tile/Skull.php | 5 +++++ src/pocketmine/tile/Spawnable.php | 3 +++ src/pocketmine/tile/Tile.php | 3 +++ 9 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/tile/Bed.php b/src/pocketmine/tile/Bed.php index b53c3de27..e0b137ac1 100644 --- a/src/pocketmine/tile/Bed.php +++ b/src/pocketmine/tile/Bed.php @@ -38,6 +38,9 @@ class Bed extends Spawnable{ return $this->color; } + /** + * @return void + */ public function setColor(int $color){ $this->color = $color & 0xf; $this->onChanged(); diff --git a/src/pocketmine/tile/Chest.php b/src/pocketmine/tile/Chest.php index f8e57ea19..4cab5fe76 100644 --- a/src/pocketmine/tile/Chest.php +++ b/src/pocketmine/tile/Chest.php @@ -117,6 +117,9 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ return $this->inventory; } + /** + * @return void + */ protected function checkPairing(){ if($this->isPaired() and !$this->getLevel()->isInLoadedTerrain(new Vector3($this->pairX, $this->y, $this->pairZ))){ //paired to a tile in an unloaded chunk @@ -151,6 +154,9 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ return "Chest"; } + /** + * @return bool + */ public function isPaired(){ return $this->pairX !== null and $this->pairZ !== null; } @@ -169,6 +175,9 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ return null; } + /** + * @return bool + */ public function pairWith(Chest $tile){ if($this->isPaired() or $tile->isPaired()){ return false; @@ -183,7 +192,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ return true; } - private function createPair(Chest $tile){ + private function createPair(Chest $tile) : void{ $this->pairX = $tile->x; $this->pairZ = $tile->z; @@ -191,6 +200,9 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ $tile->pairZ = $this->z; } + /** + * @return bool + */ public function unpair(){ if(!$this->isPaired()){ return false; diff --git a/src/pocketmine/tile/FlowerPot.php b/src/pocketmine/tile/FlowerPot.php index 7b69d69af..48703c5a4 100644 --- a/src/pocketmine/tile/FlowerPot.php +++ b/src/pocketmine/tile/FlowerPot.php @@ -70,11 +70,19 @@ class FlowerPot extends Spawnable{ return clone $this->item; } + /** + * @param Item $item + * + * @return void + */ public function setItem(Item $item){ $this->item = clone $item; $this->onChanged(); } + /** + * @return void + */ public function removeItem(){ $this->setItem(ItemFactory::get(Item::AIR, 0, 0)); } diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index 2bd1e4740..8227272e8 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -138,6 +138,11 @@ class Furnace extends Spawnable implements InventoryHolder, Container, Nameable{ return $this->getInventory(); } + /** + * @param Item $fuel + * + * @return void + */ protected function checkFuel(Item $fuel){ $ev = new FurnaceBurnEvent($this, $fuel, $fuel->getFuelTime()); $ev->call(); diff --git a/src/pocketmine/tile/ItemFrame.php b/src/pocketmine/tile/ItemFrame.php index 4b573395f..07569b38e 100644 --- a/src/pocketmine/tile/ItemFrame.php +++ b/src/pocketmine/tile/ItemFrame.php @@ -63,6 +63,11 @@ class ItemFrame extends Spawnable{ return clone $this->item; } + /** + * @param Item|null $item + * + * @return void + */ public function setItem(Item $item = null){ if($item !== null and !$item->isNull()){ $this->item = clone $item; @@ -76,6 +81,11 @@ class ItemFrame extends Spawnable{ return $this->itemRotation; } + /** + * @param int $rotation + * + * @return void + */ public function setItemRotation(int $rotation){ $this->itemRotation = $rotation; $this->onChanged(); @@ -85,6 +95,11 @@ class ItemFrame extends Spawnable{ return $this->itemDropChance; } + /** + * @param float $chance + * + * @return void + */ public function setItemDropChance(float $chance){ $this->itemDropChance = $chance; $this->onChanged(); diff --git a/src/pocketmine/tile/Nameable.php b/src/pocketmine/tile/Nameable.php index ab66b101c..7c6c3aab7 100644 --- a/src/pocketmine/tile/Nameable.php +++ b/src/pocketmine/tile/Nameable.php @@ -38,6 +38,8 @@ interface Nameable{ /** * @param string $str + * + * @return void */ public function setName(string $str); diff --git a/src/pocketmine/tile/Skull.php b/src/pocketmine/tile/Skull.php index 2e7210284..7011bdc7e 100644 --- a/src/pocketmine/tile/Skull.php +++ b/src/pocketmine/tile/Skull.php @@ -57,6 +57,11 @@ class Skull extends Spawnable{ $nbt->setByte(self::TAG_ROT, $this->skullRotation); } + /** + * @param int $type + * + * @return void + */ public function setType(int $type){ $this->skullType = $type; $this->onChanged(); diff --git a/src/pocketmine/tile/Spawnable.php b/src/pocketmine/tile/Spawnable.php index bcad010b5..416c7d640 100644 --- a/src/pocketmine/tile/Spawnable.php +++ b/src/pocketmine/tile/Spawnable.php @@ -62,6 +62,9 @@ abstract class Spawnable extends Tile{ $this->spawnToAll(); } + /** + * @return void + */ public function spawnToAll(){ if($this->closed){ return; diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index 5dcb70a0a..abafa93b8 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -84,6 +84,9 @@ abstract class Tile extends Position{ /** @var TimingsHandler */ protected $timings; + /** + * @return void + */ public static function init(){ self::registerTile(Banner::class, [self::BANNER, "minecraft:banner"]); self::registerTile(Bed::class, [self::BED, "minecraft:bed"]); From 1cc7027f920eed393724f510442387780db50a6b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:09:33 +0000 Subject: [PATCH 10/28] plugin: populate missing return type information --- src/pocketmine/plugin/Plugin.php | 12 +++++++++ src/pocketmine/plugin/PluginDescription.php | 1 + src/pocketmine/plugin/PluginManager.php | 26 ++++++++++++++++++++ src/pocketmine/plugin/RegisteredListener.php | 2 ++ 4 files changed, 41 insertions(+) diff --git a/src/pocketmine/plugin/Plugin.php b/src/pocketmine/plugin/Plugin.php index fbef35765..2af2f2e75 100644 --- a/src/pocketmine/plugin/Plugin.php +++ b/src/pocketmine/plugin/Plugin.php @@ -41,11 +41,15 @@ interface Plugin extends CommandExecutor{ /** * Called when the plugin is loaded, before calling onEnable() + * + * @return void */ public function onLoad(); /** * Called when the plugin is enabled + * + * @return void */ public function onEnable(); @@ -68,6 +72,8 @@ interface Plugin extends CommandExecutor{ /** * Called when the plugin is disabled * Use this to free open things and finish actions + * + * @return void */ public function onDisable(); @@ -120,6 +126,9 @@ interface Plugin extends CommandExecutor{ */ public function getConfig() : Config; + /** + * @return void + */ public function saveConfig(); /** @@ -127,6 +136,9 @@ interface Plugin extends CommandExecutor{ */ public function saveDefaultConfig() : bool; + /** + * @return void + */ public function reloadConfig(); /** diff --git a/src/pocketmine/plugin/PluginDescription.php b/src/pocketmine/plugin/PluginDescription.php index e092ae250..cf2da4ebc 100644 --- a/src/pocketmine/plugin/PluginDescription.php +++ b/src/pocketmine/plugin/PluginDescription.php @@ -213,6 +213,7 @@ class PluginDescription{ /** * Checks if the current PHP runtime has the extensions required by the plugin. * + * @return void * @throws PluginException if there are required extensions missing or have incompatible version, or if the version constraint cannot be parsed */ public function checkRequiredExtensions(){ diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 48e8e12a1..c49d15795 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -441,6 +441,8 @@ class PluginManager{ * @see PermissionManager::removePermission() * * @param string|Permission $permission + * + * @return void */ public function removePermission($permission){ PermissionManager::getInstance()->removePermission($permission); @@ -463,6 +465,8 @@ class PluginManager{ * @see PermissionManager::recalculatePermissionDefaults() * * @param Permission $permission + * + * @return void */ public function recalculatePermissionDefaults(Permission $permission){ PermissionManager::getInstance()->recalculatePermissionDefaults($permission); @@ -474,6 +478,8 @@ class PluginManager{ * * @param string $permission * @param Permissible $permissible + * + * @return void */ public function subscribeToPermission(string $permission, Permissible $permissible){ PermissionManager::getInstance()->subscribeToPermission($permission, $permissible); @@ -485,6 +491,8 @@ class PluginManager{ * * @param string $permission * @param Permissible $permissible + * + * @return void */ public function unsubscribeFromPermission(string $permission, Permissible $permissible){ PermissionManager::getInstance()->unsubscribeFromPermission($permission, $permissible); @@ -495,6 +503,8 @@ class PluginManager{ * @see PermissionManager::unsubscribeFromAllPermissions() * * @param Permissible $permissible + * + * @return void */ public function unsubscribeFromAllPermissions(Permissible $permissible) : void{ PermissionManager::getInstance()->unsubscribeFromAllPermissions($permissible); @@ -518,6 +528,8 @@ class PluginManager{ * * @param bool $op * @param Permissible $permissible + * + * @return void */ public function subscribeToDefaultPerms(bool $op, Permissible $permissible){ PermissionManager::getInstance()->subscribeToDefaultPerms($op, $permissible); @@ -529,6 +541,8 @@ class PluginManager{ * * @param bool $op * @param Permissible $permissible + * + * @return void */ public function unsubscribeFromDefaultPerms(bool $op, Permissible $permissible){ PermissionManager::getInstance()->unsubscribeFromDefaultPerms($op, $permissible); @@ -567,6 +581,8 @@ class PluginManager{ /** * @param Plugin $plugin + * + * @return void */ public function enablePlugin(Plugin $plugin){ if(!$plugin->isEnabled()){ @@ -647,6 +663,9 @@ class PluginManager{ return $pluginCmds; } + /** + * @return void + */ public function disablePlugins(){ foreach($this->getPlugins() as $plugin){ $this->disablePlugin($plugin); @@ -655,6 +674,8 @@ class PluginManager{ /** * @param Plugin $plugin + * + * @return void */ public function disablePlugin(Plugin $plugin){ if($plugin->isEnabled()){ @@ -683,6 +704,9 @@ class PluginManager{ } } + /** + * @return void + */ public function clearPlugins(){ $this->disablePlugins(); $this->plugins = []; @@ -697,6 +721,8 @@ class PluginManager{ * @see Event::call() * * @param Event $event + * + * @return void */ public function callEvent(Event $event){ $event->call(); diff --git a/src/pocketmine/plugin/RegisteredListener.php b/src/pocketmine/plugin/RegisteredListener.php index 7db4cadea..fed6d24c2 100644 --- a/src/pocketmine/plugin/RegisteredListener.php +++ b/src/pocketmine/plugin/RegisteredListener.php @@ -89,6 +89,8 @@ class RegisteredListener{ /** * @param Event $event + * + * @return void */ public function callEvent(Event $event){ if($event instanceof Cancellable and $event->isCancelled() and $this->isIgnoringCancelled()){ From f5a18df835d2d471035b938cc8e1fdca020f0f7b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:11:12 +0000 Subject: [PATCH 11/28] scheduler: populate missing return type information --- src/pocketmine/scheduler/AsyncTask.php | 24 ++++++++++++++++++++++ src/pocketmine/scheduler/AsyncWorker.php | 6 ++++++ src/pocketmine/scheduler/Task.php | 4 ++++ src/pocketmine/scheduler/TaskHandler.php | 10 +++++++++ src/pocketmine/scheduler/TaskScheduler.php | 7 +++++++ 5 files changed, 51 insertions(+) diff --git a/src/pocketmine/scheduler/AsyncTask.php b/src/pocketmine/scheduler/AsyncTask.php index cf3524869..410c7a373 100644 --- a/src/pocketmine/scheduler/AsyncTask.php +++ b/src/pocketmine/scheduler/AsyncTask.php @@ -71,6 +71,9 @@ abstract class AsyncTask extends Collectable{ /** @var bool */ private $crashed = false; + /** + * @return void + */ public function run(){ $this->result = null; @@ -97,6 +100,9 @@ abstract class AsyncTask extends Collectable{ return $this->serialized ? unserialize($this->result) : $this->result; } + /** + * @return void + */ public function cancelRun(){ $this->cancelRun = true; } @@ -114,11 +120,18 @@ abstract class AsyncTask extends Collectable{ /** * @param mixed $result + * + * @return void */ public function setResult($result){ $this->result = ($this->serialized = !is_scalar($result)) ? serialize($result) : $result; } + /** + * @param int $taskId + * + * @return void + */ public function setTaskId(int $taskId){ $this->taskId = $taskId; } @@ -149,6 +162,8 @@ abstract class AsyncTask extends Collectable{ * * @param string $identifier * @param mixed $value + * + * @return void */ public function saveToThreadStore(string $identifier, $value){ if($this->worker === null or $this->isGarbage()){ @@ -161,6 +176,8 @@ abstract class AsyncTask extends Collectable{ * @see AsyncWorker::removeFromThreadStore() * * @param string $identifier + * + * @return void */ public function removeFromThreadStore(string $identifier) : void{ if($this->worker === null or $this->isGarbage()){ @@ -193,6 +210,8 @@ abstract class AsyncTask extends Collectable{ * {@link AsyncTask::onProgressUpdate} from the main thread with the given progress parameter. * * @param mixed $progress A value that can be safely serialize()'ed. + * + * @return void */ public function publishProgress($progress){ $this->progressUpdates[] = serialize($progress); @@ -202,6 +221,8 @@ abstract class AsyncTask extends Collectable{ * @internal Only call from AsyncPool.php on the main thread * * @param Server $server + * + * @return void */ public function checkProgressUpdates(Server $server){ while($this->progressUpdates->count() !== 0){ @@ -218,6 +239,8 @@ abstract class AsyncTask extends Collectable{ * @param Server $server * @param mixed $progress The parameter passed to {@link AsyncTask::publishProgress}. It is serialize()'ed * and then unserialize()'ed, as if it has been cloned. + * + * @return void */ public function onProgressUpdate(Server $server, $progress){ @@ -237,6 +260,7 @@ abstract class AsyncTask extends Collectable{ * * @param mixed $complexData the data to store * + * @return void * @throws \BadMethodCallException if called from any thread except the main thread */ protected function storeLocal($complexData){ diff --git a/src/pocketmine/scheduler/AsyncWorker.php b/src/pocketmine/scheduler/AsyncWorker.php index 69400a379..d85963411 100644 --- a/src/pocketmine/scheduler/AsyncWorker.php +++ b/src/pocketmine/scheduler/AsyncWorker.php @@ -49,6 +49,9 @@ class AsyncWorker extends Worker{ $this->memoryLimit = $memoryLimit; } + /** + * @return void + */ public function run(){ error_reporting(-1); @@ -76,6 +79,9 @@ class AsyncWorker extends Worker{ return $this->logger; } + /** + * @return void + */ public function handleException(\Throwable $e){ $this->logger->logException($e); } diff --git a/src/pocketmine/scheduler/Task.php b/src/pocketmine/scheduler/Task.php index f2ad1d862..560a72f60 100644 --- a/src/pocketmine/scheduler/Task.php +++ b/src/pocketmine/scheduler/Task.php @@ -54,6 +54,8 @@ abstract class Task{ /** * @param TaskHandler|null $taskHandler + * + * @return void */ final public function setHandler(TaskHandler $taskHandler = null){ if($this->taskHandler === null or $taskHandler === null){ @@ -72,6 +74,8 @@ abstract class Task{ /** * Actions to execute if the Task is cancelled + * + * @return void */ public function onCancel(){ diff --git a/src/pocketmine/scheduler/TaskHandler.php b/src/pocketmine/scheduler/TaskHandler.php index e2188af1e..8e8305d19 100644 --- a/src/pocketmine/scheduler/TaskHandler.php +++ b/src/pocketmine/scheduler/TaskHandler.php @@ -88,6 +88,8 @@ class TaskHandler{ /** * @param int $ticks + * + * @return void */ public function setNextRun(int $ticks){ $this->nextRun = $ticks; @@ -135,6 +137,9 @@ class TaskHandler{ return $this->period; } + /** + * @return void + */ public function cancel(){ try{ if(!$this->isCancelled()){ @@ -145,6 +150,9 @@ class TaskHandler{ } } + /** + * @return void + */ public function remove(){ $this->cancelled = true; $this->task->setHandler(null); @@ -152,6 +160,8 @@ class TaskHandler{ /** * @param int $currentTick + * + * @return void */ public function run(int $currentTick){ $this->timings->startTiming(); diff --git a/src/pocketmine/scheduler/TaskScheduler.php b/src/pocketmine/scheduler/TaskScheduler.php index c8581d678..cea28c025 100644 --- a/src/pocketmine/scheduler/TaskScheduler.php +++ b/src/pocketmine/scheduler/TaskScheduler.php @@ -103,6 +103,8 @@ class TaskScheduler{ /** * @param int $taskId + * + * @return void */ public function cancelTask(int $taskId){ if(isset($this->tasks[$taskId])){ @@ -114,6 +116,9 @@ class TaskScheduler{ } } + /** + * @return void + */ public function cancelAllTasks(){ foreach($this->tasks as $id => $task){ $this->cancelTask($id); @@ -186,6 +191,8 @@ class TaskScheduler{ /** * @param int $currentTick + * + * @return void */ public function mainThreadHeartbeat(int $currentTick){ $this->currentTick = $currentTick; From 11cae2f0c0e3abb9b049b92862862239a86f62a7 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:12:13 +0000 Subject: [PATCH 12/28] timings: populate missing return type information --- src/pocketmine/timings/Timings.php | 3 +++ src/pocketmine/timings/TimingsHandler.php | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/pocketmine/timings/Timings.php b/src/pocketmine/timings/Timings.php index 5192728f5..49920b004 100644 --- a/src/pocketmine/timings/Timings.php +++ b/src/pocketmine/timings/Timings.php @@ -105,6 +105,9 @@ abstract class Timings{ /** @var TimingsHandler[] */ public static $pluginTaskTimingMap = []; + /** + * @return void + */ public static function init(){ if(self::$initialized){ return; diff --git a/src/pocketmine/timings/TimingsHandler.php b/src/pocketmine/timings/TimingsHandler.php index 9040bee54..c32b622ac 100644 --- a/src/pocketmine/timings/TimingsHandler.php +++ b/src/pocketmine/timings/TimingsHandler.php @@ -43,6 +43,8 @@ class TimingsHandler{ /** * @param resource $fp + * + * @return void */ public static function printTimings($fp){ fwrite($fp, "Minecraft" . PHP_EOL); @@ -93,6 +95,9 @@ class TimingsHandler{ return self::$timingStart; } + /** + * @return void + */ public static function reload(){ if(self::$enabled){ foreach(self::$HANDLERS as $timings){ @@ -102,6 +107,11 @@ class TimingsHandler{ } } + /** + * @param bool $measure + * + * @return void + */ public static function tick(bool $measure = true){ if(self::$enabled){ if($measure){ @@ -157,6 +167,9 @@ class TimingsHandler{ self::$HANDLERS[spl_object_hash($this)] = $this; } + /** + * @return void + */ public function startTiming(){ if(self::$enabled){ $this->internalStartTiming(microtime(true)); @@ -172,6 +185,9 @@ class TimingsHandler{ } } + /** + * @return void + */ public function stopTiming(){ if(self::$enabled){ $this->internalStopTiming(microtime(true)); @@ -200,6 +216,9 @@ class TimingsHandler{ } } + /** + * @return void + */ public function reset(){ $this->count = 0; $this->curCount = 0; @@ -210,6 +229,9 @@ class TimingsHandler{ $this->timingDepth = 0; } + /** + * @return void + */ public function remove(){ unset(self::$HANDLERS[spl_object_hash($this)]); } From e6ba3ce8a6e5d817cae55a26d05eec58706ccf54 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:13:33 +0000 Subject: [PATCH 13/28] item: populate missing return type information --- src/pocketmine/item/Consumable.php | 2 ++ src/pocketmine/item/Durable.php | 2 ++ src/pocketmine/item/Item.php | 9 +++++++++ src/pocketmine/item/ItemFactory.php | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/src/pocketmine/item/Consumable.php b/src/pocketmine/item/Consumable.php index 5977c37f4..97f1df158 100644 --- a/src/pocketmine/item/Consumable.php +++ b/src/pocketmine/item/Consumable.php @@ -49,6 +49,8 @@ interface Consumable{ * Called when this Consumable is consumed by mob, after standard resulting effects have been applied. * * @param Living $consumer + * + * @return void */ public function onConsume(Living $consumer); } diff --git a/src/pocketmine/item/Durable.php b/src/pocketmine/item/Durable.php index 07fa51002..6b548e7a7 100644 --- a/src/pocketmine/item/Durable.php +++ b/src/pocketmine/item/Durable.php @@ -42,6 +42,8 @@ abstract class Durable extends Item{ * Sets whether the item will take damage when used. * * @param bool $value + * + * @return void */ public function setUnbreakable(bool $value = true){ $this->setNamedTagEntry(new ByteTag("Unbreakable", $value ? 1 : 0)); diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index d1e21183a..ae26592d5 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -123,6 +123,9 @@ class Item implements ItemIds, \JsonSerializable{ /** @var Item[] */ private static $creative = []; + /** + * @return void + */ public static function initCreativeItems(){ self::clearCreativeItems(); @@ -140,6 +143,8 @@ class Item implements ItemIds, \JsonSerializable{ /** * Removes all previously added items from the creative menu. * Note: Players who are already online when this is called will not see this change. + * + * @return void */ public static function clearCreativeItems(){ Item::$creative = []; @@ -154,6 +159,8 @@ class Item implements ItemIds, \JsonSerializable{ * Note: Players who are already online when this is called will not see this change. * * @param Item $item + * + * @return void */ public static function addCreativeItem(Item $item){ Item::$creative[] = clone $item; @@ -164,6 +171,8 @@ class Item implements ItemIds, \JsonSerializable{ * Note: Players who are already online when this is called will not see this change. * * @param Item $item + * + * @return void */ public static function removeCreativeItem(Item $item){ $index = self::getCreativeItemIndex($item); diff --git a/src/pocketmine/item/ItemFactory.php b/src/pocketmine/item/ItemFactory.php index 3c51f3173..37c576b56 100644 --- a/src/pocketmine/item/ItemFactory.php +++ b/src/pocketmine/item/ItemFactory.php @@ -46,6 +46,9 @@ class ItemFactory{ /** @var \SplFixedArray */ private static $list = null; + /** + * @return void + */ public static function init(){ self::$list = new \SplFixedArray(65536); @@ -285,6 +288,7 @@ class ItemFactory{ * @param Item $item * @param bool $override * + * @return void * @throws \RuntimeException if something attempted to override an already-registered item without specifying the * $override parameter. */ From fffeeddca6314564c7c69fb6999c5c7fdb23a253 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:14:34 +0000 Subject: [PATCH 14/28] DataPacket: add magic method return types to keep phpstan happy this really shouldn't be necessary, but it is what it is. --- src/pocketmine/network/mcpe/protocol/DataPacket.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index fef902791..d825e43f6 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -158,6 +158,9 @@ abstract class DataPacket extends NetworkBinaryStream{ return $this; } + /** + * @return mixed[] + */ public function __debugInfo(){ $data = []; foreach((array) $this as $k => $v){ @@ -175,6 +178,8 @@ abstract class DataPacket extends NetworkBinaryStream{ /** * @param string $name + * + * @return mixed */ public function __get($name){ throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); @@ -183,6 +188,8 @@ abstract class DataPacket extends NetworkBinaryStream{ /** * @param string $name * @param mixed $value + * + * @return void */ public function __set($name, $value){ throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); From facca13139e51b50ae77dc9ca3d5ca3b72c88b02 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 17:23:52 +0000 Subject: [PATCH 15/28] permission: populate missing return type information PermissibleBase has some redundant phpdoc removed so that the Permissible interface can provide return types. --- src/pocketmine/permission/BanEntry.php | 17 ++++++++++++++ src/pocketmine/permission/BanList.php | 14 ++++++++++++ .../permission/DefaultPermissions.php | 3 +++ src/pocketmine/permission/PermissibleBase.php | 22 +++---------------- src/pocketmine/permission/Permission.php | 7 ++++++ .../permission/PermissionAttachment.php | 13 +++++++++++ .../permission/PermissionManager.php | 12 ++++++++++ src/pocketmine/permission/ServerOperator.php | 2 ++ 8 files changed, 71 insertions(+), 19 deletions(-) diff --git a/src/pocketmine/permission/BanEntry.php b/src/pocketmine/permission/BanEntry.php index 01fe5bb16..82872727f 100644 --- a/src/pocketmine/permission/BanEntry.php +++ b/src/pocketmine/permission/BanEntry.php @@ -61,6 +61,11 @@ class BanEntry{ return $this->creationDate; } + /** + * @param \DateTime $date + * + * @return void + */ public function setCreated(\DateTime $date){ self::validateDate($date); $this->creationDate = $date; @@ -70,6 +75,11 @@ class BanEntry{ return $this->source; } + /** + * @param string $source + * + * @return void + */ public function setSource(string $source){ $this->source = $source; } @@ -83,6 +93,8 @@ class BanEntry{ /** * @param \DateTime|null $date + * + * @return void */ public function setExpires(\DateTime $date = null){ if($date !== null){ @@ -101,6 +113,11 @@ class BanEntry{ return $this->reason; } + /** + * @param string $reason + * + * @return void + */ public function setReason(string $reason){ $this->reason = $reason; } diff --git a/src/pocketmine/permission/BanList.php b/src/pocketmine/permission/BanList.php index de2ca150d..5eae82a7b 100644 --- a/src/pocketmine/permission/BanList.php +++ b/src/pocketmine/permission/BanList.php @@ -61,6 +61,8 @@ class BanList{ /** * @param bool $flag + * + * @return void */ public function setEnabled(bool $flag){ $this->enabled = $flag; @@ -104,6 +106,8 @@ class BanList{ /** * @param BanEntry $entry + * + * @return void */ public function add(BanEntry $entry){ $this->list[$entry->getName()] = $entry; @@ -132,6 +136,8 @@ class BanList{ /** * @param string $name + * + * @return void */ public function remove(string $name){ $name = strtolower($name); @@ -141,6 +147,9 @@ class BanList{ } } + /** + * @return void + */ public function removeExpired(){ foreach($this->list as $name => $entry){ if($entry->hasExpired()){ @@ -149,6 +158,9 @@ class BanList{ } } + /** + * @return void + */ public function load(){ $this->list = []; $fp = @fopen($this->file, "r"); @@ -175,6 +187,8 @@ class BanList{ /** * @param bool $writeHeader + * + * @return void */ public function save(bool $writeHeader = true){ $this->removeExpired(); diff --git a/src/pocketmine/permission/DefaultPermissions.php b/src/pocketmine/permission/DefaultPermissions.php index 606e55a9e..c3c0701cc 100644 --- a/src/pocketmine/permission/DefaultPermissions.php +++ b/src/pocketmine/permission/DefaultPermissions.php @@ -43,6 +43,9 @@ abstract class DefaultPermissions{ return PermissionManager::getInstance()->getPermission($perm->getName()); } + /** + * @return void + */ public static function registerCorePermissions(){ $parent = self::registerPermission(new Permission(self::ROOT, "Allows using all PocketMine commands and utilities")); diff --git a/src/pocketmine/permission/PermissibleBase.php b/src/pocketmine/permission/PermissibleBase.php index 5471cc031..a6e9c55ee 100644 --- a/src/pocketmine/permission/PermissibleBase.php +++ b/src/pocketmine/permission/PermissibleBase.php @@ -55,34 +55,18 @@ class PermissibleBase implements Permissible{ } } - /** - * @return bool - */ public function isOp() : bool{ return $this->opable->isOp(); } - /** - * @param bool $value - */ public function setOp(bool $value){ $this->opable->setOp($value); } - /** - * @param Permission|string $name - * - * @return bool - */ public function isPermissionSet($name) : bool{ return isset($this->permissions[$name instanceof Permission ? $name->getName() : $name]); } - /** - * @param Permission|string $name - * - * @return bool - */ public function hasPermission($name) : bool{ if($name instanceof Permission){ $name = $name->getName(); @@ -127,9 +111,6 @@ class PermissibleBase implements Permissible{ return $result; } - /** - * @param PermissionAttachment $attachment - */ public function removeAttachment(PermissionAttachment $attachment){ if(isset($this->attachments[spl_object_hash($attachment)])){ unset($this->attachments[spl_object_hash($attachment)]); @@ -165,6 +146,9 @@ class PermissibleBase implements Permissible{ Timings::$permissibleCalculationTimer->stopTiming(); } + /** + * @return void + */ public function clearPermissions(){ $permManager = PermissionManager::getInstance(); $permManager->unsubscribeFromAllPermissions($this->parent ?? $this); diff --git a/src/pocketmine/permission/Permission.php b/src/pocketmine/permission/Permission.php index a387c2ad5..9b8c085eb 100644 --- a/src/pocketmine/permission/Permission.php +++ b/src/pocketmine/permission/Permission.php @@ -192,6 +192,8 @@ class Permission{ /** * @param string $value + * + * @return void */ public function setDefault(string $value){ if($value !== $this->defaultValue){ @@ -209,6 +211,8 @@ class Permission{ /** * @param string $value + * + * @return void */ public function setDescription(string $value){ $this->description = $value; @@ -221,6 +225,9 @@ class Permission{ return PermissionManager::getInstance()->getPermissionSubscriptions($this->name); } + /** + * @return void + */ public function recalculatePermissibles(){ $perms = $this->getPermissibles(); diff --git a/src/pocketmine/permission/PermissionAttachment.php b/src/pocketmine/permission/PermissionAttachment.php index 1d4693c18..2a019cdd9 100644 --- a/src/pocketmine/permission/PermissionAttachment.php +++ b/src/pocketmine/permission/PermissionAttachment.php @@ -65,6 +65,8 @@ class PermissionAttachment{ /** * @param PermissionRemovedExecutor $ex + * + * @return void */ public function setRemovalCallback(PermissionRemovedExecutor $ex){ $this->removed = $ex; @@ -91,6 +93,9 @@ class PermissionAttachment{ return $this->permissions; } + /** + * @return void + */ public function clearPermissions(){ $this->permissions = []; $this->permissible->recalculatePermissions(); @@ -98,6 +103,8 @@ class PermissionAttachment{ /** * @param bool[] $permissions + * + * @return void */ public function setPermissions(array $permissions){ foreach($permissions as $key => $value){ @@ -108,6 +115,8 @@ class PermissionAttachment{ /** * @param string[] $permissions + * + * @return void */ public function unsetPermissions(array $permissions){ foreach($permissions as $node){ @@ -119,6 +128,8 @@ class PermissionAttachment{ /** * @param string|Permission $name * @param bool $value + * + * @return void */ public function setPermission($name, bool $value){ $name = $name instanceof Permission ? $name->getName() : $name; @@ -134,6 +145,8 @@ class PermissionAttachment{ /** * @param string|Permission $name + * + * @return void */ public function unsetPermission($name){ $name = $name instanceof Permission ? $name->getName() : $name; diff --git a/src/pocketmine/permission/PermissionManager.php b/src/pocketmine/permission/PermissionManager.php index 15c969e70..d438cf81d 100644 --- a/src/pocketmine/permission/PermissionManager.php +++ b/src/pocketmine/permission/PermissionManager.php @@ -79,6 +79,8 @@ class PermissionManager{ /** * @param string|Permission $permission + * + * @return void */ public function removePermission($permission){ if($permission instanceof Permission){ @@ -103,6 +105,8 @@ class PermissionManager{ /** * @param Permission $permission + * + * @return void */ public function recalculatePermissionDefaults(Permission $permission){ if(isset($this->permissions[$permission->getName()])){ @@ -141,6 +145,8 @@ class PermissionManager{ /** * @param string $permission * @param Permissible $permissible + * + * @return void */ public function subscribeToPermission(string $permission, Permissible $permissible){ if(!isset($this->permSubs[$permission])){ @@ -152,6 +158,8 @@ class PermissionManager{ /** * @param string $permission * @param Permissible $permissible + * + * @return void */ public function unsubscribeFromPermission(string $permission, Permissible $permissible){ if(isset($this->permSubs[$permission])){ @@ -186,6 +194,8 @@ class PermissionManager{ /** * @param bool $op * @param Permissible $permissible + * + * @return void */ public function subscribeToDefaultPerms(bool $op, Permissible $permissible){ if($op){ @@ -198,6 +208,8 @@ class PermissionManager{ /** * @param bool $op * @param Permissible $permissible + * + * @return void */ public function unsubscribeFromDefaultPerms(bool $op, Permissible $permissible){ if($op){ diff --git a/src/pocketmine/permission/ServerOperator.php b/src/pocketmine/permission/ServerOperator.php index a31f67d00..98a24d247 100644 --- a/src/pocketmine/permission/ServerOperator.php +++ b/src/pocketmine/permission/ServerOperator.php @@ -36,6 +36,8 @@ interface ServerOperator{ * Sets the operator permission for the current object * * @param bool $value + * + * @return void */ public function setOp(bool $value); } From 31e8efa6d1a75055bec64f71e9f3e8e7bd53ad2b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 18:06:31 +0000 Subject: [PATCH 16/28] level/light: populate missing return type information --- src/pocketmine/level/light/LightUpdate.php | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/pocketmine/level/light/LightUpdate.php b/src/pocketmine/level/light/LightUpdate.php index a2c4bc45e..3fb90130c 100644 --- a/src/pocketmine/level/light/LightUpdate.php +++ b/src/pocketmine/level/light/LightUpdate.php @@ -59,8 +59,24 @@ abstract class LightUpdate{ abstract protected function getLight(int $x, int $y, int $z) : int; + /** + * @param int $x + * @param int $y + * @param int $z + * @param int $level + * + * @return void + */ abstract protected function setLight(int $x, int $y, int $z, int $level); + /** + * @param int $x + * @param int $y + * @param int $z + * @param int $newLevel + * + * @return void + */ public function setAndUpdateLight(int $x, int $y, int $z, int $newLevel){ $this->updateNodes[Level::blockHash($x, $y, $z)] = [$x, $y, $z, $newLevel]; } @@ -84,6 +100,9 @@ abstract class LightUpdate{ } } + /** + * @return void + */ public function execute(){ $this->prepareNodes(); @@ -137,6 +156,14 @@ abstract class LightUpdate{ } } + /** + * @param int $x + * @param int $y + * @param int $z + * @param int $oldAdjacentLevel + * + * @return void + */ protected function computeRemoveLight(int $x, int $y, int $z, int $oldAdjacentLevel){ $current = $this->getLight($x, $y, $z); @@ -157,6 +184,14 @@ abstract class LightUpdate{ } } + /** + * @param int $x + * @param int $y + * @param int $z + * @param int $newAdjacentLevel + * + * @return void + */ protected function computeSpreadLight(int $x, int $y, int $z, int $newAdjacentLevel){ $current = $this->getLight($x, $y, $z); $potentialLight = $newAdjacentLevel - BlockFactory::$lightFilter[$this->subChunkHandler->currentSubChunk->getBlockId($x & 0x0f, $y & 0x0f, $z & 0x0f)]; From aa7d55e21d88c1ea9593b43a1204ebf0ea7504b6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 18:07:54 +0000 Subject: [PATCH 17/28] level/generator: populate missing return type information --- .../level/generator/biome/BiomeSelector.php | 3 ++ .../level/generator/noise/Noise.php | 2 ++ .../level/generator/object/BigTree.php | 9 ++++++ .../level/generator/object/BirchTree.php | 9 ++++++ .../level/generator/object/OakTree.php | 9 ++++++ src/pocketmine/level/generator/object/Ore.php | 8 +++++ .../level/generator/object/Pond.php | 6 ++++ .../level/generator/object/SpruceTree.php | 9 ++++++ .../level/generator/object/TallGrass.php | 9 ++++++ .../level/generator/object/Tree.php | 29 +++++++++++++++++++ .../level/generator/populator/Ore.php | 2 ++ .../level/generator/populator/Pond.php | 15 ++++++++++ .../level/generator/populator/TallGrass.php | 4 +++ .../level/generator/populator/Tree.php | 4 +++ 14 files changed, 118 insertions(+) diff --git a/src/pocketmine/level/generator/biome/BiomeSelector.php b/src/pocketmine/level/generator/biome/BiomeSelector.php index ee7a85811..190877ba8 100644 --- a/src/pocketmine/level/generator/biome/BiomeSelector.php +++ b/src/pocketmine/level/generator/biome/BiomeSelector.php @@ -52,6 +52,9 @@ abstract class BiomeSelector{ */ abstract protected function lookup(float $temperature, float $rainfall) : int; + /** + * @return void + */ public function recalculate(){ $this->map = new \SplFixedArray(64 * 64); diff --git a/src/pocketmine/level/generator/noise/Noise.php b/src/pocketmine/level/generator/noise/Noise.php index 46a7f5059..66d781835 100644 --- a/src/pocketmine/level/generator/noise/Noise.php +++ b/src/pocketmine/level/generator/noise/Noise.php @@ -405,6 +405,8 @@ abstract class Noise{ * @param float $x * @param float $y * @param float $z + * + * @return void */ public function setOffset($x, $y, $z){ $this->offsetX = $x; diff --git a/src/pocketmine/level/generator/object/BigTree.php b/src/pocketmine/level/generator/object/BigTree.php index 4ccf9be56..63ad74e5b 100644 --- a/src/pocketmine/level/generator/object/BigTree.php +++ b/src/pocketmine/level/generator/object/BigTree.php @@ -35,6 +35,15 @@ class BigTree extends Tree{ return false; } + /** + * @param ChunkManager $level + * @param int $x + * @param int $y + * @param int $z + * @param Random $random + * + * @return void + */ public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){ } diff --git a/src/pocketmine/level/generator/object/BirchTree.php b/src/pocketmine/level/generator/object/BirchTree.php index c4e8ef023..7e75e230a 100644 --- a/src/pocketmine/level/generator/object/BirchTree.php +++ b/src/pocketmine/level/generator/object/BirchTree.php @@ -40,6 +40,15 @@ class BirchTree extends Tree{ $this->superBirch = $superBirch; } + /** + * @param ChunkManager $level + * @param int $x + * @param int $y + * @param int $z + * @param Random $random + * + * @return void + */ public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){ $this->treeHeight = $random->nextBoundedInt(3) + 5; if($this->superBirch){ diff --git a/src/pocketmine/level/generator/object/OakTree.php b/src/pocketmine/level/generator/object/OakTree.php index 47865de7e..ca3530d54 100644 --- a/src/pocketmine/level/generator/object/OakTree.php +++ b/src/pocketmine/level/generator/object/OakTree.php @@ -36,6 +36,15 @@ class OakTree extends Tree{ $this->type = Wood::OAK; } + /** + * @param ChunkManager $level + * @param int $x + * @param int $y + * @param int $z + * @param Random $random + * + * @return void + */ public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){ $this->treeHeight = $random->nextBoundedInt(3) + 4; parent::placeObject($level, $x, $y, $z, $random); diff --git a/src/pocketmine/level/generator/object/Ore.php b/src/pocketmine/level/generator/object/Ore.php index ad1f5da3c..711af8ca9 100644 --- a/src/pocketmine/level/generator/object/Ore.php +++ b/src/pocketmine/level/generator/object/Ore.php @@ -49,6 +49,14 @@ class Ore{ return $level->getBlockIdAt($x, $y, $z) === Block::STONE; } + /** + * @param ChunkManager $level + * @param int $x + * @param int $y + * @param int $z + * + * @return void + */ public function placeObject(ChunkManager $level, int $x, int $y, int $z){ $clusterSize = $this->type->clusterSize; $angle = $this->random->nextFloat() * M_PI; diff --git a/src/pocketmine/level/generator/object/Pond.php b/src/pocketmine/level/generator/object/Pond.php index 41af141f1..987fa7426 100644 --- a/src/pocketmine/level/generator/object/Pond.php +++ b/src/pocketmine/level/generator/object/Pond.php @@ -43,6 +43,12 @@ class Pond{ return false; } + /** + * @param ChunkManager $level + * @param Vector3 $pos + * + * @return void + */ public function placeObject(ChunkManager $level, Vector3 $pos){ } diff --git a/src/pocketmine/level/generator/object/SpruceTree.php b/src/pocketmine/level/generator/object/SpruceTree.php index 78a8578b8..e6ed799ce 100644 --- a/src/pocketmine/level/generator/object/SpruceTree.php +++ b/src/pocketmine/level/generator/object/SpruceTree.php @@ -39,6 +39,15 @@ class SpruceTree extends Tree{ $this->treeHeight = 10; } + /** + * @param ChunkManager $level + * @param int $x + * @param int $y + * @param int $z + * @param Random $random + * + * @return void + */ public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){ $this->treeHeight = $random->nextBoundedInt(4) + 6; diff --git a/src/pocketmine/level/generator/object/TallGrass.php b/src/pocketmine/level/generator/object/TallGrass.php index 695b879ad..ef591a617 100644 --- a/src/pocketmine/level/generator/object/TallGrass.php +++ b/src/pocketmine/level/generator/object/TallGrass.php @@ -31,6 +31,15 @@ use function count; class TallGrass{ + /** + * @param ChunkManager $level + * @param Vector3 $pos + * @param Random $random + * @param int $count + * @param int $radius + * + * @return void + */ public static function growGrass(ChunkManager $level, Vector3 $pos, Random $random, int $count = 15, int $radius = 10){ $arr = [ [Block::DANDELION, 0], diff --git a/src/pocketmine/level/generator/object/Tree.php b/src/pocketmine/level/generator/object/Tree.php index 30570feb6..743110386 100644 --- a/src/pocketmine/level/generator/object/Tree.php +++ b/src/pocketmine/level/generator/object/Tree.php @@ -49,6 +49,16 @@ abstract class Tree{ /** @var int */ public $treeHeight = 7; + /** + * @param ChunkManager $level + * @param int $x + * @param int $y + * @param int $z + * @param Random $random + * @param int $type + * + * @return void + */ public static function growTree(ChunkManager $level, int $x, int $y, int $z, Random $random, int $type = 0){ switch($type){ case Sapling::SPRUCE: @@ -100,6 +110,15 @@ abstract class Tree{ return true; } + /** + * @param ChunkManager $level + * @param int $x + * @param int $y + * @param int $z + * @param Random $random + * + * @return void + */ public function placeObject(ChunkManager $level, int $x, int $y, int $z, Random $random){ $this->placeTrunk($level, $x, $y, $z, $random, $this->treeHeight - 1); @@ -123,6 +142,16 @@ abstract class Tree{ } } + /** + * @param ChunkManager $level + * @param int $x + * @param int $y + * @param int $z + * @param Random $random + * @param int $trunkHeight + * + * @return void + */ protected function placeTrunk(ChunkManager $level, int $x, int $y, int $z, Random $random, int $trunkHeight){ // The base dirt block $level->setBlockIdAt($x, $y - 1, $z, Block::DIRT); diff --git a/src/pocketmine/level/generator/populator/Ore.php b/src/pocketmine/level/generator/populator/Ore.php index a5b472fa5..a2d962c17 100644 --- a/src/pocketmine/level/generator/populator/Ore.php +++ b/src/pocketmine/level/generator/populator/Ore.php @@ -48,6 +48,8 @@ class Ore extends Populator{ /** * @param OreType[] $types + * + * @return void */ public function setOreTypes(array $types){ $this->oreTypes = $types; diff --git a/src/pocketmine/level/generator/populator/Pond.php b/src/pocketmine/level/generator/populator/Pond.php index 48b40a5e8..4cac52973 100644 --- a/src/pocketmine/level/generator/populator/Pond.php +++ b/src/pocketmine/level/generator/populator/Pond.php @@ -49,14 +49,29 @@ class Pond extends Populator{ } } + /** + * @param int $waterOdd + * + * @return void + */ public function setWaterOdd(int $waterOdd){ $this->waterOdd = $waterOdd; } + /** + * @param int $lavaOdd + * + * @return void + */ public function setLavaOdd(int $lavaOdd){ $this->lavaOdd = $lavaOdd; } + /** + * @param int $lavaSurfaceOdd + * + * @return void + */ public function setLavaSurfaceOdd(int $lavaSurfaceOdd){ $this->lavaSurfaceOdd = $lavaSurfaceOdd; } diff --git a/src/pocketmine/level/generator/populator/TallGrass.php b/src/pocketmine/level/generator/populator/TallGrass.php index 5c110ead9..020fb9a11 100644 --- a/src/pocketmine/level/generator/populator/TallGrass.php +++ b/src/pocketmine/level/generator/populator/TallGrass.php @@ -37,6 +37,8 @@ class TallGrass extends Populator{ /** * @param int $amount + * + * @return void */ public function setRandomAmount($amount){ $this->randomAmount = $amount; @@ -44,6 +46,8 @@ class TallGrass extends Populator{ /** * @param int $amount + * + * @return void */ public function setBaseAmount($amount){ $this->baseAmount = $amount; diff --git a/src/pocketmine/level/generator/populator/Tree.php b/src/pocketmine/level/generator/populator/Tree.php index 93763c888..c5a44fad7 100644 --- a/src/pocketmine/level/generator/populator/Tree.php +++ b/src/pocketmine/level/generator/populator/Tree.php @@ -49,6 +49,8 @@ class Tree extends Populator{ /** * @param int $amount + * + * @return void */ public function setRandomAmount($amount){ $this->randomAmount = $amount; @@ -56,6 +58,8 @@ class Tree extends Populator{ /** * @param int $amount + * + * @return void */ public function setBaseAmount($amount){ $this->baseAmount = $amount; From cd36af46bf7d9910369c07ec9d76ecea31903c03 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 18:44:41 +0000 Subject: [PATCH 18/28] Level: populate missing type information --- src/pocketmine/level/Level.php | 183 ++++++++++++++++++++++++++++++++- 1 file changed, 179 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 462d4c454..6ecf561f5 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -435,6 +435,8 @@ class Level implements ChunkManager, Metadatable{ /** * @deprecated does nothing * @param int $tickRate + * + * @return void */ public function setTickRate(int $tickRate){ @@ -445,6 +447,9 @@ class Level implements ChunkManager, Metadatable{ $this->server->getAsyncPool()->submitTaskToWorker(new GeneratorRegisterTask($this, $this->generator, $this->provider->getGeneratorOptions()), $worker); } + /** + * @return void + */ public function unregisterGenerator(){ $pool = $this->server->getAsyncPool(); foreach($pool->getRunningWorkers() as $i){ @@ -478,6 +483,9 @@ class Level implements ChunkManager, Metadatable{ return $this->closed; } + /** + * @return void + */ public function close(){ if($this->closed){ throw new \InvalidStateException("Tried to close a world which is already closed"); @@ -500,6 +508,12 @@ class Level implements ChunkManager, Metadatable{ $this->closed = true; } + /** + * @param Sound $sound + * @param Player[]|null $players + * + * @return void + */ public function addSound(Sound $sound, array $players = null){ $pk = $sound->encode(); if(!is_array($pk)){ @@ -516,6 +530,12 @@ class Level implements ChunkManager, Metadatable{ } } + /** + * @param Particle $particle + * @param Player[]|null $players + * + * @return void + */ public function addParticle(Particle $particle, array $players = null){ $pk = $particle->encode(); if(!is_array($pk)){ @@ -538,6 +558,8 @@ class Level implements ChunkManager, Metadatable{ * @param Vector3|null $pos If null, broadcasts to every player in the Level * @param int $evid * @param int $data + * + * @return void */ public function broadcastLevelEvent(?Vector3 $pos, int $evid, int $data = 0){ $pk = new LevelEventPacket(); @@ -561,6 +583,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $entityTypeId * @param bool $isBabyMob * @param bool $disableRelativeVolume If true, all players receiving this sound-event will hear the sound at full volume regardless of distance + * + * @return void */ public function broadcastLevelSoundEvent(Vector3 $pos, int $soundId, int $extraData = -1, int $entityTypeId = -1, bool $isBabyMob = false, bool $disableRelativeVolume = false){ $pk = new LevelSoundEventPacket(); @@ -577,6 +601,11 @@ class Level implements ChunkManager, Metadatable{ return $this->autoSave; } + /** + * @param bool $value + * + * @return void + */ public function setAutoSave(bool $value){ $this->autoSave = $value; } @@ -674,6 +703,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $chunkX * @param int $chunkZ * @param DataPacket $packet + * + * @return void */ public function addChunkPacket(int $chunkX, int $chunkZ, DataPacket $packet){ if(!isset($this->chunkPackets[$index = Level::chunkHash($chunkX, $chunkZ)])){ @@ -712,6 +743,14 @@ class Level implements ChunkManager, Metadatable{ $this->globalPackets[] = $packet; } + /** + * @param ChunkLoader $loader + * @param int $chunkX + * @param int $chunkZ + * @param bool $autoLoad + * + * @return void + */ public function registerChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ, bool $autoLoad = true){ $loaderId = $loader->getLoaderId(); @@ -741,6 +780,13 @@ class Level implements ChunkManager, Metadatable{ } } + /** + * @param ChunkLoader $loader + * @param int $chunkX + * @param int $chunkZ + * + * @return void + */ public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){ $chunkHash = Level::chunkHash($chunkX, $chunkZ); $loaderId = $loader->getLoaderId(); @@ -764,6 +810,8 @@ class Level implements ChunkManager, Metadatable{ * @internal * * @param Player ...$targets If empty, will send to all players in the level. + * + * @return void */ public function sendTime(Player ...$targets){ $pk = new SetTimePacket(); @@ -777,6 +825,7 @@ class Level implements ChunkManager, Metadatable{ * * @param int $currentTick * + * @return void */ public function doTick(int $currentTick){ if($this->closed){ @@ -929,6 +978,9 @@ class Level implements ChunkManager, Metadatable{ $this->chunkPackets = []; } + /** + * @return void + */ public function checkSleep(){ if(count($this->players) === 0){ return; @@ -964,6 +1016,8 @@ class Level implements ChunkManager, Metadatable{ * @param Vector3[] $blocks * @param int $flags * @param bool $optimizeRebuilds + * + * @return void */ public function sendBlocks(array $target, array $blocks, int $flags = UpdateBlockPacket::FLAG_NONE, bool $optimizeRebuilds = false){ $packets = []; @@ -1023,6 +1077,11 @@ class Level implements ChunkManager, Metadatable{ $this->server->batchPackets($target, $packets, false, false); } + /** + * @param bool $force + * + * @return void + */ public function clearCache(bool $force = false){ if($force){ $this->chunkCache = []; @@ -1039,6 +1098,12 @@ class Level implements ChunkManager, Metadatable{ } } + /** + * @param int $chunkX + * @param int $chunkZ + * + * @return void + */ public function clearChunkCache(int $chunkX, int $chunkZ){ unset($this->chunkCache[Level::chunkHash($chunkX, $chunkZ)]); } @@ -1047,15 +1112,25 @@ class Level implements ChunkManager, Metadatable{ return $this->randomTickBlocks; } + /** + * @param int $id + * + * @return void + */ public function addRandomTickedBlock(int $id){ $this->randomTickBlocks[$id] = BlockFactory::get($id); } + /** + * @param int $id + * + * @return void + */ public function removeRandomTickedBlock(int $id){ $this->randomTickBlocks[$id] = null; } - private function tickChunks(){ + private function tickChunks() : void{ if($this->chunksPerTick <= 0 or count($this->loaders) === 0){ $this->chunkTickList = []; return; @@ -1163,6 +1238,9 @@ class Level implements ChunkManager, Metadatable{ return true; } + /** + * @return void + */ public function saveChunks(){ $this->timings->syncChunkSaveTimer->startTiming(); try{ @@ -1183,6 +1261,8 @@ class Level implements ChunkManager, Metadatable{ * * @param Vector3 $pos * @param int $delay + * + * @return void */ public function scheduleDelayedBlockUpdate(Vector3 $pos, int $delay){ if( @@ -1200,6 +1280,8 @@ class Level implements ChunkManager, Metadatable{ * Blocks will be updated with the normal update type. * * @param Vector3 $pos + * + * @return void */ public function scheduleNeighbourBlockUpdates(Vector3 $pos){ $pos = $pos->floor(); @@ -1491,6 +1573,11 @@ class Level implements ChunkManager, Metadatable{ return $block; } + /** + * @param Vector3 $pos + * + * @return void + */ public function updateAllLight(Vector3 $pos){ $this->updateBlockSkyLight($pos->x, $pos->y, $pos->z); $this->updateBlockLight($pos->x, $pos->y, $pos->z); @@ -1516,6 +1603,13 @@ class Level implements ChunkManager, Metadatable{ ]); } + /** + * @param int $x + * @param int $y + * @param int $z + * + * @return void + */ public function updateBlockSkyLight(int $x, int $y, int $z){ $this->timings->doBlockSkyLightUpdates->startTiming(); @@ -1576,6 +1670,13 @@ class Level implements ChunkManager, Metadatable{ ]); } + /** + * @param int $x + * @param int $y + * @param int $z + * + * @return void + */ public function updateBlockLight(int $x, int $y, int $z){ $this->timings->doBlockLightUpdates->startTiming(); @@ -2242,6 +2343,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $y * @param int $z * @param int $id 0-255 + * + * @return void */ public function setBlockIdAt(int $x, int $y, int $z, int $id){ if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :( @@ -2281,6 +2384,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $y * @param int $z * @param int $data 0-15 + * + * @return void */ public function setBlockDataAt(int $x, int $y, int $z, int $data){ if(!$this->isInWorld($x, $y, $z)){ //TODO: bad hack but fixing this requires BC breaks to do properly :( @@ -2321,6 +2426,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $y * @param int $z * @param int $level 0-15 + * + * @return void */ public function setBlockSkyLightAt(int $x, int $y, int $z, int $level){ $this->getChunk($x >> 4, $z >> 4, true)->setBlockSkyLight($x & 0x0f, $y, $z & 0x0f, $level & 0x0f); @@ -2346,6 +2453,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $y * @param int $z * @param int $level 0-15 + * + * @return void */ public function setBlockLightAt(int $x, int $y, int $z, int $level){ $this->getChunk($x >> 4, $z >> 4, true)->setBlockLight($x & 0x0f, $y, $z & 0x0f, $level & 0x0f); @@ -2375,6 +2484,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $x * @param int $z * @param int $biomeId + * + * @return void */ public function setBiomeId(int $x, int $z, int $biomeId){ $this->getChunk($x >> 4, $z >> 4, true)->setBiomeId($x & 0x0f, $z & 0x0f, $biomeId); @@ -2394,6 +2505,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $x * @param int $z * @param int $value + * + * @return void */ public function setHeightMap(int $x, int $z, int $value){ $this->getChunk($x >> 4, $z >> 4, true)->setHeightMap($x & 0x0f, $z & 0x0f, $value); @@ -2461,6 +2574,13 @@ class Level implements ChunkManager, Metadatable{ return $result; } + /** + * @param int $x + * @param int $z + * @param Chunk|null $chunk + * + * @return void + */ public function generateChunkCallback(int $x, int $z, ?Chunk $chunk){ Timings::$generationCallbackTimer->startTiming(); if(isset($this->chunkPopulationQueue[$index = Level::chunkHash($x, $z)])){ @@ -2498,6 +2618,8 @@ class Level implements ChunkManager, Metadatable{ * @param int $chunkZ * @param Chunk|null $chunk * @param bool $deleteEntitiesAndTiles Whether to delete entities and tiles on the old chunk, or transfer them to the new one + * + * @return void */ public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null, bool $deleteEntitiesAndTiles = true){ if($chunk === null){ @@ -2623,6 +2745,8 @@ class Level implements ChunkManager, Metadatable{ * Sets the level spawn location * * @param Vector3 $pos + * + * @return void */ public function setSpawnLocation(Vector3 $pos){ $previousSpawn = $this->getSpawnLocation(); @@ -2630,6 +2754,13 @@ class Level implements ChunkManager, Metadatable{ (new SpawnChangeEvent($this, $previousSpawn))->call(); } + /** + * @param int $x + * @param int $z + * @param Player $player + * + * @return void + */ public function requestChunk(int $x, int $z, Player $player){ $index = Level::chunkHash($x, $z); if(!isset($this->chunkSendQueue[$index])){ @@ -2639,7 +2770,7 @@ class Level implements ChunkManager, Metadatable{ $this->chunkSendQueue[$index][$player->getLoaderId()] = $player; } - private function sendChunkFromCache(int $x, int $z){ + private function sendChunkFromCache(int $x, int $z) : void{ if(isset($this->chunkSendQueue[$index = Level::chunkHash($x, $z)])){ foreach($this->chunkSendQueue[$index] as $player){ /** @var Player $player */ @@ -2651,7 +2782,7 @@ class Level implements ChunkManager, Metadatable{ } } - private function processChunkRequest(){ + private function processChunkRequest() : void{ if(count($this->chunkSendQueue) > 0){ $this->timings->syncChunkSendTimer->startTiming(); @@ -2689,6 +2820,13 @@ class Level implements ChunkManager, Metadatable{ } } + /** + * @param int $x + * @param int $z + * @param BatchPacket $payload + * + * @return void + */ public function chunkRequestCallback(int $x, int $z, BatchPacket $payload){ $this->timings->syncChunkSendTimer->startTiming(); @@ -2707,6 +2845,7 @@ class Level implements ChunkManager, Metadatable{ /** * @param Entity $entity * + * @return void * @throws LevelException */ public function addEntity(Entity $entity){ @@ -2728,6 +2867,7 @@ class Level implements ChunkManager, Metadatable{ * * @param Entity $entity * + * @return void * @throws LevelException */ public function removeEntity(Entity $entity){ @@ -2747,6 +2887,7 @@ class Level implements ChunkManager, Metadatable{ /** * @param Tile $tile * + * @return void * @throws LevelException */ public function addTile(Tile $tile){ @@ -2773,6 +2914,7 @@ class Level implements ChunkManager, Metadatable{ /** * @param Tile $tile * + * @return void * @throws LevelException */ public function removeTile(Tile $tile){ @@ -2868,11 +3010,18 @@ class Level implements ChunkManager, Metadatable{ return true; } - private function queueUnloadChunk(int $x, int $z){ + private function queueUnloadChunk(int $x, int $z) : void{ $this->unloadQueue[$index = Level::chunkHash($x, $z)] = microtime(true); unset($this->chunkTickList[$index]); } + /** + * @param int $x + * @param int $z + * @param bool $safe + * + * @return bool + */ public function unloadChunkRequest(int $x, int $z, bool $safe = true){ if(($safe and $this->isChunkInUse($x, $z)) or $this->isSpawnChunk($x, $z)){ return false; @@ -2883,6 +3032,12 @@ class Level implements ChunkManager, Metadatable{ return true; } + /** + * @param int $x + * @param int $z + * + * @return void + */ public function cancelUnloadChunkRequest(int $x, int $z){ unset($this->unloadQueue[Level::chunkHash($x, $z)]); } @@ -3034,6 +3189,8 @@ class Level implements ChunkManager, Metadatable{ * Sets the current time on the level * * @param int $time + * + * @return void */ public function setTime(int $time){ $this->time = $time; @@ -3042,6 +3199,8 @@ class Level implements ChunkManager, Metadatable{ /** * Stops the time for the level, will not save the lock state to disk + * + * @return void */ public function stopTime(){ $this->stopTime = true; @@ -3050,6 +3209,8 @@ class Level implements ChunkManager, Metadatable{ /** * Start the time again, if it was stopped + * + * @return void */ public function startTime(){ $this->stopTime = false; @@ -3069,6 +3230,8 @@ class Level implements ChunkManager, Metadatable{ * Sets the seed for the level * * @param int $seed + * + * @return void */ public function setSeed(int $seed){ $this->provider->setSeed($seed); @@ -3087,6 +3250,8 @@ class Level implements ChunkManager, Metadatable{ /** * @param int $difficulty + * + * @return void */ public function setDifficulty(int $difficulty){ if($difficulty < 0 or $difficulty > 3){ @@ -3099,6 +3264,8 @@ class Level implements ChunkManager, Metadatable{ /** * @param Player ...$targets + * + * @return void */ public function sendDifficulty(Player ...$targets){ if(count($targets) === 0){ @@ -3147,6 +3314,9 @@ class Level implements ChunkManager, Metadatable{ return true; } + /** + * @return void + */ public function doChunkGarbageCollection(){ $this->timings->doChunkGC->startTiming(); @@ -3165,6 +3335,11 @@ class Level implements ChunkManager, Metadatable{ $this->timings->doChunkGC->stopTiming(); } + /** + * @param bool $force + * + * @return void + */ public function unloadChunks(bool $force = false){ if(count($this->unloadQueue) > 0){ $maxUnload = 96; From bd4a63b6682fef0c8af5b4af5c277a80bf2e45e3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:09:08 +0000 Subject: [PATCH 19/28] Server: populate missing return type information --- src/pocketmine/Server.php | 100 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 97 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index ad065b05f..aa38b4996 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -483,6 +483,8 @@ class Server{ /** * @param bool $value + * + * @return void */ public function setAutoSave(bool $value){ $this->autoSave = $value; @@ -874,6 +876,8 @@ class Server{ /** * @param string $name * @param CompoundTag $nbtTag + * + * @return void */ public function saveOfflinePlayerData(string $name, CompoundTag $nbtTag){ $ev = new PlayerDataSaveEvent($nbtTag, $name); @@ -1277,6 +1281,8 @@ class Server{ /** * @param string $variable * @param string $value + * + * @return void */ public function setConfigString(string $variable, string $value){ $this->properties->set($variable, $value); @@ -1300,6 +1306,8 @@ class Server{ /** * @param string $variable * @param int $value + * + * @return void */ public function setConfigInt(string $variable, int $value){ $this->properties->set($variable, $value); @@ -1336,6 +1344,8 @@ class Server{ /** * @param string $variable * @param bool $value + * + * @return void */ public function setConfigBool(string $variable, bool $value){ $this->properties->set($variable, $value ? "1" : "0"); @@ -1370,6 +1380,8 @@ class Server{ /** * @param string $name + * + * @return void */ public function addOp(string $name){ $this->operators->set(strtolower($name), true); @@ -1382,6 +1394,8 @@ class Server{ /** * @param string $name + * + * @return void */ public function removeOp(string $name){ $this->operators->remove(strtolower($name)); @@ -1394,6 +1408,8 @@ class Server{ /** * @param string $name + * + * @return void */ public function addWhitelist(string $name){ $this->whitelist->set(strtolower($name), true); @@ -1402,6 +1418,8 @@ class Server{ /** * @param string $name + * + * @return void */ public function removeWhitelist(string $name){ $this->whitelist->remove(strtolower($name)); @@ -1440,6 +1458,9 @@ class Server{ return $this->operators; } + /** + * @return void + */ public function reloadWhitelist(){ $this->whitelist->reload(); } @@ -1476,6 +1497,11 @@ class Server{ return self::$instance; } + /** + * @param int $microseconds + * + * @return void + */ public static function microSleep(int $microseconds){ Server::$sleeper->synchronized(function(int $ms){ Server::$sleeper->wait($ms); @@ -1913,6 +1939,8 @@ class Server{ * * @param Player[] $players * @param DataPacket $packet + * + * @return void */ public function broadcastPacket(array $players, DataPacket $packet){ $packet->encode(); @@ -1926,6 +1954,8 @@ class Server{ * @param DataPacket[] $packets * @param bool $forceSync * @param bool $immediate + * + * @return void */ public function batchPackets(array $players, array $packets, bool $forceSync = false, bool $immediate = false){ if(count($packets) === 0){ @@ -1964,6 +1994,8 @@ class Server{ * @param BatchPacket $pk * @param Player[] $players * @param bool $immediate + * + * @return void */ public function broadcastPacketsCallback(BatchPacket $pk, array $players, bool $immediate = false){ if(!$pk->isEncoded){ @@ -1978,6 +2010,8 @@ class Server{ /** * @param int $type + * + * @return void */ public function enablePlugins(int $type){ foreach($this->pluginManager->getPlugins() as $plugin){ @@ -1994,11 +2028,16 @@ class Server{ /** * @param Plugin $plugin + * + * @return void */ public function enablePlugin(Plugin $plugin){ $this->pluginManager->enablePlugin($plugin); } + /** + * @return void + */ public function disablePlugins(){ $this->pluginManager->disablePlugins(); } @@ -2033,6 +2072,9 @@ class Server{ return false; } + /** + * @return void + */ public function reload(){ $this->logger->info("Saving worlds..."); @@ -2072,11 +2114,16 @@ class Server{ /** * Shuts the server down correctly + * + * @return void */ public function shutdown(){ $this->isRunning = false; } + /** + * @return void + */ public function forceShutdown(){ if($this->hasStopped){ return; @@ -2162,7 +2209,7 @@ class Server{ /** * Starts the PocketMine-MP server and starts processing ticks and packets */ - private function start(){ + private function start() : void{ if($this->getConfigBool("enable-query", true)){ $this->queryHandler = new QueryHandler(); } @@ -2206,6 +2253,8 @@ class Server{ /** * @param int $signo + * + * @return void */ public function handleSignal($signo){ if($signo === SIGTERM or $signo === SIGINT or $signo === SIGHUP){ @@ -2216,6 +2265,8 @@ class Server{ /** * @param \Throwable $e * @param array|null $trace + * + * @return void */ public function exceptionHandler(\Throwable $e, $trace = null){ while(@ob_end_flush()){} @@ -2334,6 +2385,9 @@ class Server{ exit(1); } + /** + * @return mixed[] + */ public function __debugInfo(){ return []; } @@ -2342,7 +2396,7 @@ class Server{ return $this->tickSleeper; } - private function tickProcessor(){ + private function tickProcessor() : void{ $this->nextTick = microtime(true); while($this->isRunning){ @@ -2353,6 +2407,11 @@ class Server{ } } + /** + * @param Player $player + * + * @return void + */ public function onPlayerLogin(Player $player){ if($this->sendUsageTicker > 0){ $this->uniquePlayers[$player->getRawUniqueId()] = $player->getRawUniqueId(); @@ -2361,27 +2420,49 @@ class Server{ $this->loggedInPlayers[$player->getRawUniqueId()] = $player; } + /** + * @param Player $player + * + * @return void + */ public function onPlayerLogout(Player $player){ unset($this->loggedInPlayers[$player->getRawUniqueId()]); } + /** + * @param Player $player + * + * @return void + */ public function addPlayer(Player $player){ $this->players[spl_object_hash($player)] = $player; } /** * @param Player $player + * + * @return void */ public function removePlayer(Player $player){ unset($this->players[spl_object_hash($player)]); } + /** + * @param Player $player + * + * @return void + */ public function addOnlinePlayer(Player $player){ $this->updatePlayerListData($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkin(), $player->getXuid()); $this->playerList[$player->getRawUniqueId()] = $player; } + /** + * @param Player $player + * + * @return void + */ public function removeOnlinePlayer(Player $player){ if(isset($this->playerList[$player->getRawUniqueId()])){ unset($this->playerList[$player->getRawUniqueId()]); @@ -2397,6 +2478,8 @@ class Server{ * @param Skin $skin * @param string $xboxUserId * @param Player[]|null $players + * + * @return void */ public function updatePlayerListData(UUID $uuid, int $entityId, string $name, Skin $skin, string $xboxUserId = "", array $players = null){ $pk = new PlayerListPacket(); @@ -2410,6 +2493,8 @@ class Server{ /** * @param UUID $uuid * @param Player[]|null $players + * + * @return void */ public function removePlayerListData(UUID $uuid, array $players = null){ $pk = new PlayerListPacket(); @@ -2420,6 +2505,8 @@ class Server{ /** * @param Player $p + * + * @return void */ public function sendFullPlayerListData(Player $p){ $pk = new PlayerListPacket(); @@ -2455,6 +2542,9 @@ class Server{ } } + /** + * @return void + */ public function doAutoSave(){ if($this->getAutoSave()){ Timings::$worldSaveTimer->startTiming(); @@ -2475,6 +2565,8 @@ class Server{ /** * @param int $type + * + * @return void */ public function sendUsage($type = SendUsageTask::TYPE_STATUS){ if((bool) $this->getProperty("anonymous-statistics.enabled", true)){ @@ -2512,7 +2604,7 @@ class Server{ return $this->memoryManager; } - private function titleTick(){ + private function titleTick() : void{ Timings::$titleTickTimer->startTiming(); $d = Utils::getRealMemoryUsage(); @@ -2537,6 +2629,8 @@ class Server{ * @param int $port * @param string $payload * + * @return void + * * TODO: move this to Network */ public function handlePacket(AdvancedSourceInterface $interface, string $address, int $port, string $payload){ From 2c11742f9ef9489f3a4de45e6aef6d29031cab19 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:16:38 +0000 Subject: [PATCH 20/28] Player: populate missing type information --- src/pocketmine/Player.php | 164 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 6cc03ce1e..4b0cfbefe 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -476,6 +476,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return $this->playedBefore; } + /** + * @param bool $value + * + * @return void + */ public function setAllowFlight(bool $value){ $this->allowFlight = $value; $this->sendSettings(); @@ -485,6 +490,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return $this->allowFlight; } + /** + * @param bool $value + * + * @return void + */ public function setFlying(bool $value){ if($this->flying !== $value){ $this->flying = $value; @@ -497,6 +507,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return $this->flying; } + /** + * @param bool $value + * + * @return void + */ public function setAutoJump(bool $value){ $this->autoJump = $value; $this->sendSettings(); @@ -510,6 +525,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return $this->allowMovementCheats; } + /** + * @param bool $value + * + * @return void + */ public function setAllowMovementCheats(bool $value = true){ $this->allowMovementCheats = $value; } @@ -539,6 +559,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param bool $remove + * + * @return void */ public function setRemoveFormat(bool $remove = true){ $this->removeFormat = $remove; @@ -566,6 +588,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param Player $player + * + * @return void */ public function hidePlayer(Player $player){ if($player === $this){ @@ -577,6 +601,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param Player $player + * + * @return void */ public function showPlayer(Player $player){ if($player === $this){ @@ -605,6 +631,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return $this->viewDistance; } + /** + * @param int $distance + * + * @return void + */ public function setViewDistance(int $distance){ $this->viewDistance = $this->server->getAllowedViewDistance($distance); @@ -635,6 +666,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param bool $value + * + * @return void */ public function setOp(bool $value){ if($value === $this->isOp()){ @@ -686,6 +719,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param PermissionAttachment $attachment + * + * @return void */ public function removeAttachment(PermissionAttachment $attachment){ $this->perm->removeAttachment($attachment); @@ -721,6 +756,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return $this->perm->getEffectivePermissions(); } + /** + * @return void + */ public function sendCommandData(){ $pk = new AvailableCommandsPacket(); foreach($this->server->getCommandMap()->getCommands() as $name => $command){ @@ -818,6 +856,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param string $name + * + * @return void */ public function setDisplayName(string $name){ $this->displayName = $name; @@ -903,6 +943,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * @internal Plugins should not use this method. * * @param int $pingMS + * + * @return void */ public function updatePing(int $pingMS){ $this->lastPingMeasure = $pingMS; @@ -927,6 +969,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return $this->getGenericFlag(self::DATA_FLAG_ACTION) and $this->startAction > -1; } + /** + * @param bool $value + * + * @return void + */ public function setUsingItem(bool $value){ $this->startAction = $value ? $this->server->getTick() : -1; $this->setGenericFlag(self::DATA_FLAG_ACTION, $value); @@ -996,6 +1043,13 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return false; } + /** + * @param int $x + * @param int $z + * @param Level|null $level + * + * @return void + */ protected function unloadChunk(int $x, int $z, Level $level = null){ $level = $level ?? $this->level; $index = Level::chunkHash($x, $z); @@ -1012,6 +1066,13 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ unset($this->loadQueue[$index]); } + /** + * @param int $x + * @param int $z + * @param BatchPacket $payload + * + * @return void + */ public function sendChunk(int $x, int $z, BatchPacket $payload){ if(!$this->isConnected()){ return; @@ -1034,6 +1095,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } + /** + * @return void + */ protected function sendNextChunk(){ if(!$this->isConnected()){ return; @@ -1068,6 +1132,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ Timings::$playerChunkSendTimer->stopTiming(); } + /** + * @return void + */ public function doFirstSpawn(){ if($this->spawned){ return; //avoid player spawning twice (this can only happen on 3.x with a custom malicious client) @@ -1117,6 +1184,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } + /** + * @param Vector3 $pos + * @param int $respawnState + * + * @return void + */ protected function sendRespawnPacket(Vector3 $pos, int $respawnState = RespawnPacket::SEARCHING_FOR_SPAWN){ $pk = new RespawnPacket(); $pk->position = $pos->add(0, $this->baseOffset, 0); @@ -1246,6 +1319,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * Position object * * @param Vector3|Position $pos + * + * @return void */ public function setSpawn(Vector3 $pos){ if(!($pos instanceof Position)){ @@ -1305,6 +1380,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return true; } + /** + * @return void + */ public function stopSleep(){ if($this->sleeping instanceof Vector3){ $b = $this->level->getBlock($this->sleeping); @@ -1368,6 +1446,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param string $achievementId + * + * @return void */ public function removeAchievement(string $achievementId){ if($this->hasAchievement($achievementId)){ @@ -1456,6 +1536,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @internal * Sends the player's gamemode to the client. + * + * @return void */ public function sendGamemode(){ $pk = new SetPlayerGameTypePacket(); @@ -1465,6 +1547,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * Sends all the option flags + * + * @return void */ public function sendSettings(){ $pk = new AdventureSettingsPacket(); @@ -1570,6 +1654,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return false; //currently has no server-side movement } + /** + * @return void + */ protected function checkNearEntities(){ foreach($this->level->getNearbyEntities($this->boundingBox->expandedCopy(1, 0.5, 1), $this) as $entity){ $entity->scheduleUpdate(); @@ -1582,6 +1669,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } + /** + * @param int $tickDiff + * + * @return void + */ protected function processMovement(int $tickDiff){ if(!$this->isAlive() or !$this->spawned or $this->newPosition === null or $this->isSleeping()){ return; @@ -1724,6 +1816,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } + /** + * @param bool $sendAll + * + * @return void + */ public function sendAttributes(bool $sendAll = false){ $entries = $sendAll ? $this->attributeMap->getAll() : $this->attributeMap->needSend(); if(count($entries) > 0){ @@ -1829,6 +1926,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->dataPacket($pk); } + /** + * @return void + */ public function checkNetwork(){ if(!$this->isOnline()){ return; @@ -1977,6 +2077,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return true; } + /** + * @param int $status + * @param bool $immediate + * + * @return void + */ public function sendPlayStatus(int $status, bool $immediate = false){ $pk = new PlayStatusPacket(); $pk->status = $status; @@ -2020,6 +2126,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->processLogin(); } + /** + * @return void + */ protected function processLogin(){ foreach($this->server->getLoggedInPlayers() as $p){ if($p !== $this and ($p->iusername === $this->iusername or $this->getUniqueId()->equals($p->getUniqueId()))){ @@ -2136,6 +2245,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return true; } + /** + * @return void + */ protected function completeLoginSequence(){ /** @var float[] $pos */ $pos = $this->namedtag->getListTag("Pos")->getAllValues(); @@ -3156,6 +3268,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * Called when a packet is received from the client. This method will call DataPacketReceiveEvent. * * @param DataPacket $packet + * + * @return void */ public function handleDataPacket(DataPacket $packet){ if($this->sessionAdapter !== null){ @@ -3313,6 +3427,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * @param int $fadeIn Duration in ticks for fade-in. If -1 is given, client-sided defaults will be used. * @param int $stay Duration in ticks to stay on screen for * @param int $fadeOut Duration in ticks for fade-out. + * + * @return void */ public function addTitle(string $title, string $subtitle = "", int $fadeIn = -1, int $stay = -1, int $fadeOut = -1){ $this->setTitleDuration($fadeIn, $stay, $fadeOut); @@ -3326,6 +3442,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * Sets the subtitle message, without sending a title. * * @param string $subtitle + * + * @return void */ public function addSubTitle(string $subtitle){ $this->sendTitleText($subtitle, SetTitlePacket::TYPE_SET_SUBTITLE); @@ -3335,6 +3453,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * Adds small text to the user's screen. * * @param string $message + * + * @return void */ public function addActionBarMessage(string $message){ $this->sendTitleText($message, SetTitlePacket::TYPE_SET_ACTIONBAR_MESSAGE); @@ -3342,6 +3462,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * Removes the title from the client's screen. + * + * @return void */ public function removeTitles(){ $pk = new SetTitlePacket(); @@ -3351,6 +3473,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * Resets the title duration settings to defaults and removes any existing titles. + * + * @return void */ public function resetTitles(){ $pk = new SetTitlePacket(); @@ -3364,6 +3488,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * @param int $fadeIn Title fade-in time in ticks. * @param int $stay Title stay time in ticks. * @param int $fadeOut Title fade-out time in ticks. + * + * @return void */ public function setTitleDuration(int $fadeIn, int $stay, int $fadeOut){ if($fadeIn >= 0 and $stay >= 0 and $fadeOut >= 0){ @@ -3381,6 +3507,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * * @param string $title * @param int $type + * + * @return void */ protected function sendTitleText(string $title, int $type){ $pk = new SetTitlePacket(); @@ -3393,6 +3521,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * Sends a direct chat message to a player * * @param TextContainer|string $message + * + * @return void */ public function sendMessage($message){ if($message instanceof TextContainer){ @@ -3412,6 +3542,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param string $message * @param string[] $parameters + * + * @return void */ public function sendTranslation(string $message, array $parameters = []){ $pk = new TextPacket(); @@ -3437,6 +3569,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * * @param string $message * @param string $subtitle @deprecated + * + * @return void */ public function sendPopup(string $message, string $subtitle = ""){ $pk = new TextPacket(); @@ -3445,6 +3579,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ $this->dataPacket($pk); } + /** + * @param string $message + * + * @return void + */ public function sendTip(string $message){ $pk = new TextPacket(); $pk->type = TextPacket::TYPE_TIP; @@ -3455,6 +3594,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ /** * @param string $sender * @param string $message + * + * @return void */ public function sendWhisper(string $sender, string $message){ $pk = new TextPacket(); @@ -3596,6 +3737,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } + /** + * @return mixed[] + */ public function __debugInfo(){ return []; } @@ -3612,6 +3756,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * Handles player data saving * * @throws \InvalidStateException if the player is closed + * + * @return void */ public function save(){ if($this->closed){ @@ -3774,6 +3920,15 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return $result; } + /** + * @param Vector3 $pos + * @param float|null $yaw + * @param float|null $pitch + * @param int $mode + * @param Player[]|null $targets + * + * @return void + */ public function sendPosition(Vector3 $pos, float $yaw = null, float $pitch = null, int $mode = MovePlayerPacket::MODE_NORMAL, array $targets = null){ $yaw = $yaw ?? $this->yaw; $pitch = $pitch ?? $this->pitch; @@ -3825,6 +3980,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ return false; } + /** + * @return void + */ protected function addDefaultWindows(){ $this->addWindow($this->getInventory(), ContainerIds::INVENTORY, true); @@ -3950,6 +4108,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * @param Inventory $inventory * @param bool $force Forces removal of permanent windows such as normal inventory, cursor * + * @return void * @throws \InvalidArgumentException if trying to remove a fixed inventory window without the `force` parameter as true */ public function removeWindow(Inventory $inventory, bool $force = false){ @@ -3969,6 +4128,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ * Removes all inventory windows from the player. By default this WILL NOT remove permanent windows. * * @param bool $removePermanentWindows Whether to remove permanent windows. + * + * @return void */ public function removeAllWindows(bool $removePermanentWindows = false){ foreach($this->windowIndex as $id => $window){ @@ -3980,6 +4141,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{ } } + /** + * @return void + */ protected function sendAllInventories(){ foreach($this->windowIndex as $id => $inventory){ $inventory->sendContents($this); From 82e9072223d5b9f2c6a1b7c367ba07a8937ff1e8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:35:45 +0000 Subject: [PATCH 21/28] level/format/io: populate missing return type information --- .../level/format/io/BaseLevelProvider.php | 3 +++ src/pocketmine/level/format/io/LevelProvider.php | 14 ++++++++++++++ .../level/format/io/LevelProviderManager.php | 1 + src/pocketmine/level/format/io/leveldb/LevelDB.php | 4 ++-- src/pocketmine/level/format/io/region/McRegion.php | 4 ++++ .../level/format/io/region/RegionLoader.php | 13 ++++++++++++- 6 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/level/format/io/BaseLevelProvider.php b/src/pocketmine/level/format/io/BaseLevelProvider.php index 3a9a01be4..2022de406 100644 --- a/src/pocketmine/level/format/io/BaseLevelProvider.php +++ b/src/pocketmine/level/format/io/BaseLevelProvider.php @@ -150,6 +150,9 @@ abstract class BaseLevelProvider implements LevelProvider{ return $this->levelData; } + /** + * @return void + */ public function saveLevelData(){ $nbt = new BigEndianNBTStream(); $buffer = $nbt->writeCompressed(new CompoundTag("", [ diff --git a/src/pocketmine/level/format/io/LevelProvider.php b/src/pocketmine/level/format/io/LevelProvider.php index 5fa272c17..88e594def 100644 --- a/src/pocketmine/level/format/io/LevelProvider.php +++ b/src/pocketmine/level/format/io/LevelProvider.php @@ -72,6 +72,8 @@ interface LevelProvider{ * @param int $seed * @param string $generator * @param array $options + * + * @return void */ public static function generate(string $path, string $name, int $seed, string $generator, array $options = []); @@ -119,6 +121,8 @@ interface LevelProvider{ /** * @param int $value + * + * @return void */ public function setTime(int $value); @@ -129,6 +133,8 @@ interface LevelProvider{ /** * @param int $value + * + * @return void */ public function setSeed(int $value); @@ -139,6 +145,8 @@ interface LevelProvider{ /** * @param Vector3 $pos + * + * @return void */ public function setSpawn(Vector3 $pos); @@ -152,16 +160,22 @@ interface LevelProvider{ * Sets the world difficulty. * * @param int $difficulty + * + * @return void */ public function setDifficulty(int $difficulty); /** * Performs garbage collection in the level provider, such as cleaning up regions in Region-based worlds. + * + * @return void */ public function doGarbageCollection(); /** * Performs cleanups necessary when the level provider is closed and no longer needed. + * + * @return void */ public function close(); diff --git a/src/pocketmine/level/format/io/LevelProviderManager.php b/src/pocketmine/level/format/io/LevelProviderManager.php index ca64a5c94..21f2602b3 100644 --- a/src/pocketmine/level/format/io/LevelProviderManager.php +++ b/src/pocketmine/level/format/io/LevelProviderManager.php @@ -44,6 +44,7 @@ abstract class LevelProviderManager{ /** * @param string $class * + * @return void * @throws \InvalidArgumentException */ public static function addProvider(string $class){ diff --git a/src/pocketmine/level/format/io/leveldb/LevelDB.php b/src/pocketmine/level/format/io/leveldb/LevelDB.php index 1a355062d..26df4ba57 100644 --- a/src/pocketmine/level/format/io/leveldb/LevelDB.php +++ b/src/pocketmine/level/format/io/leveldb/LevelDB.php @@ -102,7 +102,7 @@ class LevelDB extends BaseLevelProvider{ /** @var \LevelDB */ protected $db; - private static function checkForLevelDBExtension(){ + private static function checkForLevelDBExtension() : void{ if(!extension_loaded('leveldb')){ throw new LevelException("The leveldb PHP extension is required to use this world format"); } @@ -523,7 +523,7 @@ class LevelDB extends BaseLevelProvider{ * @param CompoundTag[] $targets * @param string $index */ - private function writeTags(array $targets, string $index){ + private function writeTags(array $targets, string $index) : void{ if(count($targets) > 0){ $nbt = new LittleEndianNBTStream(); $this->db->put($index, $nbt->write($targets)); diff --git a/src/pocketmine/level/format/io/region/McRegion.php b/src/pocketmine/level/format/io/region/McRegion.php index 3aa089bf6..5077f8b19 100644 --- a/src/pocketmine/level/format/io/region/McRegion.php +++ b/src/pocketmine/level/format/io/region/McRegion.php @@ -333,6 +333,8 @@ class McRegion extends BaseLevelProvider{ * @param int $chunkZ * @param int $regionX reference parameter * @param int $regionZ reference parameter + * + * @return void */ public static function getRegionIndex(int $chunkX, int $chunkZ, &$regionX, &$regionZ){ $regionX = $chunkX >> 5; @@ -364,6 +366,8 @@ class McRegion extends BaseLevelProvider{ /** * @param int $regionX * @param int $regionZ + * + * @return void */ protected function loadRegion(int $regionX, int $regionZ){ if(!isset($this->regions[$index = Level::chunkHash($regionX, $regionZ)])){ diff --git a/src/pocketmine/level/format/io/region/RegionLoader.php b/src/pocketmine/level/format/io/region/RegionLoader.php index 6b87a8a0d..0c313ed5e 100644 --- a/src/pocketmine/level/format/io/region/RegionLoader.php +++ b/src/pocketmine/level/format/io/region/RegionLoader.php @@ -87,6 +87,7 @@ class RegionLoader{ } /** + * @return void * @throws CorruptedRegionException */ public function open(){ @@ -188,6 +189,7 @@ class RegionLoader{ * @param int $z * @param string $chunkData * + * @return void * @throws ChunkException * @throws \InvalidArgumentException */ @@ -220,6 +222,7 @@ class RegionLoader{ * @param int $x * @param int $z * + * @return void * @throws \InvalidArgumentException */ public function removeChunk(int $x, int $z){ @@ -256,6 +259,8 @@ class RegionLoader{ * Writes the region header and closes the file * * @param bool $writeHeader + * + * @return void */ public function close(bool $writeHeader = true){ if(is_resource($this->filePointer)){ @@ -268,6 +273,7 @@ class RegionLoader{ } /** + * @return void * @throws CorruptedRegionException */ protected function loadLocationTable(){ @@ -329,7 +335,7 @@ class RegionLoader{ } } - private function writeLocationTable(){ + private function writeLocationTable() : void{ $write = []; for($i = 0; $i < 1024; ++$i){ @@ -344,6 +350,8 @@ class RegionLoader{ /** * @param int $index + * + * @return void */ protected function writeLocationIndex($index){ fseek($this->filePointer, $index << 2); @@ -352,6 +360,9 @@ class RegionLoader{ fwrite($this->filePointer, Binary::writeInt($this->locationTable[$index]->getTimestamp()), 4); } + /** + * @return void + */ protected function createBlank(){ fseek($this->filePointer, 0); ftruncate($this->filePointer, 8192); // this fills the file with the null byte From 5334099fbf6613557491f936d21093df350d0702 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:36:34 +0000 Subject: [PATCH 22/28] level/format: populate missing return type information --- src/pocketmine/level/format/Chunk.php | 45 +++++++++++++++++++ src/pocketmine/level/format/SubChunk.php | 3 ++ .../level/format/SubChunkInterface.php | 4 ++ 3 files changed, 52 insertions(+) diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 5847dd0ab..a0b02a0cd 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -153,12 +153,19 @@ class Chunk{ return $this->z; } + /** + * @param int $x + * + * @return void + */ public function setX(int $x){ $this->x = $x; } /** * @param int $z + * + * @return void */ public function setZ(int $z){ $this->z = $z; @@ -225,6 +232,8 @@ class Chunk{ * @param int $y * @param int $z 0-15 * @param int $id 0-255 + * + * @return void */ public function setBlockId(int $x, int $y, int $z, int $id){ if($this->getSubChunk($y >> 4, true)->setBlockId($x, $y & 0x0f, $z, $id)){ @@ -252,6 +261,8 @@ class Chunk{ * @param int $y * @param int $z 0-15 * @param int $data 0-15 + * + * @return void */ public function setBlockData(int $x, int $y, int $z, int $data){ if($this->getSubChunk($y >> 4, true)->setBlockData($x, $y & 0x0f, $z, $data)){ @@ -279,6 +290,8 @@ class Chunk{ * @param int $y * @param int $z 0-15 * @param int $level 0-15 + * + * @return void */ public function setBlockSkyLight(int $x, int $y, int $z, int $level){ if($this->getSubChunk($y >> 4, true)->setBlockSkyLight($x, $y & 0x0f, $z, $level)){ @@ -288,6 +301,8 @@ class Chunk{ /** * @param int $level + * + * @return void */ public function setAllBlockSkyLight(int $level){ $char = chr(($level & 0x0f) | ($level << 4)); @@ -317,6 +332,8 @@ class Chunk{ * @param int $y 0-15 * @param int $z 0-15 * @param int $level 0-15 + * + * @return void */ public function setBlockLight(int $x, int $y, int $z, int $level){ if($this->getSubChunk($y >> 4, true)->setBlockLight($x, $y & 0x0f, $z, $level)){ @@ -326,6 +343,8 @@ class Chunk{ /** * @param int $level + * + * @return void */ public function setAllBlockLight(int $level){ $char = chr(($level & 0x0f) | ($level << 4)); @@ -381,6 +400,8 @@ class Chunk{ * @param int $x 0-15 * @param int $z 0-15 * @param int $value + * + * @return void */ public function setHeightMap(int $x, int $z, int $value){ $this->heightMap[($z << 4) | $x] = $value; @@ -388,6 +409,8 @@ class Chunk{ /** * Recalculates the heightmap for the whole chunk. + * + * @return void */ public function recalculateHeightMap(){ for($z = 0; $z < 16; ++$z){ @@ -423,6 +446,8 @@ class Chunk{ * if the chunk is light-populated after being terrain-populated. * * TODO: fast adjacent light spread + * + * @return void */ public function populateSkyLight(){ $maxY = $this->getMaxY(); @@ -469,6 +494,8 @@ class Chunk{ * @param int $x 0-15 * @param int $z 0-15 * @param int $biomeId 0-255 + * + * @return void */ public function setBiomeId(int $x, int $z, int $biomeId){ $this->hasChanged = true; @@ -549,6 +576,8 @@ class Chunk{ /** * @param bool $value + * + * @return void */ public function setLightPopulated(bool $value = true){ $this->lightPopulated = $value; @@ -563,6 +592,8 @@ class Chunk{ /** * @param bool $value + * + * @return void */ public function setPopulated(bool $value = true){ $this->terrainPopulated = $value; @@ -577,6 +608,8 @@ class Chunk{ /** * @param bool $value + * + * @return void */ public function setGenerated(bool $value = true){ $this->terrainGenerated = $value; @@ -584,6 +617,8 @@ class Chunk{ /** * @param Entity $entity + * + * @return void */ public function addEntity(Entity $entity){ if($entity->isClosed()){ @@ -597,6 +632,8 @@ class Chunk{ /** * @param Entity $entity + * + * @return void */ public function removeEntity(Entity $entity){ unset($this->entities[$entity->getId()]); @@ -607,6 +644,8 @@ class Chunk{ /** * @param Tile $tile + * + * @return void */ public function addTile(Tile $tile){ if($tile->isClosed()){ @@ -624,6 +663,8 @@ class Chunk{ /** * @param Tile $tile + * + * @return void */ public function removeTile(Tile $tile){ unset($this->tiles[$tile->getId()]); @@ -690,6 +731,8 @@ class Chunk{ * Deserializes tiles and entities from NBT * * @param Level $level + * + * @return void */ public function initChunk(Level $level){ if(!$this->isInit){ @@ -766,6 +809,8 @@ class Chunk{ /** * @param bool $value + * + * @return void */ public function setChanged(bool $value = true){ $this->hasChanged = $value; diff --git a/src/pocketmine/level/format/SubChunk.php b/src/pocketmine/level/format/SubChunk.php index 1285d1ee1..773afbf86 100644 --- a/src/pocketmine/level/format/SubChunk.php +++ b/src/pocketmine/level/format/SubChunk.php @@ -217,6 +217,9 @@ class SubChunk implements SubChunkInterface{ return "\x00" . $this->ids . $this->data; } + /** + * @return mixed[] + */ public function __debugInfo(){ return []; } diff --git a/src/pocketmine/level/format/SubChunkInterface.php b/src/pocketmine/level/format/SubChunkInterface.php index e7d4cde8b..d5aa82520 100644 --- a/src/pocketmine/level/format/SubChunkInterface.php +++ b/src/pocketmine/level/format/SubChunkInterface.php @@ -185,6 +185,8 @@ interface SubChunkInterface{ /** * @param string $data + * + * @return void */ public function setBlockSkyLightArray(string $data); @@ -195,6 +197,8 @@ interface SubChunkInterface{ /** * @param string $data + * + * @return void */ public function setBlockLightArray(string $data); From 6ede56015db8f95308aea379a02bc193cd02a27d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:37:08 +0000 Subject: [PATCH 23/28] level/biome: populate missing return type information --- src/pocketmine/level/biome/Biome.php | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/pocketmine/level/biome/Biome.php b/src/pocketmine/level/biome/Biome.php index 7ccab348d..8cc5fbf72 100644 --- a/src/pocketmine/level/biome/Biome.php +++ b/src/pocketmine/level/biome/Biome.php @@ -76,11 +76,20 @@ abstract class Biome{ /** @var float */ protected $temperature = 0.5; + /** + * @param int $id + * @param Biome $biome + * + * @return void + */ protected static function register(int $id, Biome $biome){ self::$biomes[$id] = $biome; $biome->setId($id); } + /** + * @return void + */ public static function init(){ self::$biomes = new \SplFixedArray(self::MAX_BIOMES); @@ -113,10 +122,18 @@ abstract class Biome{ return self::$biomes[$id]; } + /** + * @return void + */ public function clearPopulators(){ $this->populators = []; } + /** + * @param Populator $populator + * + * @return void + */ public function addPopulator(Populator $populator){ $this->populators[] = $populator; } @@ -126,6 +143,8 @@ abstract class Biome{ * @param int $chunkX * @param int $chunkZ * @param Random $random + * + * @return void */ public function populateChunk(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){ foreach($this->populators as $populator){ @@ -140,6 +159,11 @@ abstract class Biome{ return $this->populators; } + /** + * @param int $id + * + * @return void + */ public function setId(int $id){ if(!$this->registered){ $this->registered = true; @@ -161,6 +185,12 @@ abstract class Biome{ return $this->maxElevation; } + /** + * @param int $min + * @param int $max + * + * @return void + */ public function setElevation(int $min, int $max){ $this->minElevation = $min; $this->maxElevation = $max; @@ -175,6 +205,8 @@ abstract class Biome{ /** * @param Block[] $covers + * + * @return void */ public function setGroundCover(array $covers){ $this->groundCover = $covers; From db734675d81bd48bfb9b121ede7131ea9ea55dd2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:38:09 +0000 Subject: [PATCH 24/28] level: populate missing interface return types --- src/pocketmine/level/ChunkLoader.php | 10 ++++++++++ src/pocketmine/level/ChunkManager.php | 10 ++++++++++ src/pocketmine/level/SimpleChunkManager.php | 9 +++++++++ 3 files changed, 29 insertions(+) diff --git a/src/pocketmine/level/ChunkLoader.php b/src/pocketmine/level/ChunkLoader.php index 144b55192..b4d60f43e 100644 --- a/src/pocketmine/level/ChunkLoader.php +++ b/src/pocketmine/level/ChunkLoader.php @@ -78,6 +78,8 @@ interface ChunkLoader{ * This method will be called when a Chunk is replaced by a new one * * @param Chunk $chunk + * + * @return void */ public function onChunkChanged(Chunk $chunk); @@ -85,6 +87,8 @@ interface ChunkLoader{ * This method will be called when a registered chunk is loaded * * @param Chunk $chunk + * + * @return void */ public function onChunkLoaded(Chunk $chunk); @@ -93,6 +97,8 @@ interface ChunkLoader{ * This method will be called when a registered chunk is unloaded * * @param Chunk $chunk + * + * @return void */ public function onChunkUnloaded(Chunk $chunk); @@ -101,6 +107,8 @@ interface ChunkLoader{ * Usually it'll be sent with another call to onChunkChanged() * * @param Chunk $chunk + * + * @return void */ public function onChunkPopulated(Chunk $chunk); @@ -108,6 +116,8 @@ interface ChunkLoader{ * This method will be called when a block changes in a registered chunk * * @param Block|Vector3 $block + * + * @return void */ public function onBlockChanged(Vector3 $block); diff --git a/src/pocketmine/level/ChunkManager.php b/src/pocketmine/level/ChunkManager.php index ce17eec12..db985801d 100644 --- a/src/pocketmine/level/ChunkManager.php +++ b/src/pocketmine/level/ChunkManager.php @@ -44,6 +44,8 @@ interface ChunkManager{ * @param int $y * @param int $z * @param int $id 0-255 + * + * @return void */ public function setBlockIdAt(int $x, int $y, int $z, int $id); @@ -65,6 +67,8 @@ interface ChunkManager{ * @param int $y * @param int $z * @param int $data 0-15 + * + * @return void */ public function setBlockDataAt(int $x, int $y, int $z, int $data); @@ -86,6 +90,8 @@ interface ChunkManager{ * @param int $y * @param int $z * @param int $level + * + * @return void */ public function setBlockLightAt(int $x, int $y, int $z, int $level); @@ -107,6 +113,8 @@ interface ChunkManager{ * @param int $y * @param int $z * @param int $level + * + * @return void */ public function setBlockSkyLightAt(int $x, int $y, int $z, int $level); @@ -122,6 +130,8 @@ interface ChunkManager{ * @param int $chunkX * @param int $chunkZ * @param Chunk|null $chunk + * + * @return void */ public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null); diff --git a/src/pocketmine/level/SimpleChunkManager.php b/src/pocketmine/level/SimpleChunkManager.php index dba9854bf..fd89c6c4a 100644 --- a/src/pocketmine/level/SimpleChunkManager.php +++ b/src/pocketmine/level/SimpleChunkManager.php @@ -71,6 +71,8 @@ class SimpleChunkManager implements ChunkManager{ * @param int $y * @param int $z * @param int $id 0-255 + * + * @return void */ public function setBlockIdAt(int $x, int $y, int $z, int $id){ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ @@ -101,6 +103,8 @@ class SimpleChunkManager implements ChunkManager{ * @param int $y * @param int $z * @param int $data 0-15 + * + * @return void */ public function setBlockDataAt(int $x, int $y, int $z, int $data){ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ @@ -150,6 +154,8 @@ class SimpleChunkManager implements ChunkManager{ * @param int $chunkX * @param int $chunkZ * @param Chunk|null $chunk + * + * @return void */ public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null){ if($chunk === null){ @@ -159,6 +165,9 @@ class SimpleChunkManager implements ChunkManager{ $this->chunks[Level::chunkHash($chunkX, $chunkZ)] = $chunk; } + /** + * @return void + */ public function cleanChunks(){ $this->chunks = []; } From e8a5fa8a375b5f708dc39fe4788bc355de36a537 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:38:41 +0000 Subject: [PATCH 25/28] updater: populate missing return type information --- src/pocketmine/updater/AutoUpdater.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pocketmine/updater/AutoUpdater.php b/src/pocketmine/updater/AutoUpdater.php index d2efe1290..38cc828b4 100644 --- a/src/pocketmine/updater/AutoUpdater.php +++ b/src/pocketmine/updater/AutoUpdater.php @@ -63,6 +63,8 @@ class AutoUpdater{ * Callback used at the end of the update checking task * * @param array $updateInfo + * + * @return void */ public function checkUpdateCallback(array $updateInfo){ $this->updateInfo = $updateInfo; @@ -92,6 +94,8 @@ class AutoUpdater{ /** * Posts a warning to the console to tell the user there is an update available + * + * @return void */ public function showConsoleUpdate(){ $messages = [ @@ -109,12 +113,17 @@ class AutoUpdater{ * Shows a warning to a player to tell them there is an update available * * @param Player $player + * + * @return void */ public function showPlayerUpdate(Player $player){ $player->sendMessage(TextFormat::DARK_PURPLE . "The version of " . $this->server->getName() . " that this server is running is out of date. Please consider updating to the latest version."); $player->sendMessage(TextFormat::DARK_PURPLE . "Check the console for more details."); } + /** + * @return void + */ protected function showChannelSuggestionStable(){ $this->printConsoleMessage([ "It appears you're running a Stable build, when you've specified that you prefer to run " . ucfirst($this->getChannel()) . " builds.", @@ -122,6 +131,9 @@ class AutoUpdater{ ]); } + /** + * @return void + */ protected function showChannelSuggestionBeta(){ $this->printConsoleMessage([ "It appears you're running a Beta build, when you've specified that you prefer to run Stable builds.", @@ -129,6 +141,9 @@ class AutoUpdater{ ]); } + /** + * @return void + */ protected function printConsoleMessage(array $lines, string $logLevel = \LogLevel::INFO){ $logger = $this->server->getLogger(); @@ -151,6 +166,8 @@ class AutoUpdater{ /** * Schedules an AsyncTask to check for an update. + * + * @return void */ public function doCheck(){ $this->server->getAsyncPool()->submitTask(new UpdateCheckTask($this->endpoint, $this->getChannel())); @@ -158,6 +175,8 @@ class AutoUpdater{ /** * Checks the update information against the current server version to decide if there's an update + * + * @return void */ protected function checkUpdate(){ if($this->updateInfo === null){ From ea935a1af5de37255a98375a818a0ee4c64b7031 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:40:01 +0000 Subject: [PATCH 26/28] pocketmine root: sweep missing return type information --- src/pocketmine/Collectable.php | 3 +++ src/pocketmine/CrashDump.php | 7 +++++++ src/pocketmine/IPlayer.php | 4 ++++ src/pocketmine/MemoryManager.php | 11 +++++++++-- src/pocketmine/OfflinePlayer.php | 3 +++ src/pocketmine/Thread.php | 17 +++++++++++++++++ src/pocketmine/ThreadManager.php | 7 +++++++ src/pocketmine/Worker.php | 17 +++++++++++++++++ 8 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/Collectable.php b/src/pocketmine/Collectable.php index ece56bb0b..238cfcfe6 100644 --- a/src/pocketmine/Collectable.php +++ b/src/pocketmine/Collectable.php @@ -32,6 +32,9 @@ abstract class Collectable extends \Threaded{ return $this->isGarbage; } + /** + * @return void + */ public function setGarbage(){ $this->isGarbage = true; } diff --git a/src/pocketmine/CrashDump.php b/src/pocketmine/CrashDump.php index 86e335ed4..530a8d7a8 100644 --- a/src/pocketmine/CrashDump.php +++ b/src/pocketmine/CrashDump.php @@ -137,6 +137,9 @@ class CrashDump{ return $this->path; } + /** + * @return string + */ public function getEncodedData(){ return $this->encodedData; } @@ -345,6 +348,8 @@ class CrashDump{ /** * @param string $line + * + * @return void */ public function addLine($line = ""){ fwrite($this->fp, $line . PHP_EOL); @@ -352,6 +357,8 @@ class CrashDump{ /** * @param string $str + * + * @return void */ public function add($str){ fwrite($this->fp, $str); diff --git a/src/pocketmine/IPlayer.php b/src/pocketmine/IPlayer.php index bc0e8bc9d..8ea9ba59b 100644 --- a/src/pocketmine/IPlayer.php +++ b/src/pocketmine/IPlayer.php @@ -44,6 +44,8 @@ interface IPlayer extends ServerOperator{ /** * @param bool $banned + * + * @return void */ public function setBanned(bool $banned); @@ -54,6 +56,8 @@ interface IPlayer extends ServerOperator{ /** * @param bool $value + * + * @return void */ public function setWhitelisted(bool $value); diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index 52e650a35..7ae331184 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -115,7 +115,7 @@ class MemoryManager{ $this->init(); } - private function init(){ + private function init() : void{ $this->memoryLimit = ((int) $this->server->getProperty("memory.main-limit", 0)) * 1024 * 1024; $defaultMemory = 1024; @@ -201,6 +201,8 @@ class MemoryManager{ * @param int $limit * @param bool $global * @param int $triggerCount + * + * @return void */ public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0){ $this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB", @@ -230,6 +232,8 @@ class MemoryManager{ /** * Called every tick to update the memory manager state. + * + * @return void */ public function check(){ Timings::$memoryManagerTimer->startTiming(); @@ -297,6 +301,8 @@ class MemoryManager{ * @param string $outputFolder * @param int $maxNesting * @param int $maxStringSize + * + * @return void */ public function dumpServerMemory(string $outputFolder, int $maxNesting, int $maxStringSize){ $this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash"); @@ -319,6 +325,7 @@ class MemoryManager{ * @param int $maxStringSize * @param \Logger $logger * + * @return void * @throws \ReflectionException */ public static function dumpMemory($startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger){ @@ -479,7 +486,7 @@ class MemoryManager{ * @param int $maxNesting * @param int $maxStringSize */ - private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize){ + private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize) : void{ if($maxNesting <= 0){ $data = "(error) NESTING LIMIT REACHED"; return; diff --git a/src/pocketmine/OfflinePlayer.php b/src/pocketmine/OfflinePlayer.php index 0e631ee62..18702bc92 100644 --- a/src/pocketmine/OfflinePlayer.php +++ b/src/pocketmine/OfflinePlayer.php @@ -57,6 +57,9 @@ class OfflinePlayer implements IPlayer, Metadatable{ return $this->name; } + /** + * @return Server + */ public function getServer(){ return $this->server; } diff --git a/src/pocketmine/Thread.php b/src/pocketmine/Thread.php index 00b76b125..c6a335a2e 100644 --- a/src/pocketmine/Thread.php +++ b/src/pocketmine/Thread.php @@ -36,10 +36,18 @@ abstract class Thread extends \Thread{ /** @var bool */ protected $isKilled = false; + /** + * @return \ClassLoader|null + */ public function getClassLoader(){ return $this->classLoader; } + /** + * @param \ClassLoader|null $loader + * + * @return void + */ public function setClassLoader(\ClassLoader $loader = null){ $this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH; @@ -55,6 +63,8 @@ abstract class Thread extends \Thread{ * WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable. * If you do not do this, you will not be able to use new classes that were not loaded when the thread was started * (unless you are using a custom autoloader). + * + * @return void */ public function registerClassLoader(){ if($this->composerAutoloaderPath !== null){ @@ -65,6 +75,11 @@ abstract class Thread extends \Thread{ } } + /** + * @param int|null $options TODO: pthreads bug + * + * @return bool + */ public function start(?int $options = \PTHREADS_INHERIT_ALL){ ThreadManager::getInstance()->add($this); @@ -76,6 +91,8 @@ abstract class Thread extends \Thread{ /** * Stops the thread using the best way possible. Try to stop it yourself before calling this. + * + * @return void */ public function quit(){ $this->isKilled = true; diff --git a/src/pocketmine/ThreadManager.php b/src/pocketmine/ThreadManager.php index e90d598d6..b84f6509a 100644 --- a/src/pocketmine/ThreadManager.php +++ b/src/pocketmine/ThreadManager.php @@ -31,6 +31,9 @@ class ThreadManager extends \Volatile{ /** @var ThreadManager */ private static $instance = null; + /** + * @return void + */ public static function init(){ self::$instance = new ThreadManager(); } @@ -44,6 +47,8 @@ class ThreadManager extends \Volatile{ /** * @param Worker|Thread $thread + * + * @return void */ public function add($thread){ if($thread instanceof Thread or $thread instanceof Worker){ @@ -53,6 +58,8 @@ class ThreadManager extends \Volatile{ /** * @param Worker|Thread $thread + * + * @return void */ public function remove($thread){ if($thread instanceof Thread or $thread instanceof Worker){ diff --git a/src/pocketmine/Worker.php b/src/pocketmine/Worker.php index a8b843dba..ab5c81b50 100644 --- a/src/pocketmine/Worker.php +++ b/src/pocketmine/Worker.php @@ -36,10 +36,18 @@ abstract class Worker extends \Worker{ /** @var bool */ protected $isKilled = false; + /** + * @return \ClassLoader|null + */ public function getClassLoader(){ return $this->classLoader; } + /** + * @param \ClassLoader|null $loader + * + * @return void + */ public function setClassLoader(\ClassLoader $loader = null){ $this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH; @@ -55,6 +63,8 @@ abstract class Worker extends \Worker{ * WARNING: This method MUST be called from any descendent threads' run() method to make autoloading usable. * If you do not do this, you will not be able to use new classes that were not loaded when the thread was started * (unless you are using a custom autoloader). + * + * @return void */ public function registerClassLoader(){ if($this->composerAutoloaderPath !== null){ @@ -65,6 +75,11 @@ abstract class Worker extends \Worker{ } } + /** + * @param int|null $options TODO: pthreads bug + * + * @return bool + */ public function start(?int $options = \PTHREADS_INHERIT_ALL){ ThreadManager::getInstance()->add($this); @@ -76,6 +91,8 @@ abstract class Worker extends \Worker{ /** * Stops the thread using the best way possible. Try to stop it yourself before calling this. + * + * @return void */ public function quit(){ $this->isKilled = true; From 8252bea6994114ced77a454d40210a6a70250313 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:43:52 +0000 Subject: [PATCH 27/28] phpstan: enable MissingMethodReturnTypehintRule this was a bitch of a job, but it's one step closer to bypassing level 6. --- tests/phpstan/configs/gradual-level6.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpstan/configs/gradual-level6.neon b/tests/phpstan/configs/gradual-level6.neon index adf4eb0bf..0adcbb4df 100644 --- a/tests/phpstan/configs/gradual-level6.neon +++ b/tests/phpstan/configs/gradual-level6.neon @@ -8,5 +8,5 @@ rules: - PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule - PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule - PHPStan\Rules\Methods\MissingMethodParameterTypehintRule - #- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule + - PHPStan\Rules\Methods\MissingMethodReturnTypehintRule - PHPStan\Rules\Properties\MissingPropertyTypehintRule From 73257ffde7ee03702478c6789eda7be9f40febc3 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 19 Jan 2020 19:50:20 +0000 Subject: [PATCH 28/28] updated pocketmine/spl dependency --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index dce1d5d53..35a7e8efc 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-zip": "*", "ext-zlib": ">=1.2.11", "pocketmine/raklib": "^0.12.5", - "pocketmine/spl": "^0.3.0", + "pocketmine/spl": "^0.3.5", "pocketmine/binaryutils": "^0.1.9", "pocketmine/nbt": "^0.2.10", "pocketmine/math": "^0.2.0", diff --git a/composer.lock b/composer.lock index 6c77ae7cf..e58e461b9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "377d9e0ab5f1a9a4ef9b664706d26f5b", + "content-hash": "f693f278b3bb9c1d266079fa17644dcb", "packages": [ { "name": "adhocore/json-comment", @@ -276,16 +276,16 @@ }, { "name": "pocketmine/spl", - "version": "0.3.4", + "version": "0.3.5", "source": { "type": "git", "url": "https://github.com/pmmp/SPL.git", - "reference": "00d5b0b5a99e72c28c957cb7a310c6765d76e899" + "reference": "88052c67d3df2cc2dc2d99ebeae3d7ede3fc64ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/SPL/zipball/00d5b0b5a99e72c28c957cb7a310c6765d76e899", - "reference": "00d5b0b5a99e72c28c957cb7a310c6765d76e899", + "url": "https://api.github.com/repos/pmmp/SPL/zipball/88052c67d3df2cc2dc2d99ebeae3d7ede3fc64ab", + "reference": "88052c67d3df2cc2dc2d99ebeae3d7ede3fc64ab", "shasum": "" }, "type": "library", @@ -299,10 +299,10 @@ ], "description": "Standard library files required by PocketMine-MP and related projects", "support": { - "source": "https://github.com/pmmp/SPL/tree/0.3.4", + "source": "https://github.com/pmmp/SPL/tree/0.3", "issues": "https://github.com/pmmp/SPL/issues" }, - "time": "2020-01-11T22:00:31+00:00" + "time": "2020-01-14T16:23:26+00:00" } ], "packages-dev": [],