diff --git a/src/item/Armor.php b/src/item/Armor.php index cd3d6bd55..7cf8e646d 100644 --- a/src/item/Armor.php +++ b/src/item/Armor.php @@ -40,8 +40,7 @@ class Armor extends Durable{ public const TAG_CUSTOM_COLOR = "customColor"; //TAG_Int - /** @var ArmorTypeInfo */ - private $armorInfo; + private ArmorTypeInfo $armorInfo; /** @var Color|null */ protected $customColor = null; diff --git a/src/item/ArmorTypeInfo.php b/src/item/ArmorTypeInfo.php index 3542a554e..703d9b4aa 100644 --- a/src/item/ArmorTypeInfo.php +++ b/src/item/ArmorTypeInfo.php @@ -24,19 +24,11 @@ declare(strict_types=1); namespace pocketmine\item; class ArmorTypeInfo{ - - /** @var int */ - private $defensePoints; - /** @var int */ - private $maxDurability; - /** @var int */ - private $armorSlot; - - public function __construct(int $defensePoints, int $maxDurability, int $armorSlot){ - $this->defensePoints = $defensePoints; - $this->maxDurability = $maxDurability; - $this->armorSlot = $armorSlot; - } + public function __construct( + private int $defensePoints, + private int $maxDurability, + private int $armorSlot + ){} public function getDefensePoints() : int{ return $this->defensePoints; diff --git a/src/item/Banner.php b/src/item/Banner.php index ea7320b79..5ec875ed1 100644 --- a/src/item/Banner.php +++ b/src/item/Banner.php @@ -39,14 +39,13 @@ class Banner extends ItemBlockWallOrFloor{ public const TAG_PATTERN_COLOR = TileBanner::TAG_PATTERN_COLOR; public const TAG_PATTERN_NAME = TileBanner::TAG_PATTERN_NAME; - /** @var DyeColor */ - private $color; + private DyeColor $color; /** * @var BannerPatternLayer[] * @phpstan-var list */ - private $patterns = []; + private array $patterns = []; public function __construct(ItemIdentifier $identifier, Block $floorVariant, Block $wallVariant){ parent::__construct($identifier, $floorVariant, $wallVariant); diff --git a/src/item/Bed.php b/src/item/Bed.php index c1251ac63..60efd470e 100644 --- a/src/item/Bed.php +++ b/src/item/Bed.php @@ -28,9 +28,7 @@ use pocketmine\block\utils\DyeColor; use pocketmine\block\VanillaBlocks; class Bed extends Item{ - - /** @var DyeColor */ - private $color; + private DyeColor $color; public function __construct(ItemIdentifier $identifier, string $name, DyeColor $color){ parent::__construct($identifier, $name); diff --git a/src/item/Boat.php b/src/item/Boat.php index c117dab1d..eb0b3d9c5 100644 --- a/src/item/Boat.php +++ b/src/item/Boat.php @@ -26,8 +26,7 @@ namespace pocketmine\item; use pocketmine\block\utils\TreeType; class Boat extends Item{ - /** @var TreeType */ - private $woodType; + private TreeType $woodType; public function __construct(ItemIdentifier $identifier, string $name, TreeType $woodType){ parent::__construct($identifier, $name); diff --git a/src/item/Durable.php b/src/item/Durable.php index 9d4a2d044..33678be8c 100644 --- a/src/item/Durable.php +++ b/src/item/Durable.php @@ -32,8 +32,7 @@ abstract class Durable extends Item{ /** @var int */ protected $damage = 0; - /** @var bool */ - private $unbreakable = false; + private bool $unbreakable = false; public function getMeta() : int{ return $this->damage; diff --git a/src/item/Dye.php b/src/item/Dye.php index dcd6c9955..cdb39e75c 100644 --- a/src/item/Dye.php +++ b/src/item/Dye.php @@ -26,9 +26,7 @@ namespace pocketmine\item; use pocketmine\block\utils\DyeColor; class Dye extends Item{ - - /** @var DyeColor */ - private $color; + private DyeColor $color; public function __construct(ItemIdentifier $identifier, string $name, DyeColor $color){ parent::__construct($identifier, $name); diff --git a/src/item/Item.php b/src/item/Item.php index 9c1119db3..eed7b0e20 100644 --- a/src/item/Item.php +++ b/src/item/Item.php @@ -65,10 +65,9 @@ class Item implements \JsonSerializable{ public const TAG_DISPLAY_NAME = "Name"; public const TAG_DISPLAY_LORE = "Lore"; - /** @var ItemIdentifier */ - private $identifier; - /** @var CompoundTag */ - private $nbt; + private ItemIdentifier $identifier; + private CompoundTag $nbt; + /** @var int */ protected $count = 1; /** @var string */ diff --git a/src/item/ItemBlock.php b/src/item/ItemBlock.php index 0836d86e1..0fa1e06c8 100644 --- a/src/item/ItemBlock.php +++ b/src/item/ItemBlock.php @@ -30,8 +30,7 @@ use pocketmine\block\BlockFactory; * Class used for Items that can be Blocks */ class ItemBlock extends Item{ - /** @var int */ - private $blockFullId; + private int $blockFullId; public function __construct(ItemIdentifier $identifier, Block $block){ parent::__construct($identifier, $block->getName()); diff --git a/src/item/ItemBlockWallOrFloor.php b/src/item/ItemBlockWallOrFloor.php index 92a6afcf5..c1d063dcf 100644 --- a/src/item/ItemBlockWallOrFloor.php +++ b/src/item/ItemBlockWallOrFloor.php @@ -29,11 +29,8 @@ use pocketmine\math\Axis; use pocketmine\math\Facing; class ItemBlockWallOrFloor extends Item{ - - /** @var int */ - private $floorVariant; - /** @var int */ - private $wallVariant; + private int $floorVariant; + private int $wallVariant; public function __construct(ItemIdentifier $identifier, Block $floorVariant, Block $wallVariant){ parent::__construct($identifier, $floorVariant->getName()); diff --git a/src/item/ItemFactory.php b/src/item/ItemFactory.php index 15894b921..c3e6a1cfc 100644 --- a/src/item/ItemFactory.php +++ b/src/item/ItemFactory.php @@ -55,7 +55,7 @@ class ItemFactory{ use SingletonTrait; /** @var Item[] */ - private $list = []; + private array $list = []; public function __construct(){ $this->registerArmorItems(); diff --git a/src/item/ItemIdentifier.php b/src/item/ItemIdentifier.php index 414cd5e0e..b24c586a9 100644 --- a/src/item/ItemIdentifier.php +++ b/src/item/ItemIdentifier.php @@ -24,11 +24,8 @@ declare(strict_types=1); namespace pocketmine\item; final class ItemIdentifier{ - - /** @var int */ - private $id; - /** @var int */ - private $meta; + private int $id; + private int $meta; public function __construct(int $id, int $meta){ if($id < -0x8000 || $id > 0x7fff){ //signed short range diff --git a/src/item/LegacyStringToItemParser.php b/src/item/LegacyStringToItemParser.php index 3065cb1bd..bfcca209a 100644 --- a/src/item/LegacyStringToItemParser.php +++ b/src/item/LegacyStringToItemParser.php @@ -50,9 +50,6 @@ use function trim; final class LegacyStringToItemParser{ use SingletonTrait; - /** @var ItemFactory */ - private $itemFactory; - private static function make() : self{ $result = new self(ItemFactory::getInstance()); @@ -73,11 +70,9 @@ final class LegacyStringToItemParser{ * @var int[] * @phpstan-var array */ - private $map = []; + private array $map = []; - public function __construct(ItemFactory $itemFactory){ - $this->itemFactory = $itemFactory; - } + public function __construct(private ItemFactory $itemFactory){} public function addMapping(string $alias, int $id) : void{ $this->map[$alias] = $id; diff --git a/src/item/LiquidBucket.php b/src/item/LiquidBucket.php index 710e37ba1..deadcc561 100644 --- a/src/item/LiquidBucket.php +++ b/src/item/LiquidBucket.php @@ -31,9 +31,7 @@ use pocketmine\math\Vector3; use pocketmine\player\Player; class LiquidBucket extends Item{ - - /** @var Liquid */ - private $liquid; + private Liquid $liquid; public function __construct(ItemIdentifier $identifier, string $name, Liquid $liquid){ parent::__construct($identifier, $name); diff --git a/src/item/Record.php b/src/item/Record.php index 35c56bb67..df53328fb 100644 --- a/src/item/Record.php +++ b/src/item/Record.php @@ -26,9 +26,9 @@ namespace pocketmine\item; use pocketmine\block\utils\RecordType; class Record extends Item{ - /** @var RecordType */ - private $recordType; + private RecordType $recordType; + //TODO: inconsistent parameter order public function __construct(ItemIdentifier $identifier, RecordType $recordType, string $name){ $this->recordType = $recordType; parent::__construct($identifier, $name); diff --git a/src/item/Skull.php b/src/item/Skull.php index 6e4a98203..d45b79023 100644 --- a/src/item/Skull.php +++ b/src/item/Skull.php @@ -28,9 +28,7 @@ use pocketmine\block\utils\SkullType; use pocketmine\block\VanillaBlocks; class Skull extends Item{ - - /** @var SkullType */ - private $skullType; + private SkullType $skullType; public function __construct(ItemIdentifier $identifier, string $name, SkullType $skullType){ parent::__construct($identifier, $name); diff --git a/src/item/ToolTier.php b/src/item/ToolTier.php index a0984c6ad..ea3bf009a 100644 --- a/src/item/ToolTier.php +++ b/src/item/ToolTier.php @@ -52,21 +52,14 @@ final class ToolTier{ ); } - /** @var int */ - private $harvestLevel; - /** @var int */ - private $maxDurability; - /** @var int */ - private $baseAttackPoints; - /** @var int */ - private $baseEfficiency; - - private function __construct(string $name, int $harvestLevel, int $maxDurability, int $baseAttackPoints, int $baseEfficiency){ + private function __construct( + string $name, + private int $harvestLevel, + private int $maxDurability, + private int $baseAttackPoints, + private int $baseEfficiency + ){ $this->Enum___construct($name); - $this->harvestLevel = $harvestLevel; - $this->maxDurability = $maxDurability; - $this->baseAttackPoints = $baseAttackPoints; - $this->baseEfficiency = $baseEfficiency; } public function getHarvestLevel() : int{ diff --git a/src/item/WritableBookBase.php b/src/item/WritableBookBase.php index db0b37574..dae95afc6 100644 --- a/src/item/WritableBookBase.php +++ b/src/item/WritableBookBase.php @@ -42,7 +42,7 @@ abstract class WritableBookBase extends Item{ * @var WritableBookPage[] * @phpstan-var list */ - private $pages = []; + private array $pages = []; public function __construct(ItemIdentifier $identifier, string $name){ parent::__construct($identifier, $name); diff --git a/src/item/WritableBookPage.php b/src/item/WritableBookPage.php index 95d5a6258..d0325febb 100644 --- a/src/item/WritableBookPage.php +++ b/src/item/WritableBookPage.php @@ -32,10 +32,8 @@ class WritableBookPage{ public const PAGE_LENGTH_HARD_LIMIT_BYTES = Limits::INT16_MAX; public const PHOTO_NAME_LENGTH_HARD_LIMIT_BYTES = Limits::INT16_MAX; - /** @var string */ - private $text; - /** @var string */ - private $photoName; + private string $text; + private string $photoName; /** * @throws \InvalidArgumentException diff --git a/src/item/WrittenBook.php b/src/item/WrittenBook.php index 129dfec3b..b5e04e5d0 100644 --- a/src/item/WrittenBook.php +++ b/src/item/WrittenBook.php @@ -40,12 +40,9 @@ class WrittenBook extends WritableBookBase{ public const TAG_AUTHOR = "author"; //TAG_String public const TAG_TITLE = "title"; //TAG_String - /** @var int */ - private $generation = self::GENERATION_ORIGINAL; - /** @var string */ - private $author = ""; - /** @var string */ - private $title = ""; + private int $generation = self::GENERATION_ORIGINAL; + private string $author = ""; + private string $title = ""; public function getMaxStackSize() : int{ return 16; diff --git a/src/item/enchantment/EnchantmentInstance.php b/src/item/enchantment/EnchantmentInstance.php index f46d2c75b..93aeb8416 100644 --- a/src/item/enchantment/EnchantmentInstance.php +++ b/src/item/enchantment/EnchantmentInstance.php @@ -29,21 +29,10 @@ namespace pocketmine\item\enchantment; * Note: This class is assumed to be immutable. Consider this before making alterations. */ final class EnchantmentInstance{ - /** @var Enchantment */ - private $enchantment; - /** @var int */ - private $level; - - /** - * EnchantmentInstance constructor. - * - * @param Enchantment $enchantment Enchantment type - * @param int $level Level of enchantment - */ - public function __construct(Enchantment $enchantment, int $level = 1){ - $this->enchantment = $enchantment; - $this->level = $level; - } + public function __construct( + private Enchantment $enchantment, + private int $level = 1 + ){} /** * Returns the type of this enchantment.