mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
ContainerTrait: use a static-analysis-friendly way to read NBT, fixes 4 phpstan level 8 errors
This commit is contained in:
parent
f039a077cd
commit
9484220bd5
@ -44,9 +44,7 @@ trait ContainerTrait{
|
|||||||
abstract public function getRealInventory();
|
abstract public function getRealInventory();
|
||||||
|
|
||||||
protected function loadItems(CompoundTag $tag) : void{
|
protected function loadItems(CompoundTag $tag) : void{
|
||||||
if($tag->hasTag(Container::TAG_ITEMS, ListTag::class)){
|
if(($inventoryTag = $tag->getTag(Container::TAG_ITEMS)) instanceof ListTag){
|
||||||
$inventoryTag = $tag->getListTag(Container::TAG_ITEMS);
|
|
||||||
|
|
||||||
$inventory = $this->getRealInventory();
|
$inventory = $this->getRealInventory();
|
||||||
$listeners = $inventory->getListeners()->toArray();
|
$listeners = $inventory->getListeners()->toArray();
|
||||||
$inventory->getListeners()->remove(...$listeners); //prevent any events being fired by initialization
|
$inventory->getListeners()->remove(...$listeners); //prevent any events being fired by initialization
|
||||||
|
@ -45,26 +45,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/block/tile/Chest.php
|
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\\.$#"
|
message: "#^Parameter \\#1 \\$nbt of method pocketmine\\\\block\\\\tile\\\\Tile\\:\\:readSaveData\\(\\) expects pocketmine\\\\nbt\\\\tag\\\\CompoundTag, pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user