diff --git a/src/block/BlockFactory.php b/src/block/BlockFactory.php index 14d37d72d..3b0ca17db 100644 --- a/src/block/BlockFactory.php +++ b/src/block/BlockFactory.php @@ -74,7 +74,7 @@ class BlockFactory{ * @var \SplFixedArray|Block[] * @phpstan-var \SplFixedArray */ - private $fullList; + private \SplFixedArray $fullList; /** * @var \SplFixedArray|int[] @@ -86,22 +86,22 @@ class BlockFactory{ * @var \SplFixedArray|int[] * @phpstan-var \SplFixedArray */ - public $light; + public \SplFixedArray $light; /** * @var \SplFixedArray|int[] * @phpstan-var \SplFixedArray */ - public $lightFilter; + public \SplFixedArray $lightFilter; /** * @var \SplFixedArray|bool[] * @phpstan-var \SplFixedArray */ - public $blocksDirectSkyLight; + public \SplFixedArray $blocksDirectSkyLight; /** * @var \SplFixedArray|float[] * @phpstan-var \SplFixedArray */ - public $blastResistance; + public \SplFixedArray $blastResistance; public function __construct(){ $this->fullList = new \SplFixedArray(1024 << Block::INTERNAL_METADATA_BITS); diff --git a/src/block/inventory/DoubleChestInventory.php b/src/block/inventory/DoubleChestInventory.php index 9d99f1e2b..e09dfab35 100644 --- a/src/block/inventory/DoubleChestInventory.php +++ b/src/block/inventory/DoubleChestInventory.php @@ -33,10 +33,8 @@ use pocketmine\world\sound\Sound; class DoubleChestInventory extends BaseInventory implements BlockInventory, InventoryHolder{ use AnimatedBlockInventoryTrait; - /** @var ChestInventory */ - private $left; - /** @var ChestInventory */ - private $right; + private ChestInventory $left; + private ChestInventory $right; public function __construct(ChestInventory $left, ChestInventory $right){ $this->left = $left; diff --git a/src/block/tile/Banner.php b/src/block/tile/Banner.php index 4404a3971..4d2550f4d 100644 --- a/src/block/tile/Banner.php +++ b/src/block/tile/Banner.php @@ -44,14 +44,13 @@ class Banner extends Spawnable{ public const TAG_PATTERN_COLOR = "Color"; public const TAG_PATTERN_NAME = "Pattern"; - /** @var DyeColor */ - private $baseColor; + private DyeColor $baseColor; /** * @var BannerPatternLayer[] * @phpstan-var list */ - private $patterns = []; + private array $patterns = []; public function __construct(World $world, Vector3 $pos){ $this->baseColor = DyeColor::BLACK(); diff --git a/src/block/tile/Beacon.php b/src/block/tile/Beacon.php index 4d4b8cf6d..42c24cd38 100644 --- a/src/block/tile/Beacon.php +++ b/src/block/tile/Beacon.php @@ -29,10 +29,8 @@ final class Beacon extends Spawnable{ private const TAG_PRIMARY = "primary"; //TAG_Int private const TAG_SECONDARY = "secondary"; //TAG_Int - /** @var int */ - private $primaryEffect = 0; - /** @var int */ - private $secondaryEffect = 0; + private int $primaryEffect = 0; + private int $secondaryEffect = 0; protected function addAdditionalSpawnData(CompoundTag $nbt) : void{ $nbt->setInt(self::TAG_PRIMARY, $this->primaryEffect); diff --git a/src/block/tile/Bed.php b/src/block/tile/Bed.php index 77cca1ceb..49ac07202 100644 --- a/src/block/tile/Bed.php +++ b/src/block/tile/Bed.php @@ -32,8 +32,8 @@ use pocketmine\world\World; class Bed extends Spawnable{ public const TAG_COLOR = "color"; - /** @var DyeColor */ - private $color; + + private DyeColor $color; public function __construct(World $world, Vector3 $pos){ $this->color = DyeColor::RED(); diff --git a/src/block/tile/Chest.php b/src/block/tile/Chest.php index 057aa1991..1f49a2ddb 100644 --- a/src/block/tile/Chest.php +++ b/src/block/tile/Chest.php @@ -49,10 +49,8 @@ class Chest extends Spawnable implements Container, Nameable{ /** @var DoubleChestInventory|null */ protected $doubleInventory = null; - /** @var int|null */ - private $pairX; - /** @var int|null */ - private $pairZ; + private ?int $pairX = null; + private ?int $pairZ = null; public function __construct(World $world, Vector3 $pos){ parent::__construct($world, $pos); diff --git a/src/block/tile/FlowerPot.php b/src/block/tile/FlowerPot.php index 221453ae6..294e4fe41 100644 --- a/src/block/tile/FlowerPot.php +++ b/src/block/tile/FlowerPot.php @@ -38,8 +38,7 @@ class FlowerPot extends Spawnable{ private const TAG_ITEM = "item"; private const TAG_ITEM_DATA = "mData"; - /** @var Block|null */ - private $plant = null; + private ?Block $plant = null; public function readSaveData(CompoundTag $nbt) : void{ if(($itemIdTag = $nbt->getTag(self::TAG_ITEM)) instanceof ShortTag && ($itemMetaTag = $nbt->getTag(self::TAG_ITEM_DATA)) instanceof IntTag){ diff --git a/src/block/tile/Furnace.php b/src/block/tile/Furnace.php index 21b05f504..806c53a07 100644 --- a/src/block/tile/Furnace.php +++ b/src/block/tile/Furnace.php @@ -50,12 +50,9 @@ abstract class Furnace extends Spawnable implements Container, Nameable{ /** @var FurnaceInventory */ protected $inventory; - /** @var int */ - private $remainingFuelTime = 0; - /** @var int */ - private $cookTime = 0; - /** @var int */ - private $maxFuelTime = 0; + private int $remainingFuelTime = 0; + private int $cookTime = 0; + private int $maxFuelTime = 0; public function __construct(World $world, Vector3 $pos){ parent::__construct($world, $pos); diff --git a/src/block/tile/Hopper.php b/src/block/tile/Hopper.php index 9ebb429ef..c5fe6f167 100644 --- a/src/block/tile/Hopper.php +++ b/src/block/tile/Hopper.php @@ -35,11 +35,8 @@ class Hopper extends Spawnable implements Container, Nameable{ private const TAG_TRANSFER_COOLDOWN = "TransferCooldown"; - /** @var HopperInventory */ - private $inventory; - - /** @var int */ - private $transferCooldown = 0; + private HopperInventory $inventory; + private int $transferCooldown = 0; public function __construct(World $world, Vector3 $pos){ parent::__construct($world, $pos); diff --git a/src/block/tile/ItemFrame.php b/src/block/tile/ItemFrame.php index f4f679e7e..ecb93acc1 100644 --- a/src/block/tile/ItemFrame.php +++ b/src/block/tile/ItemFrame.php @@ -38,12 +38,9 @@ class ItemFrame extends Spawnable{ public const TAG_ITEM_DROP_CHANCE = "ItemDropChance"; public const TAG_ITEM = "Item"; - /** @var Item */ - private $item; - /** @var int */ - private $itemRotation = 0; - /** @var float */ - private $itemDropChance = 1.0; + private Item $item; + private int $itemRotation = 0; + private float $itemDropChance = 1.0; public function __construct(World $world, Vector3 $pos){ $this->item = VanillaItems::AIR(); diff --git a/src/block/tile/Jukebox.php b/src/block/tile/Jukebox.php index 35242ed8d..eb8041258 100644 --- a/src/block/tile/Jukebox.php +++ b/src/block/tile/Jukebox.php @@ -30,8 +30,7 @@ use pocketmine\nbt\tag\CompoundTag; class Jukebox extends Spawnable{ private const TAG_RECORD = "RecordItem"; //Item CompoundTag - /** @var Record|null */ - private $record = null; + private ?Record $record = null; public function getRecord() : ?Record{ return $this->record; diff --git a/src/block/tile/MonsterSpawner.php b/src/block/tile/MonsterSpawner.php index 8b6d0eeca..040d6a3ee 100644 --- a/src/block/tile/MonsterSpawner.php +++ b/src/block/tile/MonsterSpawner.php @@ -56,43 +56,24 @@ class MonsterSpawner extends Spawnable{ public const DEFAULT_SPAWN_RANGE = 4; //blocks public const DEFAULT_REQUIRED_PLAYER_RANGE = 16; - /** - * @var string - * TODO: replace this with a cached entity or something of that nature - */ - private $entityTypeId = ":"; - /** - * @var ListTag|null - * TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun) - */ - private $spawnPotentials = null; - /** - * @var CompoundTag|null - * TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun) - */ - private $spawnData = null; + /** TODO: replace this with a cached entity or something of that nature */ + private string $entityTypeId = ":"; + /** TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun) */ + private ?ListTag $spawnPotentials = null; + /** TODO: deserialize this properly and drop the NBT (PC and PE formats are different, just for fun) */ + private ?CompoundTag $spawnData = null; - /** @var float */ - private $displayEntityWidth = 1; - /** @var float */ - private $displayEntityHeight = 1; - /** @var float */ - private $displayEntityScale = 1; + private float $displayEntityWidth = 1.0; + private float $displayEntityHeight = 1.0; + private float $displayEntityScale = 1.0; - /** @var int */ - private $spawnDelay = self::DEFAULT_MIN_SPAWN_DELAY; - /** @var int */ - private $minSpawnDelay = self::DEFAULT_MIN_SPAWN_DELAY; - /** @var int */ - private $maxSpawnDelay = self::DEFAULT_MAX_SPAWN_DELAY; - /** @var int */ - private $spawnPerAttempt = 1; - /** @var int */ - private $maxNearbyEntities = self::DEFAULT_MAX_NEARBY_ENTITIES; - /** @var int */ - private $spawnRange = self::DEFAULT_SPAWN_RANGE; - /** @var int */ - private $requiredPlayerRange = self::DEFAULT_REQUIRED_PLAYER_RANGE; + private int $spawnDelay = self::DEFAULT_MIN_SPAWN_DELAY; + private int $minSpawnDelay = self::DEFAULT_MIN_SPAWN_DELAY; + private int $maxSpawnDelay = self::DEFAULT_MAX_SPAWN_DELAY; + private int $spawnPerAttempt = 1; + private int $maxNearbyEntities = self::DEFAULT_MAX_NEARBY_ENTITIES; + private int $spawnRange = self::DEFAULT_SPAWN_RANGE; + private int $requiredPlayerRange = self::DEFAULT_REQUIRED_PLAYER_RANGE; public function readSaveData(CompoundTag $nbt) : void{ if(($legacyIdTag = $nbt->getTag(self::TAG_LEGACY_ENTITY_TYPE_ID)) instanceof IntTag){ diff --git a/src/block/tile/Note.php b/src/block/tile/Note.php index 30c252593..bf597607c 100644 --- a/src/block/tile/Note.php +++ b/src/block/tile/Note.php @@ -30,8 +30,7 @@ use pocketmine\nbt\tag\CompoundTag; * @deprecated */ class Note extends Tile{ - /** @var int */ - private $pitch = 0; + private int $pitch = 0; public function readSaveData(CompoundTag $nbt) : void{ if(($pitch = $nbt->getByte("note", $this->pitch)) > BlockNote::MIN_PITCH && $pitch <= BlockNote::MAX_PITCH){ diff --git a/src/block/tile/Skull.php b/src/block/tile/Skull.php index 8ff40898d..30dd164c0 100644 --- a/src/block/tile/Skull.php +++ b/src/block/tile/Skull.php @@ -40,10 +40,8 @@ class Skull extends Spawnable{ private const TAG_MOUTH_MOVING = "MouthMoving"; //TAG_Byte private const TAG_MOUTH_TICK_COUNT = "MouthTickCount"; //TAG_Int - /** @var SkullType */ - private $skullType; - /** @var int */ - private $skullRotation = 0; + private SkullType $skullType; + private int $skullRotation = 0; public function __construct(World $world, Vector3 $pos){ $this->skullType = SkullType::SKELETON(); diff --git a/src/block/tile/Spawnable.php b/src/block/tile/Spawnable.php index 5184159df..b48f8a0f7 100644 --- a/src/block/tile/Spawnable.php +++ b/src/block/tile/Spawnable.php @@ -28,11 +28,8 @@ use pocketmine\network\mcpe\protocol\types\CacheableNbt; use function get_class; abstract class Spawnable extends Tile{ - /** - * @var CacheableNbt|null - * @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null - */ - private $spawnCompoundCache = null; + /** @phpstan-var CacheableNbt<\pocketmine\nbt\tag\CompoundTag>|null */ + private ?CacheableNbt $spawnCompoundCache = null; /** * @deprecated diff --git a/src/block/tile/TileFactory.php b/src/block/tile/TileFactory.php index 10c09ad55..f2cc53045 100644 --- a/src/block/tile/TileFactory.php +++ b/src/block/tile/TileFactory.php @@ -42,12 +42,12 @@ final class TileFactory{ * @var string[] classes that extend Tile * @phpstan-var array> */ - private $knownTiles = []; + private array $knownTiles = []; /** * @var string[] * @phpstan-var array, string> */ - private $saveNames = []; + private array $saveNames = []; public function __construct(){ $this->register(Barrel::class, ["Barrel", "minecraft:barrel"]); diff --git a/src/block/utils/BannerPatternLayer.php b/src/block/utils/BannerPatternLayer.php index 8095102fc..00ba8caec 100644 --- a/src/block/utils/BannerPatternLayer.php +++ b/src/block/utils/BannerPatternLayer.php @@ -30,14 +30,10 @@ use pocketmine\block\BaseBanner; * @see BaseBanner */ class BannerPatternLayer{ - private BannerPatternType $type; - /** @var DyeColor */ - private $color; - - public function __construct(BannerPatternType $type, DyeColor $color){ - $this->type = $type; - $this->color = $color; - } + public function __construct( + private BannerPatternType $type, + private DyeColor $color + ){} public function getType() : BannerPatternType{ return $this->type; } diff --git a/src/block/utils/CoralType.php b/src/block/utils/CoralType.php index 07d94d7ea..2006d3799 100644 --- a/src/block/utils/CoralType.php +++ b/src/block/utils/CoralType.php @@ -42,9 +42,6 @@ final class CoralType{ __construct as Enum___construct; } - /** @var string */ - private $displayName; - protected static function setup() : void{ self::registerAll( new self("tube", "Tube"), @@ -55,9 +52,11 @@ final class CoralType{ ); } - private function __construct(string $name, string $displayName){ + private function __construct( + string $name, + private string $displayName + ){ $this->Enum___construct($name); - $this->displayName = $displayName; } public function getDisplayName() : string{ return $this->displayName; } diff --git a/src/block/utils/DyeColor.php b/src/block/utils/DyeColor.php index 91fe73fbf..a1bb941a1 100644 --- a/src/block/utils/DyeColor.php +++ b/src/block/utils/DyeColor.php @@ -75,15 +75,12 @@ final class DyeColor{ ); } - /** @var string */ - private $displayName; - /** @var Color */ - private $rgbValue; - - private function __construct(string $enumName, string $displayName, Color $rgbValue){ + private function __construct( + string $enumName, + private string $displayName, + private Color $rgbValue + ){ $this->Enum___construct($enumName); - $this->displayName = $displayName; - $this->rgbValue = $rgbValue; } public function getDisplayName() : string{ diff --git a/src/block/utils/RecordType.php b/src/block/utils/RecordType.php index e497d419c..e6692a511 100644 --- a/src/block/utils/RecordType.php +++ b/src/block/utils/RecordType.php @@ -70,15 +70,13 @@ final class RecordType{ ); } - /** @var string */ - private $soundName; - /** @var int */ - private $soundId; - - private function __construct(string $enumName, string $soundName, int $soundId, private Translatable $translatableName){ + private function __construct( + string $enumName, + private string $soundName, + private int $soundId, + private Translatable $translatableName + ){ $this->Enum___construct($enumName); - $this->soundName = $soundName; - $this->soundId = $soundId; } public function getSoundName() : string{ diff --git a/src/block/utils/SignText.php b/src/block/utils/SignText.php index 4c7eeeb02..dd7221ac2 100644 --- a/src/block/utils/SignText.php +++ b/src/block/utils/SignText.php @@ -36,7 +36,7 @@ class SignText{ public const LINE_COUNT = 4; /** @var string[] */ - private $lines; + private array $lines; /** * @param string[]|null $lines index-sensitive; omitting an index will leave it unchanged diff --git a/src/block/utils/SkullType.php b/src/block/utils/SkullType.php index 2bbb566dd..6ec6341c0 100644 --- a/src/block/utils/SkullType.php +++ b/src/block/utils/SkullType.php @@ -45,7 +45,7 @@ final class SkullType{ } /** @var SkullType[] */ - private static $numericIdMap = []; + private static array $numericIdMap = []; protected static function setup() : void{ self::registerAll( @@ -75,15 +75,12 @@ final class SkullType{ return self::$numericIdMap[$magicNumber]; } - /** @var string */ - private $displayName; - /** @var int */ - private $magicNumber; - - private function __construct(string $enumName, string $displayName, int $magicNumber){ + private function __construct( + string $enumName, + private string $displayName, + private int $magicNumber + ){ $this->Enum___construct($enumName); - $this->displayName = $displayName; - $this->magicNumber = $magicNumber; } public function getDisplayName() : string{ diff --git a/src/block/utils/TreeType.php b/src/block/utils/TreeType.php index 7667d144d..60e796db2 100644 --- a/src/block/utils/TreeType.php +++ b/src/block/utils/TreeType.php @@ -45,7 +45,7 @@ final class TreeType{ } /** @var TreeType[] */ - private static $numericIdMap = []; + private static array $numericIdMap = []; protected static function setup() : void{ self::registerAll( @@ -76,15 +76,12 @@ final class TreeType{ return self::$numericIdMap[$magicNumber]; } - /** @var string */ - private $displayName; - /** @var int */ - private $magicNumber; - - private function __construct(string $enumName, string $displayName, int $magicNumber){ + private function __construct( + string $enumName, + private string $displayName, + private int $magicNumber + ){ $this->Enum___construct($enumName); - $this->displayName = $displayName; - $this->magicNumber = $magicNumber; } public function getDisplayName() : string{