From 8ecf5e02b95c4efc29ccafe455657278c7ea03f2 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 4 Dec 2019 22:00:19 +0000 Subject: [PATCH] bad fix for WritableBook phpstan warning master has this shit so much better --- src/pocketmine/item/WritableBook.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pocketmine/item/WritableBook.php b/src/pocketmine/item/WritableBook.php index cc73eec18..8b965b787 100644 --- a/src/pocketmine/item/WritableBook.php +++ b/src/pocketmine/item/WritableBook.php @@ -186,16 +186,18 @@ class WritableBook extends Item{ * @return CompoundTag[] */ public function getPages() : array{ - $pages = $this->getNamedTag()->getListTag(self::TAG_PAGES); - if($pages === null){ - return []; - } + /** @var CompoundTag[] $pages */ + $pages = $this->getPagesTag()->getValue(); - return $pages->getValue(); + return $pages; } protected function getPagesTag() : ListTag{ - return $this->getNamedTag()->getListTag(self::TAG_PAGES) ?? new ListTag(self::TAG_PAGES, [], NBT::TAG_Compound); + $pagesTag = $this->getNamedTag()->getListTag(self::TAG_PAGES); + if($pagesTag !== null and $pagesTag->getTagType() === NBT::TAG_Compound){ + return $pagesTag; + } + return new ListTag(self::TAG_PAGES, [], NBT::TAG_Compound); } /**