Hinting up Entity API to PHP 7.2 standards

This commit is contained in:
Dylan K. Taylor
2018-05-19 10:46:47 +01:00
parent 389990e0a8
commit 0bb5e88b5c
17 changed files with 181 additions and 171 deletions

View File

@ -48,7 +48,7 @@ class Arrow extends Projectile{
protected $damage = 2;
public function __construct(Level $level, CompoundTag $nbt, Entity $shootingEntity = null, bool $critical = false){
public function __construct(Level $level, CompoundTag $nbt, ?Entity $shootingEntity = null, bool $critical = false){
parent::__construct($level, $nbt, $shootingEntity);
$this->setCritical($critical);
}
@ -57,7 +57,7 @@ class Arrow extends Projectile{
return $this->getGenericFlag(self::DATA_FLAG_CRITICAL);
}
public function setCritical(bool $value = true){
public function setCritical(bool $value = true) : void{
$this->setGenericFlag(self::DATA_FLAG_CRITICAL, $value);
}
@ -95,7 +95,7 @@ class Arrow extends Projectile{
$this->broadcastEntityEvent(EntityEventPacket::ARROW_SHAKE, 7); //7 ticks
}
public function onCollideWithPlayer(Player $player){
public function onCollideWithPlayer(Player $player) : void{
if($this->blockHit === null){
return;
}

View File

@ -55,20 +55,20 @@ abstract class Projectile extends Entity{
/** @var int|null */
protected $blockHitData;
public function __construct(Level $level, CompoundTag $nbt, Entity $shootingEntity = null){
public function __construct(Level $level, CompoundTag $nbt, ?Entity $shootingEntity = null){
parent::__construct($level, $nbt);
if($shootingEntity !== null){
$this->setOwningEntity($shootingEntity);
}
}
public function attack(EntityDamageEvent $source){
public function attack(EntityDamageEvent $source) : void{
if($source->getCause() === EntityDamageEvent::CAUSE_VOID){
parent::attack($source);
}
}
protected function initEntity(){
protected function initEntity() : void{
parent::initEntity();
$this->setMaxHealth(1);
@ -120,7 +120,7 @@ abstract class Projectile extends Entity{
return (int) ceil(sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2) * $this->damage);
}
public function saveNBT(){
public function saveNBT() : void{
parent::saveNBT();
$this->namedtag->setShort("Age", $this->age);

View File

@ -42,13 +42,13 @@ class SplashPotion extends Throwable{
protected $gravity = 0.05;
protected $drag = 0.01;
protected function initEntity(){
protected function initEntity() : void{
parent::initEntity();
$this->setPotionId($this->namedtag->getShort("PotionId", 0));
}
public function saveNBT(){
public function saveNBT() : void{
parent::saveNBT();
$this->namedtag->setShort("PotionId", $this->getPotionId());
}