diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 99ada2658b..82564f49db 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -2343,7 +2343,7 @@ class Server{ $p->dataPacket($pk); } - private function checkTickUpdates($currentTick, $tickTime){ + private function checkTickUpdates(int $currentTick, float $tickTime) : void{ foreach($this->players as $p){ if(!$p->loggedIn and ($tickTime - $p->creationTime) >= 10){ $p->close("", "Login timeout"); diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index 6edf9c8c1e..bd0d459f02 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -67,7 +67,7 @@ class Leaves extends Transparent{ } - protected function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null) : bool{ + protected function findLog(Block $pos, array $visited, int $distance, &$check, ?int $fromSide = null) : bool{ ++$check; $index = $pos->x . "." . $pos->y . "." . $pos->z; if(isset($visited[$index])){ diff --git a/src/pocketmine/command/PluginCommand.php b/src/pocketmine/command/PluginCommand.php index 59a1eb17e1..4c7757b590 100644 --- a/src/pocketmine/command/PluginCommand.php +++ b/src/pocketmine/command/PluginCommand.php @@ -38,7 +38,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{ * @param string $name * @param Plugin $owner */ - public function __construct($name, Plugin $owner){ + public function __construct(string $name, Plugin $owner){ parent::__construct($name); $this->owningPlugin = $owner; $this->executor = $owner; diff --git a/src/pocketmine/event/player/PlayerCommandPreprocessEvent.php b/src/pocketmine/event/player/PlayerCommandPreprocessEvent.php index be8f4c697b..80283b5ed3 100644 --- a/src/pocketmine/event/player/PlayerCommandPreprocessEvent.php +++ b/src/pocketmine/event/player/PlayerCommandPreprocessEvent.php @@ -43,7 +43,7 @@ class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable{ * @param Player $player * @param string $message */ - public function __construct(Player $player, $message){ + public function __construct(Player $player, string $message){ $this->player = $player; $this->message = $message; } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 10acf678e3..d6b125a332 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -850,7 +850,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $flags * @param bool $optimizeRebuilds */ - public function sendBlocks(array $target, array $blocks, $flags = UpdateBlockPacket::FLAG_NONE, bool $optimizeRebuilds = false){ + public function sendBlocks(array $target, array $blocks, int $flags = UpdateBlockPacket::FLAG_NONE, bool $optimizeRebuilds = false){ $packets = []; if($optimizeRebuilds){ $chunks = []; @@ -2067,7 +2067,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getChunkEntities($X, $Z) : array{ + public function getChunkEntities(int $X, int $Z) : array{ return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getEntities() : []; } @@ -2079,7 +2079,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Tile[] */ - public function getChunkTiles($X, $Z) : array{ + public function getChunkTiles(int $X, int $Z) : array{ return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getTiles() : []; } diff --git a/src/pocketmine/level/SimpleChunkManager.php b/src/pocketmine/level/SimpleChunkManager.php index 4c4e673bf0..051176d148 100644 --- a/src/pocketmine/level/SimpleChunkManager.php +++ b/src/pocketmine/level/SimpleChunkManager.php @@ -39,7 +39,7 @@ class SimpleChunkManager implements ChunkManager{ * @param int $seed * @param int $worldHeight */ - public function __construct($seed, int $worldHeight = Level::Y_MAX){ + public function __construct(int $seed, int $worldHeight = Level::Y_MAX){ $this->seed = $seed; $this->worldHeight = $worldHeight; } diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index 1415a98198..f1156a487e 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -186,7 +186,7 @@ class Chunk{ * * @return bool */ - public function setBlock(int $x, int $y, int $z, $blockId = null, $meta = null) : bool{ + public function setBlock(int $x, int $y, int $z, ?int $blockId = null, ?int $meta = null) : bool{ if($this->getSubChunk($y >> 4, true)->setBlock($x, $y & 0x0f, $z, $blockId !== null ? ($blockId & 0xff) : null, $meta !== null ? ($meta & 0x0f) : null)){ $this->hasChanged = true; return true; diff --git a/src/pocketmine/level/format/EmptySubChunk.php b/src/pocketmine/level/format/EmptySubChunk.php index 5ffb2942d3..7d8c22544b 100644 --- a/src/pocketmine/level/format/EmptySubChunk.php +++ b/src/pocketmine/level/format/EmptySubChunk.php @@ -59,7 +59,7 @@ class EmptySubChunk implements SubChunkInterface{ return 0; } - public function setBlock(int $x, int $y, int $z, $id = null, $data = null) : bool{ + public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{ return false; } diff --git a/src/pocketmine/level/format/SubChunk.php b/src/pocketmine/level/format/SubChunk.php index 74c6625212..33ce57d6b5 100644 --- a/src/pocketmine/level/format/SubChunk.php +++ b/src/pocketmine/level/format/SubChunk.php @@ -93,7 +93,7 @@ class SubChunk implements SubChunkInterface{ } } - public function setBlock(int $x, int $y, int $z, $id = null, $data = null) : bool{ + public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{ $i = ($x << 8) | ($z << 4) | $y; $changed = false; if($id !== null){ diff --git a/src/pocketmine/level/format/SubChunkInterface.php b/src/pocketmine/level/format/SubChunkInterface.php index 6cfaf945c1..b0c8164035 100644 --- a/src/pocketmine/level/format/SubChunkInterface.php +++ b/src/pocketmine/level/format/SubChunkInterface.php @@ -87,7 +87,7 @@ interface SubChunkInterface{ * * @return bool */ - public function setBlock(int $x, int $y, int $z, $id = null, $data = null) : bool; + public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool; /** * @param int $x diff --git a/src/pocketmine/level/generator/populator/TallGrass.php b/src/pocketmine/level/generator/populator/TallGrass.php index 2aab240e39..a601799466 100644 --- a/src/pocketmine/level/generator/populator/TallGrass.php +++ b/src/pocketmine/level/generator/populator/TallGrass.php @@ -56,12 +56,12 @@ class TallGrass extends Populator{ } } - private function canTallGrassStay($x, $y, $z){ + private function canTallGrassStay(int $x, int $y, int $z) : bool{ $b = $this->level->getBlockIdAt($x, $y, $z); return ($b === Block::AIR or $b === Block::SNOW_LAYER) and $this->level->getBlockIdAt($x, $y - 1, $z) === Block::GRASS; } - private function getHighestWorkableBlock($x, $z){ + private function getHighestWorkableBlock(int $x, int $z) : int{ for($y = 127; $y >= 0; --$y){ $b = $this->level->getBlockIdAt($x, $y, $z); if($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER){ diff --git a/src/pocketmine/level/generator/populator/Tree.php b/src/pocketmine/level/generator/populator/Tree.php index 85bb071eb3..cbe8e6bcee 100644 --- a/src/pocketmine/level/generator/populator/Tree.php +++ b/src/pocketmine/level/generator/populator/Tree.php @@ -63,7 +63,7 @@ class Tree extends Populator{ } } - private function getHighestWorkableBlock($x, $z){ + private function getHighestWorkableBlock(int $x, int $z) : int{ for($y = 127; $y > 0; --$y){ $b = $this->level->getBlockIdAt($x, $y, $z); if($b === Block::DIRT or $b === Block::GRASS){ diff --git a/src/pocketmine/network/query/QueryHandler.php b/src/pocketmine/network/query/QueryHandler.php index 1cb9de5014..ea2fa81749 100644 --- a/src/pocketmine/network/query/QueryHandler.php +++ b/src/pocketmine/network/query/QueryHandler.php @@ -70,7 +70,7 @@ class QueryHandler{ $this->token = random_bytes(16); } - public static function getTokenString($token, $salt){ + public static function getTokenString(string $token, string $salt) : int{ return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4)); } diff --git a/src/pocketmine/network/rcon/RCONInstance.php b/src/pocketmine/network/rcon/RCONInstance.php index 64224ff770..495f6ecccd 100644 --- a/src/pocketmine/network/rcon/RCONInstance.php +++ b/src/pocketmine/network/rcon/RCONInstance.php @@ -71,15 +71,15 @@ class RCONInstance extends Thread{ $this->start(PTHREADS_INHERIT_NONE); } - private function writePacket($client, $requestID, $packetType, $payload){ - $pk = Binary::writeLInt((int) $requestID) - . Binary::writeLInt((int) $packetType) + private function writePacket($client, int $requestID, int $packetType, string $payload){ + $pk = Binary::writeLInt($requestID) + . Binary::writeLInt($packetType) . $payload . "\x00\x00"; //Terminate payload and packet return socket_write($client, Binary::writeLInt(strlen($pk)) . $pk); } - private function readPacket($client, &$requestID, &$packetType, &$payload){ + private function readPacket($client, ?int &$requestID, ?int &$packetType, ?string &$payload){ $d = socket_read($client, 4); if($this->stop){ return false; diff --git a/src/pocketmine/permission/Permission.php b/src/pocketmine/permission/Permission.php index 8b0942dea1..2e4ff4b7a4 100644 --- a/src/pocketmine/permission/Permission.php +++ b/src/pocketmine/permission/Permission.php @@ -178,7 +178,7 @@ class Permission{ * * @return Permission|null Permission if $name is a string, null if it's a Permission */ - public function addParent($name, $value){ + public function addParent($name, bool $value){ if($name instanceof Permission){ $name->getChildren()[$this->getName()] = $value; $name->recalculatePermissibles(); diff --git a/src/pocketmine/plugin/PharPluginLoader.php b/src/pocketmine/plugin/PharPluginLoader.php index 5e78d13760..40c7a90648 100644 --- a/src/pocketmine/plugin/PharPluginLoader.php +++ b/src/pocketmine/plugin/PharPluginLoader.php @@ -112,7 +112,7 @@ class PharPluginLoader implements PluginLoader{ * @param string $dataFolder * @param string $file */ - private function initPlugin(PluginBase $plugin, PluginDescription $description, $dataFolder, $file){ + private function initPlugin(PluginBase $plugin, PluginDescription $description, string $dataFolder, string $file){ $plugin->init($this, $this->server, $description, $dataFolder, $file); $plugin->onLoad(); } diff --git a/src/pocketmine/plugin/PluginBase.php b/src/pocketmine/plugin/PluginBase.php index de66a85d2f..d90f51a763 100644 --- a/src/pocketmine/plugin/PluginBase.php +++ b/src/pocketmine/plugin/PluginBase.php @@ -113,7 +113,7 @@ abstract class PluginBase implements Plugin{ return $this->description; } - final public function init(PluginLoader $loader, Server $server, PluginDescription $description, $dataFolder, $file){ + final public function init(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file){ if(!$this->initialized){ $this->initialized = true; $this->loader = $loader; diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index d980b841a2..88b048afe0 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -110,13 +110,13 @@ abstract class Tile extends Position{ } /** - * @param $className - * @param array $saveNames + * @param string $className + * @param array $saveNames * * @return bool * @throws \ReflectionException */ - public static function registerTile($className, array $saveNames = []) : bool{ + public static function registerTile(string $className, array $saveNames = []) : bool{ $class = new \ReflectionClass($className); if(is_a($className, Tile::class, true) and !$class->isAbstract()){ $shortName = $class->getShortName(); diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 82b9aed6c9..290f5bd30e 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -569,7 +569,7 @@ class Utils{ * * @return int */ - public static function getReferenceCount($value, $includeCurrent = true){ + public static function getReferenceCount($value, bool $includeCurrent = true){ ob_start(); debug_zval_dump($value); $ret = explode("\n", ob_get_contents());