diff --git a/src/pocketmine/network/AdvancedSourceInterface.php b/src/pocketmine/network/AdvancedSourceInterface.php index 3e58140f2..2ba728c31 100644 --- a/src/pocketmine/network/AdvancedSourceInterface.php +++ b/src/pocketmine/network/AdvancedSourceInterface.php @@ -32,23 +32,23 @@ interface AdvancedSourceInterface extends SourceInterface{ * @param string $address * @param int $timeout Seconds */ - public function blockAddress(string $address, int $timeout = 300); + public function blockAddress(string $address, int $timeout = 300) : void; /** * @param string $address */ - public function unblockAddress(string $address); + public function unblockAddress(string $address) : void; /** * @param Network $network */ - public function setNetwork(Network $network); + public function setNetwork(Network $network) : void; /** * @param string $address * @param int $port * @param string $payload */ - public function sendRawPacket(string $address, int $port, string $payload); + public function sendRawPacket(string $address, int $port, string $payload) : void; } diff --git a/src/pocketmine/network/CompressBatchedTask.php b/src/pocketmine/network/CompressBatchedTask.php index 9ddd7baae..a8aa24a6b 100644 --- a/src/pocketmine/network/CompressBatchedTask.php +++ b/src/pocketmine/network/CompressBatchedTask.php @@ -43,7 +43,7 @@ class CompressBatchedTask extends AsyncTask{ $this->storeLocal($targets); } - public function onRun(){ + public function onRun() : void{ $batch = new BatchPacket(); $batch->payload = $this->data; $this->data = null; @@ -54,7 +54,7 @@ class CompressBatchedTask extends AsyncTask{ $this->setResult($batch->buffer, false); } - public function onCompletion(Server $server){ + public function onCompletion(Server $server) : void{ $pk = new BatchPacket($this->getResult()); $pk->isEncoded = true; diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 6edb9977f..af907d77c 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -58,20 +58,20 @@ class Network{ } - public function addStatistics($upload, $download){ + public function addStatistics(float $upload, float $download) : void{ $this->upload += $upload; $this->download += $download; } - public function getUpload(){ + public function getUpload() : float{ return $this->upload; } - public function getDownload(){ + public function getDownload() : float{ return $this->download; } - public function resetStatistics(){ + public function resetStatistics() : void{ $this->upload = 0; $this->download = 0; } @@ -83,7 +83,7 @@ class Network{ return $this->interfaces; } - public function processInterfaces(){ + public function processInterfaces() : void{ foreach($this->interfaces as $interface){ $this->processInterface($interface); } @@ -109,7 +109,7 @@ class Network{ /** * @param SourceInterface $interface */ - public function registerInterface(SourceInterface $interface){ + public function registerInterface(SourceInterface $interface) : void{ $this->server->getPluginManager()->callEvent($ev = new NetworkInterfaceRegisterEvent($interface)); if(!$ev->isCancelled()){ $interface->start(); @@ -125,7 +125,7 @@ class Network{ /** * @param SourceInterface $interface */ - public function unregisterInterface(SourceInterface $interface){ + public function unregisterInterface(SourceInterface $interface) : void{ $this->server->getPluginManager()->callEvent(new NetworkInterfaceUnregisterEvent($interface)); unset($this->interfaces[$hash = spl_object_hash($interface)], $this->advancedInterfaces[$hash]); } @@ -135,7 +135,7 @@ class Network{ * * @param string $name */ - public function setName(string $name){ + public function setName(string $name) : void{ $this->name = $name; foreach($this->interfaces as $interface){ $interface->setName($this->name); @@ -149,7 +149,7 @@ class Network{ return $this->name; } - public function updateName(){ + public function updateName() : void{ foreach($this->interfaces as $interface){ $interface->setName($this->name); } @@ -167,7 +167,7 @@ class Network{ * @param int $port * @param string $payload */ - public function sendPacket(string $address, int $port, string $payload){ + public function sendPacket(string $address, int $port, string $payload) : void{ foreach($this->advancedInterfaces as $interface){ $interface->sendRawPacket($address, $port, $payload); } @@ -179,13 +179,13 @@ class Network{ * @param string $address * @param int $timeout */ - public function blockAddress(string $address, int $timeout = 300){ + public function blockAddress(string $address, int $timeout = 300) : void{ foreach($this->advancedInterfaces as $interface){ $interface->blockAddress($address, $timeout); } } - public function unblockAddress(string $address){ + public function unblockAddress(string $address) : void{ foreach($this->advancedInterfaces as $interface){ $interface->unblockAddress($address); } diff --git a/src/pocketmine/network/SourceInterface.php b/src/pocketmine/network/SourceInterface.php index e5a6b679a..e6676470c 100644 --- a/src/pocketmine/network/SourceInterface.php +++ b/src/pocketmine/network/SourceInterface.php @@ -37,7 +37,7 @@ interface SourceInterface{ /** * Performs actions needed to start the interface after it is registered. */ - public function start(); + public function start() : void; /** * Sends a DataPacket to the interface, returns an unique identifier for the packet if $needACK is true @@ -49,7 +49,7 @@ interface SourceInterface{ * * @return int|null */ - public function putPacket(Player $player, DataPacket $packet, bool $needACK = false, bool $immediate = true); + public function putPacket(Player $player, DataPacket $packet, bool $needACK = false, bool $immediate = true) : ?int; /** * Terminates the connection @@ -57,20 +57,20 @@ interface SourceInterface{ * @param Player $player * @param string $reason */ - public function close(Player $player, string $reason = "unknown reason"); + public function close(Player $player, string $reason = "unknown reason") : void; /** * @param string $name */ - public function setName(string $name); + public function setName(string $name) : void; /** * Called every tick to process events on the interface. */ public function process() : void; - public function shutdown(); + public function shutdown() : void; - public function emergencyShutdown(); + public function emergencyShutdown() : void; } diff --git a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php index 385a64540..2f651a583 100644 --- a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php +++ b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php @@ -78,7 +78,7 @@ class PlayerNetworkSessionAdapter extends NetworkSession{ $this->player = $player; } - public function handleDataPacket(DataPacket $packet){ + public function handleDataPacket(DataPacket $packet) : void{ $timings = Timings::getReceiveDataPacketTimings($packet); $timings->startTiming(); diff --git a/src/pocketmine/network/mcpe/RakLibInterface.php b/src/pocketmine/network/mcpe/RakLibInterface.php index bd3998379..2f180ddf2 100644 --- a/src/pocketmine/network/mcpe/RakLibInterface.php +++ b/src/pocketmine/network/mcpe/RakLibInterface.php @@ -91,11 +91,11 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $this->interface = new ServerHandler($this->rakLib, $this); } - public function start(){ + public function start() : void{ $this->rakLib->start(PTHREADS_INHERIT_CONSTANTS | PTHREADS_INHERIT_INI); //HACK: MainLogger needs INI and constants } - public function setNetwork(Network $network){ + public function setNetwork(Network $network) : void{ $this->network = $network; } @@ -117,7 +117,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ } } - public function close(Player $player, string $reason = "unknown reason"){ + public function close(Player $player, string $reason = "unknown reason") : void{ if(isset($this->identifiers[$h = spl_object_hash($player)])){ unset($this->players[$this->identifiers[$h]]); unset($this->identifiersACK[$this->identifiers[$h]]); @@ -126,12 +126,12 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ } } - public function shutdown(){ + public function shutdown() : void{ $this->server->getTickSleeper()->removeNotifier($this->sleeper); $this->interface->shutdown(); } - public function emergencyShutdown(){ + public function emergencyShutdown() : void{ $this->server->getTickSleeper()->removeNotifier($this->sleeper); $this->interface->emergencyShutdown(); } @@ -167,11 +167,11 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ } } - public function blockAddress(string $address, int $timeout = 300){ + public function blockAddress(string $address, int $timeout = 300) : void{ $this->interface->blockAddress($address, $timeout); } - public function unblockAddress(string $address){ + public function unblockAddress(string $address) : void{ $this->interface->unblockAddress($address); } @@ -179,7 +179,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $this->server->handlePacket($this, $address, $port, $payload); } - public function sendRawPacket(string $address, int $port, string $payload){ + public function sendRawPacket(string $address, int $port, string $payload) : void{ $this->interface->sendRaw($address, $port, $payload); } @@ -187,7 +187,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ } - public function setName(string $name){ + public function setName(string $name) : void{ $info = $this->server->getQueryInformation(); $this->interface->sendOption("name", implode(";", @@ -205,8 +205,8 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ ); } - public function setPortCheck($name){ - $this->interface->sendOption("portChecking", (bool) $name); + public function setPortCheck(bool $name) : void{ + $this->interface->sendOption("portChecking", $name); } public function handleOption(string $option, string $value) : void{ @@ -216,7 +216,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ } } - public function putPacket(Player $player, DataPacket $packet, bool $needACK = false, bool $immediate = true){ + public function putPacket(Player $player, DataPacket $packet, bool $needACK = false, bool $immediate = true) : ?int{ if(isset($this->identifiers[$h = spl_object_hash($player)])){ $identifier = $this->identifiers[$h]; if(!$packet->isEncoded){ diff --git a/src/pocketmine/network/mcpe/VerifyLoginTask.php b/src/pocketmine/network/mcpe/VerifyLoginTask.php index cf4f5d374..a509e35ef 100644 --- a/src/pocketmine/network/mcpe/VerifyLoginTask.php +++ b/src/pocketmine/network/mcpe/VerifyLoginTask.php @@ -55,7 +55,7 @@ class VerifyLoginTask extends AsyncTask{ $this->packet = $packet; } - public function onRun(){ + public function onRun() : void{ $packet = $this->packet; //Get it in a local variable to make sure it stays unserialized try{ @@ -142,7 +142,7 @@ class VerifyLoginTask extends AsyncTask{ $currentPublicKey = $claims["identityPublicKey"] ?? null; //if there are further links, the next link should be signed with this } - public function onCompletion(Server $server){ + public function onCompletion(Server $server) : void{ /** @var Player $player */ $player = $this->fetchLocal(); if($player->isClosed()){ diff --git a/src/pocketmine/network/query/QueryHandler.php b/src/pocketmine/network/query/QueryHandler.php index 7c6770097..1f238962a 100644 --- a/src/pocketmine/network/query/QueryHandler.php +++ b/src/pocketmine/network/query/QueryHandler.php @@ -58,14 +58,14 @@ class QueryHandler{ $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.server.query.running", [$addr, $port])); } - public function regenerateInfo(){ + public function regenerateInfo() : void{ $ev = $this->server->getQueryInformation(); $this->longData = $ev->getLongQuery(); $this->shortData = $ev->getShortQuery(); $this->timeout = microtime(true) + $ev->getTimeout(); } - public function regenerateToken(){ + public function regenerateToken() : void{ $this->lastToken = $this->token; $this->token = random_bytes(16); } @@ -74,7 +74,7 @@ class QueryHandler{ return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4)); } - public function handle(AdvancedSourceInterface $interface, string $address, int $port, string $packet){ + public function handle(AdvancedSourceInterface $interface, string $address, int $port, string $packet) : void{ $offset = 2; $packetType = ord($packet{$offset++}); $sessionID = Binary::readInt(substr($packet, $offset, 4)); diff --git a/src/pocketmine/network/rcon/RCON.php b/src/pocketmine/network/rcon/RCON.php index 624045789..cf57cd106 100644 --- a/src/pocketmine/network/rcon/RCON.php +++ b/src/pocketmine/network/rcon/RCON.php @@ -82,7 +82,7 @@ class RCON{ $this->server->getLogger()->info("RCON running on $addr:$port"); } - public function stop(){ + public function stop() : void{ $this->instance->close(); socket_write($this->ipcMainSocket, "\x00"); //make select() return Server::microSleep(50000); @@ -93,7 +93,7 @@ class RCON{ @socket_close($this->ipcThreadSocket); } - public function check(){ + public function check() : void{ $response = new RemoteConsoleCommandSender(); $command = $this->instance->cmd; diff --git a/src/pocketmine/network/rcon/RCONInstance.php b/src/pocketmine/network/rcon/RCONInstance.php index d1e98da2e..47790e4e6 100644 --- a/src/pocketmine/network/rcon/RCONInstance.php +++ b/src/pocketmine/network/rcon/RCONInstance.php @@ -102,11 +102,11 @@ class RCONInstance extends Thread{ return true; } - public function close(){ + public function close() : void{ $this->stop = true; } - public function run(){ + public function run() : void{ $this->registerClassLoader(); /** @var resource[] $clients */