diff --git a/src/block/tile/ContainerTrait.php b/src/block/tile/ContainerTrait.php index f76944a6ad..b23c944eb3 100644 --- a/src/block/tile/ContainerTrait.php +++ b/src/block/tile/ContainerTrait.php @@ -44,9 +44,7 @@ trait ContainerTrait{ abstract public function getRealInventory(); protected function loadItems(CompoundTag $tag) : void{ - if($tag->hasTag(Container::TAG_ITEMS, ListTag::class)){ - $inventoryTag = $tag->getListTag(Container::TAG_ITEMS); - + if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag){ $inventory = $this->getRealInventory(); $listeners = $inventory->getListeners()->toArray(); $inventory->getListeners()->remove(...$listeners); //prevent any events being fired by initialization diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index 5591073842..da9f714777 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -45,26 +45,6 @@ parameters: count: 1 path: ../../../src/block/tile/Chest.php - - - message: "#^Argument of an invalid type pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: ../../../src/block/tile/Chest.php - - - - message: "#^Argument of an invalid type pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: ../../../src/block/tile/BrewingStand.php - - - - message: "#^Argument of an invalid type pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: ../../../src/block/tile/Furnace.php - - - - message: "#^Argument of an invalid type pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: ../../../src/block/tile/Hopper.php - - message: "#^Parameter \\#1 \\$nbt of method pocketmine\\\\block\\\\tile\\\\Tile\\:\\:readSaveData\\(\\) expects pocketmine\\\\nbt\\\\tag\\\\CompoundTag, pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null given\\.$#" count: 1