Modernize property type declarations

This commit is contained in:
Dylan K. Taylor
2022-06-04 18:16:32 +01:00
parent 23695fb900
commit 083a35f970
114 changed files with 431 additions and 863 deletions

View File

@ -27,8 +27,7 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity;
class EntityCombustByBlockEvent extends EntityCombustEvent{
/** @var Block */
protected $combuster;
protected Block $combuster;
public function __construct(Block $combuster, Entity $combustee, int $duration){
parent::__construct($combustee, $duration);

View File

@ -26,8 +26,7 @@ namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
class EntityCombustByEntityEvent extends EntityCombustEvent{
/** @var Entity */
protected $combuster;
protected Entity $combuster;
public function __construct(Entity $combuster, Entity $combustee, int $duration){
parent::__construct($combustee, $duration);

View File

@ -33,8 +33,7 @@ use pocketmine\event\CancellableTrait;
class EntityCombustEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var int */
protected $duration;
protected int $duration;
public function __construct(Entity $combustee, int $duration){
$this->entity = $combustee;

View File

@ -33,11 +33,8 @@ use pocketmine\event\Event;
* @phpstan-template TEntity of Entity
*/
abstract class EntityEvent extends Event{
/**
* @var Entity
* @phpstan-var TEntity
*/
protected $entity;
/** @phpstan-var TEntity */
protected Entity $entity;
/**
* @return Entity

View File

@ -41,27 +41,20 @@ use pocketmine\world\Position;
class EntityExplodeEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var Position */
protected $position;
/** @var Block[] */
protected $blocks;
/** @var float */
protected $yield;
/**
* @param Block[] $blocks
* @param float $yield 0-100
*/
public function __construct(Entity $entity, Position $position, array $blocks, float $yield){
public function __construct(
Entity $entity,
protected Position $position,
protected array $blocks,
protected float $yield
){
$this->entity = $entity;
$this->position = $position;
$this->blocks = $blocks;
if($yield < 0.0 || $yield > 100.0){
throw new \InvalidArgumentException("Yield must be in range 0.0 - 100.0");
}
$this->yield = $yield;
}
public function getPosition() : Position{

View File

@ -38,16 +38,16 @@ use pocketmine\event\CancellableTrait;
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var float */
protected $force;
private bool $blockBreaking = true;
public function __construct(Entity $entity, float $force){
public function __construct(
Entity $entity,
protected float $force
){
if($force <= 0){
throw new \InvalidArgumentException("Explosion radius must be positive");
}
$this->entity = $entity;
$this->force = $force;
}
public function getForce() : float{