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

@ -401,7 +401,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
*
* @return UUID|null
*/
public function getUniqueId(){
public function getUniqueId() : ?UUID{
return parent::getUniqueId();
}
@ -459,7 +459,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
/**
* @param Player $player
*/
public function spawnTo(Player $player){
public function spawnTo(Player $player) : void{
if($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->getLevel() === $this->level and $player->canSee($this) and !$this->isSpectator()){
parent::spawnTo($player);
}
@ -538,7 +538,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return !$this->isSpectator();
}
public function resetFallDistance(){
public function resetFallDistance() : void{
parent::resetFallDistance();
if($this->inAirTicks !== 0){
$this->startAirTicks = 5;
@ -812,7 +812,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
*
* If null is given, will additionally send the skin to the player itself as well as its viewers.
*/
public function sendSkin(array $targets = null) : void{
public function sendSkin(?array $targets = null) : void{
parent::sendSkin($targets ?? $this->server->getOnlinePlayers());
}
@ -1487,7 +1487,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return 0;
}
protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz){
protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz) : void{
if(!$this->onGround or $movY != 0){
$bb = clone $this->boundingBox;
$bb->minY = $this->y - 0.2;
@ -1637,13 +1637,13 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->newPosition = null;
}
public function jump(){
public function jump() : void{
$this->server->getPluginManager()->callEvent(new PlayerJumpEvent($this));
parent::jump();
}
public function setMotion(Vector3 $mot){
if(parent::setMotion($mot)){
public function setMotion(Vector3 $motion) : bool{
if(parent::setMotion($motion)){
$this->broadcastMotion();
if($this->motionY > 0){
@ -1655,11 +1655,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return false;
}
protected function updateMovement(bool $teleport = false){
protected function updateMovement(bool $teleport = false) : void{
}
protected function tryChangeMovement(){
protected function tryChangeMovement() : void{
}
@ -1744,7 +1744,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return true;
}
public function doFoodTick(int $tickDiff = 1){
public function doFoodTick(int $tickDiff = 1) : void{
if($this->isSurvival()){
parent::doFoodTick($tickDiff);
}
@ -1827,11 +1827,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return ($targetDot - $eyeDot) >= -$maxDiff;
}
protected function initHumanData(){
protected function initHumanData() : void{
$this->setNameTag($this->username);
}
protected function initEntity(){
protected function initEntity() : void{
parent::initEntity();
$this->addDefaultWindows();
}
@ -3340,7 +3340,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
* @param string $reason Reason showed in console
* @param bool $notify
*/
final public function close($message = "", string $reason = "generic reason", bool $notify = true){
final public function close($message = "", string $reason = "generic reason", bool $notify = true) : void{
if($this->isConnected() and !$this->closed){
try{
@ -3491,7 +3491,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
}
public function kill(){
public function kill() : void{
if(!$this->spawned){
return;
}
@ -3501,7 +3501,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->sendRespawnPacket($this->getSpawn());
}
protected function onDeath(){
protected function onDeath() : void{
$message = "death.attack.generic";
$params = [
@ -3689,7 +3689,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_DAMAGE);
}
public function attack(EntityDamageEvent $source){
public function attack(EntityDamageEvent $source) : void{
if(!$this->isAlive()){
return;
}