Modernize property declarations in src/world/generator

This commit is contained in:
Dylan K. Taylor 2022-04-28 13:16:21 +01:00
parent 46c504e529
commit ed2a239334
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
5 changed files with 14 additions and 28 deletions

View File

@ -34,11 +34,9 @@ use pocketmine\world\generator\populator\Populator;
use function count; use function count;
class Flat extends Generator{ class Flat extends Generator{
private Chunk $chunk;
/** @var Chunk */
private $chunk;
/** @var Populator[] */ /** @var Populator[] */
private $populators = []; private array $populators = [];
private FlatGeneratorOptions $options; private FlatGeneratorOptions $options;

View File

@ -26,11 +26,9 @@ namespace pocketmine\world\generator;
use function exp; use function exp;
final class Gaussian{ final class Gaussian{
public int $smoothSize;
/** @var int */
public $smoothSize;
/** @var float[][] */ /** @var float[][] */
public $kernel = []; public array $kernel = [];
public function __construct(int $smoothSize){ public function __construct(int $smoothSize){
$this->smoothSize = $smoothSize; $this->smoothSize = $smoothSize;

View File

@ -37,7 +37,7 @@ final class GeneratorManager{
* @var GeneratorManagerEntry[] name => classname mapping * @var GeneratorManagerEntry[] name => classname mapping
* @phpstan-var array<string, GeneratorManagerEntry> * @phpstan-var array<string, GeneratorManagerEntry>
*/ */
private $list = []; private array $list = [];
public function __construct(){ public function __construct(){
$this->addGenerator(Flat::class, "flat", \Closure::fromCallable(function(string $preset) : ?InvalidGeneratorOptionsException{ $this->addGenerator(Flat::class, "flat", \Closure::fromCallable(function(string $preset) : ?InvalidGeneratorOptionsException{

View File

@ -31,7 +31,7 @@ final class ThreadLocalGeneratorContext{
* @var self[] * @var self[]
* @phpstan-var array<int, self> * @phpstan-var array<int, self>
*/ */
private static $contexts = []; private static array $contexts = [];
public static function register(self $context, int $worldId) : void{ public static function register(self $context, int $worldId) : void{
self::$contexts[$worldId] = $context; self::$contexts[$worldId] = $context;
@ -45,19 +45,11 @@ final class ThreadLocalGeneratorContext{
return self::$contexts[$worldId] ?? null; return self::$contexts[$worldId] ?? null;
} }
/** @var Generator */ public function __construct(
private $generator; private Generator $generator,
private int $worldMinY,
/** @var int */ private int $worldMaxY
private $worldMinY; ){}
/** @var int */
private $worldMaxY;
public function __construct(Generator $generator, int $worldMinY, int $worldMaxY){
$this->generator = $generator;
$this->worldMinY = $worldMinY;
$this->worldMaxY = $worldMaxY;
}
public function getGenerator() : Generator{ return $this->generator; } public function getGenerator() : Generator{ return $this->generator; }

View File

@ -30,16 +30,14 @@ use pocketmine\world\biome\UnknownBiome;
use pocketmine\world\generator\noise\Simplex; use pocketmine\world\generator\noise\Simplex;
abstract class BiomeSelector{ abstract class BiomeSelector{
/** @var Simplex */ private Simplex $temperature;
private $temperature; private Simplex $rainfall;
/** @var Simplex */
private $rainfall;
/** /**
* @var Biome[]|\SplFixedArray * @var Biome[]|\SplFixedArray
* @phpstan-var \SplFixedArray<Biome> * @phpstan-var \SplFixedArray<Biome>
*/ */
private $map = null; private \SplFixedArray $map = null;
public function __construct(Random $random){ public function __construct(Random $random){
$this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512); $this->temperature = new Simplex($random, 2, 1 / 16, 1 / 512);