From eb3ba86e9efdf7ceb7d70c766687421e59b4aa10 Mon Sep 17 00:00:00 2001 From: Dries C Date: Sat, 15 Feb 2025 15:18:34 +0100 Subject: [PATCH] Fix PHPStan --- src/inventory/data/CreativeGroup.php | 20 ++++--------------- .../mcpe/cache/CreativeInventoryCache.php | 2 +- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/inventory/data/CreativeGroup.php b/src/inventory/data/CreativeGroup.php index 21cecf8f1f..3e89d912cc 100644 --- a/src/inventory/data/CreativeGroup.php +++ b/src/inventory/data/CreativeGroup.php @@ -32,27 +32,15 @@ final class CreativeGroup{ public readonly Translatable|string $name; public readonly ?Item $icon; - private function __construct(){ + private function __construct(CreativeCategory $categoryId, Translatable|string $name, ?Item $icon){ //NOOP } public static function anonymous(CreativeCategory $categoryId) : self{ - $result = new self(); - - $result->categoryId = $categoryId; - $result->name = ""; - $result->icon = null; - - return $result; + return new self($categoryId, "", null); } - public static function named(CreativeCategory $categoryId, Translatable|string $name, Item $icon) : self{ - $result = new self(); - - $result->categoryId = $categoryId; - $result->name = $name; - $result->icon = $icon; - - return $result; + public static function named(CreativeCategory $categoryId, Translatable|string $name, ?Item $icon = null) : self{ + return new self($categoryId, $name, $icon); } } diff --git a/src/network/mcpe/cache/CreativeInventoryCache.php b/src/network/mcpe/cache/CreativeInventoryCache.php index b5de0719e6..b1fc59e34c 100644 --- a/src/network/mcpe/cache/CreativeInventoryCache.php +++ b/src/network/mcpe/cache/CreativeInventoryCache.php @@ -84,7 +84,7 @@ private function buildCreativeInventoryCache(CreativeInventory $inventory) : Cre $groups[] = new CreativeGroupEntry( $categoryId, - $group->name instanceof Translatable ? $group->name->getText() : (string) $group->name, + $group->name instanceof Translatable ? $group->name->getText() : $group->name, $group->icon === null ? ItemStack::null() : $typeConverter->coreItemStackToNet($group->icon) ); }