From e5f28e0f7ae5d97aa2744e6beb507e80fcd941db Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 7 Jun 2015 12:05:10 +0200 Subject: [PATCH] Throw exception on invalid parameters on Inventory addItem() and removeItem() --- src/pocketmine/inventory/BaseInventory.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index dd7f922bd..1491c62fc 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -236,6 +236,9 @@ abstract class BaseInventory implements Inventory{ /** @var Item[] $slots */ $itemSlots = []; foreach($slots as $slot){ + if(!($slot instanceof Item)){ + throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot)); + } if($slot->getId() !== 0 and $slot->getCount() > 0){ $itemSlots[] = clone $slot; } @@ -293,6 +296,9 @@ abstract class BaseInventory implements Inventory{ /** @var Item[] $slots */ $itemSlots = []; foreach($slots as $slot){ + if(!($slot instanceof Item)){ + throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot)); + } if($slot->getId() !== 0 and $slot->getCount() > 0){ $itemSlots[] = clone $slot; }