From 20af789963770188de7c7bc4abd74cae865b9d34 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 30 Jan 2019 19:41:20 +0000 Subject: [PATCH] backport 3e58708130d9a77c261b3a1355fa2e0163a5c7c6: Add some missing @throws annotations --- src/pocketmine/event/Event.php | 2 -- .../inventory/transaction/CraftingTransaction.php | 1 + src/pocketmine/level/format/io/region/RegionLoader.php | 6 ++++++ src/pocketmine/resourcepacks/ResourcePack.php | 1 + src/pocketmine/resourcepacks/ZippedResourcePack.php | 3 ++- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/event/Event.php b/src/pocketmine/event/Event.php index e3bcf871f..015cdaafd 100644 --- a/src/pocketmine/event/Event.php +++ b/src/pocketmine/event/Event.php @@ -78,8 +78,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 e91085812..52d5f8c60 100644 --- a/src/pocketmine/inventory/transaction/CraftingTransaction.php +++ b/src/pocketmine/inventory/transaction/CraftingTransaction.php @@ -65,6 +65,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 e6df3bc3e..7ee7864f2 100644 --- a/src/pocketmine/level/format/io/region/RegionLoader.php +++ b/src/pocketmine/level/format/io/region/RegionLoader.php @@ -83,6 +83,9 @@ class RegionLoader{ $this->filePath = $filePath; } + /** + * @throws CorruptedRegionException + */ public function open(){ $exists = file_exists($this->filePath); if(!$exists){ @@ -263,6 +266,9 @@ class RegionLoader{ } } + /** + * @throws CorruptedRegionException + */ protected function loadLocationTable(){ fseek($this->filePointer, 0); $this->lastSector = 1; 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 d453396b7..0364ccd37 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; @@ -150,7 +151,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); }