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

@@ -48,35 +48,27 @@ use function sqrt;
class Explosion{
private int $rays = 16;
/** @var World */
public $world;
/** @var Position */
public $source;
/** @var float */
public $size;
public World $world;
/** @var Block[] */
public $affectedBlocks = [];
/** @var float */
public $stepLen = 0.3;
private Entity|Block|null $what;
public array $affectedBlocks = [];
public float $stepLen = 0.3;
private SubChunkExplorer $subChunkExplorer;
public function __construct(Position $center, float $size, Entity|Block|null $what = null){
if(!$center->isValid()){
public function __construct(
public Position $source,
public float $size,
private Entity|Block|null $what = null
){
if(!$this->source->isValid()){
throw new \InvalidArgumentException("Position does not have a valid world");
}
$this->source = $center;
$this->world = $center->getWorld();
$this->world = $this->source->getWorld();
if($size <= 0){
throw new \InvalidArgumentException("Explosion radius must be greater than 0, got $size");
}
$this->size = $size;
$this->what = $what;
$this->subChunkExplorer = new SubChunkExplorer($this->world);
}