Skip to content

Commit

Permalink
fix PHPstan and CS
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockedPlot7560 committed Jun 14, 2024
1 parent a6ffc30 commit 409933f
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 74 deletions.
1 change: 1 addition & 0 deletions src/PocketMine.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
use const PHP_EOL;
use const PHP_INT_SIZE;
use const PHP_VERSION;
use const PTHREADS_INHERIT_NONE;

require_once __DIR__ . '/VersionInfo.php';

Expand Down
8 changes: 4 additions & 4 deletions src/block/BlockFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public function getBreakTime(Item $item) : float{
$this->remap($magicNumber >= 4 ? Ids::LOG2 : Ids::LOG, ($magicNumber & 0x03) | 0b1100, $wood);

$allSidedLogs[] = $wood;
$allSidedLogs[] = new Wood(new BID(Ids::WOOD, $magicNumber | BlockLegacyMetadata::WOOD_FLAG_STRIPPED), "Stripped $name Wood", $logBreakInfo, $treeType, true);
$allSidedLogs[] = new Wood(new BID(Ids::WOOD, $magicNumber | Meta::WOOD_FLAG_STRIPPED), "Stripped $name Wood", $logBreakInfo, $treeType, true);

$this->registerAllMeta(new Log(BlockLegacyIdHelper::getStrippedLogIdentifier($treeType), "Stripped " . $name . " Log", $logBreakInfo, $treeType, true));
$this->registerAllMeta(new FenceGate(BlockLegacyIdHelper::getWoodenFenceIdentifier($treeType), $name . " Fence Gate", $planksBreakInfo));
Expand Down Expand Up @@ -608,12 +608,12 @@ public function getBreakTime(Item $item) : float{
BreakInfo::instant(),
));
$this->registerAllMeta(new FloorCoralFan(
new BlockIdentifierFlattened(Ids::CORAL_FAN, [Ids::CORAL_FAN_DEAD], 0, ItemIds::CORAL_FAN),
new BIDFlattened(Ids::CORAL_FAN, [Ids::CORAL_FAN_DEAD], 0, ItemIds::CORAL_FAN),
"Coral Fan",
BreakInfo::instant(),
));
$this->registerAllMeta(new WallCoralFan(
new BlockIdentifierFlattened(Ids::CORAL_FAN_HANG, [Ids::CORAL_FAN_HANG2, Ids::CORAL_FAN_HANG3], 0, ItemIds::CORAL_FAN),
new BIDFlattened(Ids::CORAL_FAN_HANG, [Ids::CORAL_FAN_HANG2, Ids::CORAL_FAN_HANG3], 0, ItemIds::CORAL_FAN),
"Wall Coral Fan",
BreakInfo::instant(),
));
Expand Down Expand Up @@ -956,7 +956,7 @@ private function registerAllMeta(Block $default, Block ...$additional) : void{
private function registerSlabWithDoubleHighBitsRemapping(Slab $block) : void{
$this->register($block);
$identifierFlattened = $block->getIdInfo();
if($identifierFlattened instanceof BlockIdentifierFlattened){
if($identifierFlattened instanceof BIDFlattened){
$this->remap($identifierFlattened->getSecondId(), $identifierFlattened->getVariant() | 0x8, $block->setSlabType(SlabType::DOUBLE()));
}
}
Expand Down
120 changes: 60 additions & 60 deletions src/block/BlockLegacyIdHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,61 +69,61 @@ public static function getWoodenWallSignIdentifier(TreeType $treeType) : BID{
throw new AssumptionFailedError("Switch should cover all wood types");
}

public static function getWoodenTrapdoorIdentifier(TreeType $treeType) : BlockIdentifier{
public static function getWoodenTrapdoorIdentifier(TreeType $treeType) : BID{
switch($treeType->id()){
case TreeType::OAK()->id():
return new BlockIdentifier(Ids::WOODEN_TRAPDOOR, 0);
return new BID(Ids::WOODEN_TRAPDOOR, 0);
case TreeType::SPRUCE()->id():
return new BlockIdentifier(Ids::SPRUCE_TRAPDOOR, 0);
return new BID(Ids::SPRUCE_TRAPDOOR, 0);
case TreeType::BIRCH()->id():
return new BlockIdentifier(Ids::BIRCH_TRAPDOOR, 0);
return new BID(Ids::BIRCH_TRAPDOOR, 0);
case TreeType::JUNGLE()->id():
return new BlockIdentifier(Ids::JUNGLE_TRAPDOOR, 0);
return new BID(Ids::JUNGLE_TRAPDOOR, 0);
case TreeType::ACACIA()->id():
return new BlockIdentifier(Ids::ACACIA_TRAPDOOR, 0);
return new BID(Ids::ACACIA_TRAPDOOR, 0);
case TreeType::DARK_OAK()->id():
return new BlockIdentifier(Ids::DARK_OAK_TRAPDOOR, 0);
return new BID(Ids::DARK_OAK_TRAPDOOR, 0);
}
throw new AssumptionFailedError("Switch should cover all wood types");
}

public static function getWoodenButtonIdentifier(TreeType $treeType) : BlockIdentifier{
public static function getWoodenButtonIdentifier(TreeType $treeType) : BID{
switch($treeType->id()){
case TreeType::OAK()->id():
return new BlockIdentifier(Ids::WOODEN_BUTTON, 0);
return new BID(Ids::WOODEN_BUTTON, 0);
case TreeType::SPRUCE()->id():
return new BlockIdentifier(Ids::SPRUCE_BUTTON, 0);
return new BID(Ids::SPRUCE_BUTTON, 0);
case TreeType::BIRCH()->id():
return new BlockIdentifier(Ids::BIRCH_BUTTON, 0);
return new BID(Ids::BIRCH_BUTTON, 0);
case TreeType::JUNGLE()->id():
return new BlockIdentifier(Ids::JUNGLE_BUTTON, 0);
return new BID(Ids::JUNGLE_BUTTON, 0);
case TreeType::ACACIA()->id():
return new BlockIdentifier(Ids::ACACIA_BUTTON, 0);
return new BID(Ids::ACACIA_BUTTON, 0);
case TreeType::DARK_OAK()->id():
return new BlockIdentifier(Ids::DARK_OAK_BUTTON, 0);
return new BID(Ids::DARK_OAK_BUTTON, 0);
}
throw new AssumptionFailedError("Switch should cover all wood types");
}

public static function getWoodenPressurePlateIdentifier(TreeType $treeType) : BlockIdentifier{
public static function getWoodenPressurePlateIdentifier(TreeType $treeType) : BID{
switch($treeType->id()){
case TreeType::OAK()->id():
return new BlockIdentifier(Ids::WOODEN_PRESSURE_PLATE, 0);
return new BID(Ids::WOODEN_PRESSURE_PLATE, 0);
case TreeType::SPRUCE()->id():
return new BlockIdentifier(Ids::SPRUCE_PRESSURE_PLATE, 0);
return new BID(Ids::SPRUCE_PRESSURE_PLATE, 0);
case TreeType::BIRCH()->id():
return new BlockIdentifier(Ids::BIRCH_PRESSURE_PLATE, 0);
return new BID(Ids::BIRCH_PRESSURE_PLATE, 0);
case TreeType::JUNGLE()->id():
return new BlockIdentifier(Ids::JUNGLE_PRESSURE_PLATE, 0);
return new BID(Ids::JUNGLE_PRESSURE_PLATE, 0);
case TreeType::ACACIA()->id():
return new BlockIdentifier(Ids::ACACIA_PRESSURE_PLATE, 0);
return new BID(Ids::ACACIA_PRESSURE_PLATE, 0);
case TreeType::DARK_OAK()->id():
return new BlockIdentifier(Ids::DARK_OAK_PRESSURE_PLATE, 0);
return new BID(Ids::DARK_OAK_PRESSURE_PLATE, 0);
}
throw new AssumptionFailedError("Switch should cover all wood types");
}

public static function getWoodenDoorIdentifier(TreeType $treeType) : BlockIdentifier{
public static function getWoodenDoorIdentifier(TreeType $treeType) : BID{
switch($treeType->id()){
case TreeType::OAK()->id():
return new BID(Ids::OAK_DOOR_BLOCK, 0, ItemIds::OAK_DOOR);
Expand All @@ -141,94 +141,94 @@ public static function getWoodenDoorIdentifier(TreeType $treeType) : BlockIdenti
throw new AssumptionFailedError("Switch should cover all wood types");
}

public static function getWoodenFenceIdentifier(TreeType $treeType) : BlockIdentifier{
public static function getWoodenFenceIdentifier(TreeType $treeType) : BID{
switch($treeType->id()){
case TreeType::OAK()->id():
return new BlockIdentifier(Ids::OAK_FENCE_GATE, 0);
return new BID(Ids::OAK_FENCE_GATE, 0);
case TreeType::SPRUCE()->id():
return new BlockIdentifier(Ids::SPRUCE_FENCE_GATE, 0);
return new BID(Ids::SPRUCE_FENCE_GATE, 0);
case TreeType::BIRCH()->id():
return new BlockIdentifier(Ids::BIRCH_FENCE_GATE, 0);
return new BID(Ids::BIRCH_FENCE_GATE, 0);
case TreeType::JUNGLE()->id():
return new BlockIdentifier(Ids::JUNGLE_FENCE_GATE, 0);
return new BID(Ids::JUNGLE_FENCE_GATE, 0);
case TreeType::ACACIA()->id():
return new BlockIdentifier(Ids::ACACIA_FENCE_GATE, 0);
return new BID(Ids::ACACIA_FENCE_GATE, 0);
case TreeType::DARK_OAK()->id():
return new BlockIdentifier(Ids::DARK_OAK_FENCE_GATE, 0);
return new BID(Ids::DARK_OAK_FENCE_GATE, 0);
}
throw new AssumptionFailedError("Switch should cover all wood types");
}

public static function getWoodenStairsIdentifier(TreeType $treeType) : BlockIdentifier{
public static function getWoodenStairsIdentifier(TreeType $treeType) : BID{
switch($treeType->id()){
case TreeType::OAK()->id():
return new BlockIdentifier(Ids::OAK_STAIRS, 0);
return new BID(Ids::OAK_STAIRS, 0);
case TreeType::SPRUCE()->id():
return new BlockIdentifier(Ids::SPRUCE_STAIRS, 0);
return new BID(Ids::SPRUCE_STAIRS, 0);
case TreeType::BIRCH()->id():
return new BlockIdentifier(Ids::BIRCH_STAIRS, 0);
return new BID(Ids::BIRCH_STAIRS, 0);
case TreeType::JUNGLE()->id():
return new BlockIdentifier(Ids::JUNGLE_STAIRS, 0);
return new BID(Ids::JUNGLE_STAIRS, 0);
case TreeType::ACACIA()->id():
return new BlockIdentifier(Ids::ACACIA_STAIRS, 0);
return new BID(Ids::ACACIA_STAIRS, 0);
case TreeType::DARK_OAK()->id():
return new BlockIdentifier(Ids::DARK_OAK_STAIRS, 0);
return new BID(Ids::DARK_OAK_STAIRS, 0);
}
throw new AssumptionFailedError("Switch should cover all wood types");
}

public static function getStrippedLogIdentifier(TreeType $treeType) : BlockIdentifier{
public static function getStrippedLogIdentifier(TreeType $treeType) : BID{
switch($treeType->id()){
case TreeType::OAK()->id():
return new BlockIdentifier(Ids::STRIPPED_OAK_LOG, 0);
return new BID(Ids::STRIPPED_OAK_LOG, 0);
case TreeType::SPRUCE()->id():
return new BlockIdentifier(Ids::STRIPPED_SPRUCE_LOG, 0);
return new BID(Ids::STRIPPED_SPRUCE_LOG, 0);
case TreeType::BIRCH()->id():
return new BlockIdentifier(Ids::STRIPPED_BIRCH_LOG, 0);
return new BID(Ids::STRIPPED_BIRCH_LOG, 0);
case TreeType::JUNGLE()->id():
return new BlockIdentifier(Ids::STRIPPED_JUNGLE_LOG, 0);
return new BID(Ids::STRIPPED_JUNGLE_LOG, 0);
case TreeType::ACACIA()->id():
return new BlockIdentifier(Ids::STRIPPED_ACACIA_LOG, 0);
return new BID(Ids::STRIPPED_ACACIA_LOG, 0);
case TreeType::DARK_OAK()->id():
return new BlockIdentifier(Ids::STRIPPED_DARK_OAK_LOG, 0);
return new BID(Ids::STRIPPED_DARK_OAK_LOG, 0);
}
throw new AssumptionFailedError("Switch should cover all wood types");
}

public static function getGlazedTerracottaIdentifier(DyeColor $color) : BlockIdentifier{
public static function getGlazedTerracottaIdentifier(DyeColor $color) : BID{
switch($color->id()){
case DyeColor::WHITE()->id():
return new BlockIdentifier(Ids::WHITE_GLAZED_TERRACOTTA, 0);
return new BID(Ids::WHITE_GLAZED_TERRACOTTA, 0);
case DyeColor::ORANGE()->id():
return new BlockIdentifier(Ids::ORANGE_GLAZED_TERRACOTTA, 0);
return new BID(Ids::ORANGE_GLAZED_TERRACOTTA, 0);
case DyeColor::MAGENTA()->id():
return new BlockIdentifier(Ids::MAGENTA_GLAZED_TERRACOTTA, 0);
return new BID(Ids::MAGENTA_GLAZED_TERRACOTTA, 0);
case DyeColor::LIGHT_BLUE()->id():
return new BlockIdentifier(Ids::LIGHT_BLUE_GLAZED_TERRACOTTA, 0);
return new BID(Ids::LIGHT_BLUE_GLAZED_TERRACOTTA, 0);
case DyeColor::YELLOW()->id():
return new BlockIdentifier(Ids::YELLOW_GLAZED_TERRACOTTA, 0);
return new BID(Ids::YELLOW_GLAZED_TERRACOTTA, 0);
case DyeColor::LIME()->id():
return new BlockIdentifier(Ids::LIME_GLAZED_TERRACOTTA, 0);
return new BID(Ids::LIME_GLAZED_TERRACOTTA, 0);
case DyeColor::PINK()->id():
return new BlockIdentifier(Ids::PINK_GLAZED_TERRACOTTA, 0);
return new BID(Ids::PINK_GLAZED_TERRACOTTA, 0);
case DyeColor::GRAY()->id():
return new BlockIdentifier(Ids::GRAY_GLAZED_TERRACOTTA, 0);
return new BID(Ids::GRAY_GLAZED_TERRACOTTA, 0);
case DyeColor::LIGHT_GRAY()->id():
return new BlockIdentifier(Ids::SILVER_GLAZED_TERRACOTTA, 0);
return new BID(Ids::SILVER_GLAZED_TERRACOTTA, 0);
case DyeColor::CYAN()->id():
return new BlockIdentifier(Ids::CYAN_GLAZED_TERRACOTTA, 0);
return new BID(Ids::CYAN_GLAZED_TERRACOTTA, 0);
case DyeColor::PURPLE()->id():
return new BlockIdentifier(Ids::PURPLE_GLAZED_TERRACOTTA, 0);
return new BID(Ids::PURPLE_GLAZED_TERRACOTTA, 0);
case DyeColor::BLUE()->id():
return new BlockIdentifier(Ids::BLUE_GLAZED_TERRACOTTA, 0);
return new BID(Ids::BLUE_GLAZED_TERRACOTTA, 0);
case DyeColor::BROWN()->id():
return new BlockIdentifier(Ids::BROWN_GLAZED_TERRACOTTA, 0);
return new BID(Ids::BROWN_GLAZED_TERRACOTTA, 0);
case DyeColor::GREEN()->id():
return new BlockIdentifier(Ids::GREEN_GLAZED_TERRACOTTA, 0);
return new BID(Ids::GREEN_GLAZED_TERRACOTTA, 0);
case DyeColor::RED()->id():
return new BlockIdentifier(Ids::RED_GLAZED_TERRACOTTA, 0);
return new BID(Ids::RED_GLAZED_TERRACOTTA, 0);
case DyeColor::BLACK()->id():
return new BlockIdentifier(Ids::BLACK_GLAZED_TERRACOTTA, 0);
return new BID(Ids::BLACK_GLAZED_TERRACOTTA, 0);
}
throw new AssumptionFailedError("Switch should cover all colours");
}
Expand Down
2 changes: 1 addition & 1 deletion src/item/ItemFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public function register(Item $item, bool $override = false) : void{
$this->list[self::getListOffset($id, $variant)] = clone $item;
}

public function remap(ItemIdentifier $identifier, Item $item, bool $override = false) : void{
public function remap(IID $identifier, Item $item, bool $override = false) : void{
if(!$override && $this->isRegistered($identifier->getId(), $identifier->getMeta())){
throw new \RuntimeException("Trying to overwrite an already registered item");
}
Expand Down
1 change: 1 addition & 0 deletions src/network/mcpe/ChunkRequestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use pocketmine\network\mcpe\protocol\LevelChunkPacket;
use pocketmine\network\mcpe\protocol\serializer\PacketBatch;
use pocketmine\network\mcpe\protocol\types\ChunkPosition;
use pocketmine\network\mcpe\protocol\types\DimensionIds;
use pocketmine\network\mcpe\serializer\ChunkSerializer;
use pocketmine\scheduler\AsyncTask;
use pocketmine\utils\BinaryStream;
Expand Down
4 changes: 3 additions & 1 deletion src/network/mcpe/compression/Compressor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

namespace pocketmine\network\mcpe\compression;

use pocketmine\network\mcpe\protocol\types\CompressionAlgorithm;

interface Compressor{
/**
* @throws DecompressionException
Expand All @@ -35,7 +37,7 @@ public function compress(string $payload) : string;
* Returns the canonical ID of this compressor, used to tell the remote end how to decompress a packet compressed
* with this compressor.
*
* @return CompressionAlgorithm::*
* @phpstan-return CompressionAlgorithm::*
*/
public function getNetworkId() : int;

Expand Down
3 changes: 3 additions & 0 deletions src/network/mcpe/serializer/ChunkSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public static function serializeTiles(Chunk $chunk) : string{
return $stream->getBuffer();
}

/**
* @phpstan-param DimensionIds::* $dimensionId
*/
private static function serializeBiomesAsPalette(Chunk $chunk, int $dimensionId) : string{
[$minSubChunkIndex, $maxSubChunkIndex] = self::getDimensionChunkBounds($dimensionId);
$biomeIdMap = LegacyBiomeIdToStringIdMap::getInstance();
Expand Down
16 changes: 8 additions & 8 deletions src/utils/MainLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,38 +79,38 @@ public function setFormat(string $format) : void{
}

public function emergency($message){
$this->send($message, \LogLevel::EMERGENCY, "EMERGENCY", TextFormat::RED);
$this->send($message, LogLevel::EMERGENCY, "EMERGENCY", TextFormat::RED);
}

public function alert($message){
$this->send($message, \LogLevel::ALERT, "ALERT", TextFormat::RED);
$this->send($message, LogLevel::ALERT, "ALERT", TextFormat::RED);
}

public function critical($message){
$this->send($message, \LogLevel::CRITICAL, "CRITICAL", TextFormat::RED);
$this->send($message, LogLevel::CRITICAL, "CRITICAL", TextFormat::RED);
}

public function error($message){
$this->send($message, \LogLevel::ERROR, "ERROR", TextFormat::DARK_RED);
$this->send($message, LogLevel::ERROR, "ERROR", TextFormat::DARK_RED);
}

public function warning($message){
$this->send($message, \LogLevel::WARNING, "WARNING", TextFormat::YELLOW);
$this->send($message, LogLevel::WARNING, "WARNING", TextFormat::YELLOW);
}

public function notice($message){
$this->send($message, \LogLevel::NOTICE, "NOTICE", TextFormat::AQUA);
$this->send($message, LogLevel::NOTICE, "NOTICE", TextFormat::AQUA);
}

public function info($message){
$this->send($message, \LogLevel::INFO, "INFO", TextFormat::WHITE);
$this->send($message, LogLevel::INFO, "INFO", TextFormat::WHITE);
}

public function debug($message, bool $force = false){
if(!$this->logDebug && !$force){
return;
}
$this->send($message, \LogLevel::DEBUG, "DEBUG", TextFormat::GRAY);
$this->send($message, LogLevel::DEBUG, "DEBUG", TextFormat::GRAY);
}

public function setLogDebug(bool $logDebug) : void{
Expand Down

0 comments on commit 409933f

Please sign in to comment.