From 1e9d83f0143ea16249d5047f4a1020be84e5c4b1 Mon Sep 17 00:00:00 2001 From: alvin0319 Date: Mon, 7 Nov 2022 22:09:05 +0900 Subject: [PATCH] BaseInventory: validate given array in setContents() (#5391) --- src/inventory/BaseInventory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/inventory/BaseInventory.php b/src/inventory/BaseInventory.php index 3edc52043..06b3b9800 100644 --- a/src/inventory/BaseInventory.php +++ b/src/inventory/BaseInventory.php @@ -27,6 +27,7 @@ use pocketmine\item\Item; use pocketmine\item\VanillaItems; use pocketmine\player\Player; use pocketmine\utils\ObjectSet; +use pocketmine\utils\Utils; use function array_slice; use function count; use function max; @@ -85,6 +86,7 @@ abstract class BaseInventory implements Inventory{ * @phpstan-param array $items */ public function setContents(array $items) : void{ + Utils::validateArrayValueType($items, function(Item $item) : void{}); if(count($items) > $this->getSize()){ $items = array_slice($items, 0, $this->getSize(), true); }