PHPStan 1.9 features

This commit is contained in:
Dylan K. Taylor
2022-11-04 20:23:34 +00:00
parent bfd1b2c635
commit 2fdc46c165
13 changed files with 40 additions and 1 deletions

View File

@ -396,6 +396,9 @@ class World implements ChunkManager{
/**
* @phpstan-param BlockPosHash $hash
* @phpstan-param-out int $x
* @phpstan-param-out int $y
* @phpstan-param-out int $z
*/
public static function getBlockXYZ(int $hash, ?int &$x, ?int &$y, ?int &$z) : void{
[$baseX, $baseY, $baseZ] = morton3d_decode($hash);
@ -410,6 +413,8 @@ class World implements ChunkManager{
/**
* @phpstan-param ChunkPosHash $hash
* @phpstan-param-out int $x
* @phpstan-param-out int $z
*/
public static function getXZ(int $hash, ?int &$x, ?int &$z) : void{
[$x, $z] = morton2d_decode($hash);
@ -1764,6 +1769,7 @@ class World implements ChunkManager{
* It'll try to lower the durability if Item is a tool, and set it to Air if broken.
*
* @param Item $item reference parameter (if null, can break anything)
* @phpstan-param-out Item $item
*/
public function useBreakOn(Vector3 $vector, Item &$item = null, ?Player $player = null, bool $createParticles = false) : bool{
$vector = $vector->floor();

View File

@ -191,6 +191,11 @@ class LevelDB extends BaseWorldProvider implements WritableWorldProvider{
return PalettedBlockArray::fromData($bitsPerBlock, $words, $palette);
}
/**
* @phpstan-param-out int $x
* @phpstan-param-out int $y
* @phpstan-param-out int $z
*/
protected static function deserializeExtraDataKey(int $chunkVersion, int $key, ?int &$x, ?int &$y, ?int &$z) : void{
if($chunkVersion >= ChunkVersion::v1_0_0){
$x = ($key >> 12) & 0xf;

View File

@ -276,6 +276,8 @@ class RegionLoader{
/**
* @param int $x reference parameter
* @param int $z reference parameter
* @phpstan-param-out int $x
* @phpstan-param-out int $z
*/
protected static function getChunkCoords(int $offset, ?int &$x, ?int &$z) : void{
$x = $offset & 0x1f;

View File

@ -92,6 +92,8 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
/**
* @param int $regionX reference parameter
* @param int $regionZ reference parameter
* @phpstan-param-out int $regionX
* @phpstan-param-out int $regionZ
*/
public static function getRegionIndex(int $chunkX, int $chunkZ, &$regionX, &$regionZ) : void{
$regionX = $chunkX >> 5;