diff --git a/src/entity/AttributeFactory.php b/src/entity/AttributeFactory.php index 1dcff9b60..e8ae4ce99 100644 --- a/src/entity/AttributeFactory.php +++ b/src/entity/AttributeFactory.php @@ -29,7 +29,7 @@ final class AttributeFactory{ use SingletonTrait; /** @var Attribute[] */ - private $attributes = []; + private array $attributes = []; public function __construct(){ $this->register(Attribute::ABSORPTION, 0.00, 340282346638528859811704183484516925440.00, 0.00); diff --git a/src/entity/AttributeMap.php b/src/entity/AttributeMap.php index cc427d929..9fc5f2acc 100644 --- a/src/entity/AttributeMap.php +++ b/src/entity/AttributeMap.php @@ -27,7 +27,7 @@ use function array_filter; class AttributeMap{ /** @var Attribute[] */ - private $attributes = []; + private array $attributes = []; public function add(Attribute $attribute) : void{ $this->attributes[$attribute->getId()] = $attribute; diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 2c5adbe98..c178c7895 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -96,8 +96,7 @@ abstract class Entity{ /** @var int */ protected $id; - /** @var EntityMetadataCollection */ - private $networkProperties; + private EntityMetadataCollection $networkProperties; /** @var EntityDamageEvent|null */ protected $lastDamageCause = null; @@ -124,10 +123,8 @@ abstract class Entity{ /** @var EntitySizeInfo */ public $size; - /** @var float */ - private $health = 20.0; - /** @var int */ - private $maxHealth = 20; + private float $health = 20.0; + private int $maxHealth = 20; /** @var float */ protected $ySize = 0.0; @@ -150,8 +147,7 @@ abstract class Entity{ /** @var bool */ protected $isStatic = false; - /** @var bool */ - private $savedWithChunk = true; + private bool $savedWithChunk = true; /** @var bool */ public $isCollided = false; @@ -181,8 +177,7 @@ abstract class Entity{ /** @var bool */ protected $closed = false; private bool $closeInFlight = false; - /** @var bool */ - private $needsDespawn = false; + private bool $needsDespawn = false; /** @var TimingsHandler */ protected $timings; diff --git a/src/entity/EntityFactory.php b/src/entity/EntityFactory.php index 4bd743042..73c33a220 100644 --- a/src/entity/EntityFactory.php +++ b/src/entity/EntityFactory.php @@ -70,12 +70,12 @@ final class EntityFactory{ * @var \Closure[] save ID => creator function * @phpstan-var array */ - private $creationFuncs = []; + private array $creationFuncs = []; /** * @var string[] * @phpstan-var array, string> */ - private $saveNames = []; + private array $saveNames = []; public function __construct(){ //define legacy save IDs first - use them for saving for maximum compatibility with Minecraft PC diff --git a/src/entity/EntitySizeInfo.php b/src/entity/EntitySizeInfo.php index 91cf7c5f7..d5ee1e697 100644 --- a/src/entity/EntitySizeInfo.php +++ b/src/entity/EntitySizeInfo.php @@ -26,16 +26,13 @@ namespace pocketmine\entity; use function min; final class EntitySizeInfo{ - /** @var float */ - private $height; - /** @var float */ - private $width; - /** @var float */ - private $eyeHeight; + private float $eyeHeight; - public function __construct(float $height, float $width, ?float $eyeHeight = null){ - $this->height = $height; - $this->width = $width; + public function __construct( + private float $height, + private float $width, + ?float $eyeHeight = null + ){ $this->eyeHeight = $eyeHeight ?? min($this->height / 2 + 0.1, $this->height); } diff --git a/src/entity/ExperienceManager.php b/src/entity/ExperienceManager.php index 4ed1c5486..cb44b3ea1 100644 --- a/src/entity/ExperienceManager.php +++ b/src/entity/ExperienceManager.php @@ -38,26 +38,18 @@ use function min; class ExperienceManager{ - /** @var Human */ - private $entity; + private Attribute $levelAttr; + private Attribute $progressAttr; - /** @var Attribute */ - private $levelAttr; - /** @var Attribute */ - private $progressAttr; + private int $totalXp = 0; - /** @var int */ - private $totalXp = 0; + private bool $canAttractXpOrbs = true; - /** @var bool */ - private $canAttractXpOrbs = true; - - /** @var int */ - private $xpCooldown = 0; - - public function __construct(Human $entity){ - $this->entity = $entity; + private int $xpCooldown = 0; + public function __construct( + private Human $entity + ){ $this->levelAttr = self::fetchAttribute($entity, Attribute::EXPERIENCE_LEVEL); $this->progressAttr = self::fetchAttribute($entity, Attribute::EXPERIENCE); } diff --git a/src/entity/HungerManager.php b/src/entity/HungerManager.php index 0f629c6f2..51dc5afad 100644 --- a/src/entity/HungerManager.php +++ b/src/entity/HungerManager.php @@ -32,25 +32,17 @@ use function min; class HungerManager{ - /** @var Human */ - private $entity; + private Attribute $hungerAttr; + private Attribute $saturationAttr; + private Attribute $exhaustionAttr; - /** @var Attribute */ - private $hungerAttr; - /** @var Attribute */ - private $saturationAttr; - /** @var Attribute */ - private $exhaustionAttr; + private int $foodTickTimer = 0; - /** @var int */ - private $foodTickTimer = 0; - - /** @var bool */ - private $enabled = true; - - public function __construct(Human $entity){ - $this->entity = $entity; + private bool $enabled = true; + public function __construct( + private Human $entity + ){ $this->hungerAttr = self::fetchAttribute($entity, Attribute::HUNGER); $this->saturationAttr = self::fetchAttribute($entity, Attribute::SATURATION); $this->exhaustionAttr = self::fetchAttribute($entity, Attribute::EXHAUSTION); diff --git a/src/entity/Skin.php b/src/entity/Skin.php index 786a6e711..96772ef84 100644 --- a/src/entity/Skin.php +++ b/src/entity/Skin.php @@ -39,16 +39,11 @@ final class Skin{ 128 * 128 * 4 ]; - /** @var string */ - private $skinId; - /** @var string */ - private $skinData; - /** @var string */ - private $capeData; - /** @var string */ - private $geometryName; - /** @var string */ - private $geometryData; + private string $skinId; + private string $skinData; + private string $capeData; + private string $geometryName; + private string $geometryData; private static function checkLength(string $string, string $name, int $maxLength) : void{ if(strlen($string) > $maxLength){ diff --git a/src/entity/Squid.php b/src/entity/Squid.php index 39e2a3637..5962ba1bb 100644 --- a/src/entity/Squid.php +++ b/src/entity/Squid.php @@ -44,8 +44,7 @@ class Squid extends WaterAnimal{ /** @var float */ public $swimSpeed = 0.1; - /** @var int */ - private $switchDirectionTicker = 0; + private int $switchDirectionTicker = 0; protected function getInitialSizeInfo() : EntitySizeInfo{ return new EntitySizeInfo(0.95, 0.95); } diff --git a/src/entity/Villager.php b/src/entity/Villager.php index 7e1c081cc..789517a87 100644 --- a/src/entity/Villager.php +++ b/src/entity/Villager.php @@ -38,10 +38,8 @@ class Villager extends Living implements Ageable{ public static function getNetworkTypeId() : string{ return EntityIds::VILLAGER; } - /** @var bool */ - private $baby = false; - /** @var int */ - private $profession = self::PROFESSION_FARMER; + private bool $baby = false; + private int $profession = self::PROFESSION_FARMER; protected function getInitialSizeInfo() : EntitySizeInfo{ return new EntitySizeInfo(1.8, 0.6); //TODO: eye height?? diff --git a/src/entity/effect/EffectInstance.php b/src/entity/effect/EffectInstance.php index 566ca1e5e..085d051fd 100644 --- a/src/entity/effect/EffectInstance.php +++ b/src/entity/effect/EffectInstance.php @@ -28,23 +28,12 @@ use pocketmine\utils\Limits; use function max; class EffectInstance{ - /** @var Effect */ - private $effectType; - - /** @var int */ - private $duration; - - /** @var int */ - private $amplifier; - - /** @var bool */ - private $visible; - - /** @var bool */ - private $ambient; - - /** @var Color */ - private $color; + private Effect $effectType; + private int $duration; + private int $amplifier; + private bool $visible; + private bool $ambient; + private Color $color; /** * @param int|null $duration Passing null will use the effect type's default duration diff --git a/src/entity/effect/EffectManager.php b/src/entity/effect/EffectManager.php index ee561229f..910a88921 100644 --- a/src/entity/effect/EffectManager.php +++ b/src/entity/effect/EffectManager.php @@ -34,9 +34,6 @@ use function spl_object_id; class EffectManager{ - /** @var Living */ - private $entity; - /** @var EffectInstance[] */ protected $effects = []; @@ -56,8 +53,9 @@ class EffectManager{ */ protected $effectRemoveHooks; - public function __construct(Living $entity){ - $this->entity = $entity; + public function __construct( + private Living $entity + ){ $this->bubbleColor = new Color(0, 0, 0, 0); $this->effectAddHooks = new ObjectSet(); $this->effectRemoveHooks = new ObjectSet(); diff --git a/src/entity/effect/PoisonEffect.php b/src/entity/effect/PoisonEffect.php index 166be76c6..0047b3b6c 100644 --- a/src/entity/effect/PoisonEffect.php +++ b/src/entity/effect/PoisonEffect.php @@ -30,9 +30,7 @@ use pocketmine\event\entity\EntityDamageEvent; use pocketmine\lang\Translatable; class PoisonEffect extends Effect{ - - /** @var bool */ - private $fatal; + private bool $fatal; public function __construct(Translatable|string $name, Color $color, bool $isBad = false, int $defaultDuration = 600, bool $hasBubbles = true, bool $fatal = false){ parent::__construct($name, $color, $isBad, $defaultDuration, $hasBubbles);