PlayerDeathEvent: fixed property type variance issue PHPStan complains about

This commit is contained in:
Dylan K. Taylor 2021-09-26 21:20:42 +01:00
parent 8e2d06a880
commit f138004913
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -36,7 +36,7 @@ use pocketmine\player\Player;
class PlayerDeathEvent extends EntityDeathEvent{
/** @var Player */
protected $entity;
protected $player;
/** @var Translatable|string */
private $deathMessage;
@ -49,6 +49,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
*/
public function __construct(Player $entity, array $drops, int $xp, Translatable|string|null $deathMessage){
parent::__construct($entity, $drops, $xp);
$this->player = $entity;
$this->deathMessage = $deathMessage ?? self::deriveMessage($entity->getDisplayName(), $entity->getLastDamageCause());
}
@ -56,11 +57,11 @@ class PlayerDeathEvent extends EntityDeathEvent{
* @return Player
*/
public function getEntity(){
return $this->entity;
return $this->player;
}
public function getPlayer() : Player{
return $this->entity;
return $this->player;
}
public function getDeathMessage() : Translatable|string{