From 3e58708130d9a77c261b3a1355fa2e0163a5c7c6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 30 Jan 2019 19:41:20 +0000 Subject: [PATCH] Add some missing @throws annotations --- src/pocketmine/command/Command.php | 2 ++ src/pocketmine/event/Event.php | 2 -- .../inventory/transaction/CraftingTransaction.php | 1 + src/pocketmine/level/format/io/region/RegionLoader.php | 6 ++++++ src/pocketmine/network/mcpe/NetworkCipher.php | 6 ++++++ src/pocketmine/resourcepacks/ResourcePack.php | 1 + src/pocketmine/resourcepacks/ZippedResourcePack.php | 3 ++- 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 0e949f3f4..5099801c8 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -26,6 +26,7 @@ declare(strict_types=1); */ namespace pocketmine\command; +use pocketmine\command\utils\InvalidCommandSyntaxException; use pocketmine\lang\TextContainer; use pocketmine\lang\TranslationContainer; use pocketmine\permission\PermissionManager; @@ -92,6 +93,7 @@ abstract class Command{ * @param string[] $args * * @return mixed + * @throws InvalidCommandSyntaxException */ abstract public function execute(CommandSender $sender, string $commandLabel, array $args); diff --git a/src/pocketmine/event/Event.php b/src/pocketmine/event/Event.php index 612380681..9e96ccc17 100644 --- a/src/pocketmine/event/Event.php +++ b/src/pocketmine/event/Event.php @@ -48,8 +48,6 @@ abstract class Event{ * Calls event handlers registered for this event. * * @throws \RuntimeException if event call recursion reaches the max depth limit - * - * @throws \ReflectionException */ public function call() : void{ if(self::$eventCallDepth >= self::MAX_EVENT_CALL_DEPTH){ diff --git a/src/pocketmine/inventory/transaction/CraftingTransaction.php b/src/pocketmine/inventory/transaction/CraftingTransaction.php index c8610ebbc..e01926ad1 100644 --- a/src/pocketmine/inventory/transaction/CraftingTransaction.php +++ b/src/pocketmine/inventory/transaction/CraftingTransaction.php @@ -50,6 +50,7 @@ class CraftingTransaction extends InventoryTransaction{ * @param int $iterations * * @return int + * @throws TransactionValidationException */ protected function matchRecipeItems(array $txItems, array $recipeItems, bool $wildcards, int $iterations = 0) : int{ if(empty($recipeItems)){ diff --git a/src/pocketmine/level/format/io/region/RegionLoader.php b/src/pocketmine/level/format/io/region/RegionLoader.php index f3b35ef82..b606267dd 100644 --- a/src/pocketmine/level/format/io/region/RegionLoader.php +++ b/src/pocketmine/level/format/io/region/RegionLoader.php @@ -75,6 +75,9 @@ class RegionLoader{ $this->filePath = $filePath; } + /** + * @throws CorruptedRegionException + */ public function open() : void{ $exists = file_exists($this->filePath); if(!$exists){ @@ -219,6 +222,9 @@ class RegionLoader{ } } + /** + * @throws CorruptedRegionException + */ protected function loadLocationTable() : void{ fseek($this->filePointer, 0); $this->lastSector = 1; diff --git a/src/pocketmine/network/mcpe/NetworkCipher.php b/src/pocketmine/network/mcpe/NetworkCipher.php index 79bdfaba4..b243fb88b 100644 --- a/src/pocketmine/network/mcpe/NetworkCipher.php +++ b/src/pocketmine/network/mcpe/NetworkCipher.php @@ -63,6 +63,12 @@ class NetworkCipher{ $this->encryptCipher->encryptInit($this->key, $iv); } + /** + * @param string $encrypted + * + * @return string + * @throws \UnexpectedValueException + */ public function decrypt(string $encrypted) : string{ if(strlen($encrypted) < 9){ throw new \UnexpectedValueException("Payload is too short"); diff --git a/src/pocketmine/resourcepacks/ResourcePack.php b/src/pocketmine/resourcepacks/ResourcePack.php index 06c3b6ce5..c411c8fa6 100644 --- a/src/pocketmine/resourcepacks/ResourcePack.php +++ b/src/pocketmine/resourcepacks/ResourcePack.php @@ -73,6 +73,7 @@ interface ResourcePack{ * @param int $length Maximum length of data to return. * * @return string byte-array + * @throws \InvalidArgumentException if the chunk does not exist */ public function getPackChunk(int $start, int $length) : string; } diff --git a/src/pocketmine/resourcepacks/ZippedResourcePack.php b/src/pocketmine/resourcepacks/ZippedResourcePack.php index 8aa4ca8cb..7d23b3f9e 100644 --- a/src/pocketmine/resourcepacks/ZippedResourcePack.php +++ b/src/pocketmine/resourcepacks/ZippedResourcePack.php @@ -75,6 +75,7 @@ class ZippedResourcePack implements ResourcePack{ /** * @param string $zipPath Path to the resource pack zip + * @throws ResourcePackException */ public function __construct(string $zipPath){ $this->path = $zipPath; @@ -148,7 +149,7 @@ class ZippedResourcePack implements ResourcePack{ public function getPackChunk(int $start, int $length) : string{ fseek($this->fileResource, $start); if(feof($this->fileResource)){ - throw new \RuntimeException("Requested a resource pack chunk with invalid start offset"); + throw new \InvalidArgumentException("Requested a resource pack chunk with invalid start offset"); } return fread($this->fileResource, $length); }