From 17720041a33af1dcac35255fec5ee62cc097c2d6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 11 Jan 2020 21:53:24 +0000 Subject: [PATCH] phpdoc: populate missing parameter typeinfo --- src/pocketmine/CrashDump.php | 6 ++ src/pocketmine/Server.php | 6 ++ src/pocketmine/entity/AttributeMap.php | 8 ++ .../level/format/io/region/RegionLoader.php | 3 + .../level/generator/biome/BiomeSelector.php | 17 ++- .../level/generator/noise/Noise.php | 102 ++++++++++++++++++ .../level/generator/noise/Perlin.php | 6 ++ .../level/generator/noise/Simplex.php | 30 ++++++ .../level/generator/populator/TallGrass.php | 6 ++ .../level/generator/populator/Tree.php | 9 ++ src/pocketmine/network/Network.php | 4 + .../network/mcpe/RakLibInterface.php | 3 + .../mcpe/protocol/CraftingDataPacket.php | 7 ++ .../network/mcpe/protocol/DataPacket.php | 7 ++ src/pocketmine/network/rcon/RCONInstance.php | 19 ++++ src/pocketmine/plugin/MethodEventExecutor.php | 6 ++ src/pocketmine/utils/MainLogger.php | 6 ++ src/pocketmine/utils/ReversePriorityQueue.php | 7 ++ src/pocketmine/utils/ServerKiller.php | 3 + src/pocketmine/utils/Utils.php | 8 ++ 20 files changed, 260 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/CrashDump.php b/src/pocketmine/CrashDump.php index 7f251175b..49e88dfa6 100644 --- a/src/pocketmine/CrashDump.php +++ b/src/pocketmine/CrashDump.php @@ -343,10 +343,16 @@ class CrashDump{ $this->addLine("OS : " . PHP_OS . ", " . Utils::getOS()); } + /** + * @param string $line + */ public function addLine($line = ""){ fwrite($this->fp, $line . PHP_EOL); } + /** + * @param string $str + */ public function add($str){ fwrite($this->fp, $str); } diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 1880d7a88..ad065b05f 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -2204,6 +2204,9 @@ class Server{ $this->forceShutdown(); } + /** + * @param int $signo + */ public function handleSignal($signo){ if($signo === SIGTERM or $signo === SIGINT or $signo === SIGHUP){ $this->shutdown(); @@ -2470,6 +2473,9 @@ class Server{ } } + /** + * @param int $type + */ public function sendUsage($type = SendUsageTask::TYPE_STATUS){ if((bool) $this->getProperty("anonymous-statistics.enabled", true)){ $this->asyncPool->submitTask(new SendUsageTask($this, $type, $this->uniquePlayers)); diff --git a/src/pocketmine/entity/AttributeMap.php b/src/pocketmine/entity/AttributeMap.php index 82c46d071..a8d39eb30 100644 --- a/src/pocketmine/entity/AttributeMap.php +++ b/src/pocketmine/entity/AttributeMap.php @@ -58,6 +58,11 @@ class AttributeMap implements \ArrayAccess{ }); } + /** + * @param int $offset + * + * @return bool + */ public function offsetExists($offset) : bool{ return isset($this->attributes[$offset]); } @@ -79,6 +84,9 @@ class AttributeMap implements \ArrayAccess{ $this->attributes[$offset]->setValue($value); } + /** + * @param int $offset + */ public function offsetUnset($offset) : void{ throw new \RuntimeException("Could not unset an attribute from an attribute map"); } diff --git a/src/pocketmine/level/format/io/region/RegionLoader.php b/src/pocketmine/level/format/io/region/RegionLoader.php index f4dcce87f..6b87a8a0d 100644 --- a/src/pocketmine/level/format/io/region/RegionLoader.php +++ b/src/pocketmine/level/format/io/region/RegionLoader.php @@ -342,6 +342,9 @@ class RegionLoader{ fwrite($this->filePointer, pack("N*", ...$write), 4096 * 2); } + /** + * @param int $index + */ protected function writeLocationIndex($index){ fseek($this->filePointer, $index << 2); fwrite($this->filePointer, Binary::writeInt(($this->locationTable[$index]->getFirstSector() << 8) | $this->locationTable[$index]->getSectorCount()), 4); diff --git a/src/pocketmine/level/generator/biome/BiomeSelector.php b/src/pocketmine/level/generator/biome/BiomeSelector.php index d5496775a..ee7a85811 100644 --- a/src/pocketmine/level/generator/biome/BiomeSelector.php +++ b/src/pocketmine/level/generator/biome/BiomeSelector.php @@ -66,18 +66,29 @@ abstract class BiomeSelector{ } } + /** + * @param float $x + * @param float $z + * + * @return float + */ public function getTemperature($x, $z){ return ($this->temperature->noise2D($x, $z, true) + 1) / 2; } + /** + * @param float $x + * @param float $z + * + * @return float + */ public function getRainfall($x, $z){ return ($this->rainfall->noise2D($x, $z, true) + 1) / 2; } /** - * TODO: not sure on types here - * @param int|float $x - * @param int|float $z + * @param int $x + * @param int $z * * @return Biome */ diff --git a/src/pocketmine/level/generator/noise/Noise.php b/src/pocketmine/level/generator/noise/Noise.php index 9fd4ad515..46a7f5059 100644 --- a/src/pocketmine/level/generator/noise/Noise.php +++ b/src/pocketmine/level/generator/noise/Noise.php @@ -46,22 +46,62 @@ abstract class Noise{ /** @var float */ protected $expansion; + /** + * @param float $x + * + * @return int + */ public static function floor($x) : int{ return $x >= 0 ? (int) $x : (int) ($x - 1); } + /** + * @param float $x + * + * @return float + */ public static function fade($x){ return $x * $x * $x * ($x * ($x * 6 - 15) + 10); } + /** + * @param float $x + * @param float $y + * @param float $z + * + * @return float + */ public static function lerp($x, $y, $z){ return $y + $x * ($z - $y); } + /** + * @param float $x + * @param float $x1 + * @param float $x2 + * @param float $q0 + * @param float $q1 + * + * @return float + */ public static function linearLerp($x, $x1, $x2, $q0, $q1){ return (($x2 - $x) / ($x2 - $x1)) * $q0 + (($x - $x1) / ($x2 - $x1)) * $q1; } + /** + * @param float $x + * @param float $y + * @param float $q00 + * @param float $q01 + * @param float $q10 + * @param float $q11 + * @param float $x1 + * @param float $x2 + * @param float $y1 + * @param float $y2 + * + * @return float + */ public static function bilinearLerp($x, $y, $q00, $q01, $q10, $q11, $x1, $x2, $y1, $y2){ $dx1 = (($x2 - $x) / ($x2 - $x1)); $dx2 = (($x - $x1) / ($x2 - $x1)); @@ -73,6 +113,27 @@ abstract class Noise{ ); } + /** + * @param float $x + * @param float $y + * @param float $z + * @param float $q000 + * @param float $q001 + * @param float $q010 + * @param float $q011 + * @param float $q100 + * @param float $q101 + * @param float $q110 + * @param float $q111 + * @param float $x1 + * @param float $x2 + * @param float $y1 + * @param float $y2 + * @param float $z1 + * @param float $z2 + * + * @return float + */ public static function trilinearLerp($x, $y, $z, $q000, $q001, $q010, $q011, $q100, $q101, $q110, $q111, $x1, $x2, $y1, $y2, $z1, $z2){ $dx1 = (($x2 - $x) / ($x2 - $x1)); $dx2 = (($x - $x1) / ($x2 - $x1)); @@ -94,6 +155,14 @@ abstract class Noise{ ); } + /** + * @param int $hash + * @param float $x + * @param float $y + * @param float $z + * + * @return float + */ public static function grad($hash, $x, $y, $z){ $hash &= 15; $u = $hash < 8 ? $x : $y; @@ -102,10 +171,30 @@ abstract class Noise{ return (($hash & 1) === 0 ? $u : -$u) + (($hash & 2) === 0 ? $v : -$v); } + /** + * @param float $x + * @param float $z + * + * @return float + */ abstract public function getNoise2D($x, $z); + /** + * @param float $x + * @param float $y + * @param float $z + * + * @return float + */ abstract public function getNoise3D($x, $y, $z); + /** + * @param float $x + * @param float $z + * @param bool $normalized + * + * @return float + */ public function noise2D($x, $z, $normalized = false){ $result = 0; $amp = 1; @@ -129,6 +218,14 @@ abstract class Noise{ return $result; } + /** + * @param float $x + * @param float $y + * @param float $z + * @param bool $normalized + * + * @return float + */ public function noise3D($x, $y, $z, $normalized = false){ $result = 0; $amp = 1; @@ -304,6 +401,11 @@ abstract class Noise{ return $noiseArray; } + /** + * @param float $x + * @param float $y + * @param float $z + */ public function setOffset($x, $y, $z){ $this->offsetX = $x; $this->offsetY = $y; diff --git a/src/pocketmine/level/generator/noise/Perlin.php b/src/pocketmine/level/generator/noise/Perlin.php index 6c0631218..4bc5ac478 100644 --- a/src/pocketmine/level/generator/noise/Perlin.php +++ b/src/pocketmine/level/generator/noise/Perlin.php @@ -34,6 +34,12 @@ class Perlin extends Noise{ ]; + /** + * @param Random $random + * @param int $octaves + * @param float $persistence + * @param float $expansion + */ public function __construct(Random $random, $octaves, $persistence, $expansion = 1){ $this->octaves = $octaves; $this->persistence = $persistence; diff --git a/src/pocketmine/level/generator/noise/Simplex.php b/src/pocketmine/level/generator/noise/Simplex.php index cba796c0c..0d225970b 100644 --- a/src/pocketmine/level/generator/noise/Simplex.php +++ b/src/pocketmine/level/generator/noise/Simplex.php @@ -83,6 +83,12 @@ class Simplex extends Perlin{ protected $offsetW; + /** + * @param Random $random + * @param int $octaves + * @param float $persistence + * @param float $expansion + */ public function __construct(Random $random, $octaves, $persistence, $expansion = 1){ parent::__construct($random, $octaves, $persistence, $expansion); $this->offsetW = $random->nextFloat() * 256; @@ -100,14 +106,38 @@ class Simplex extends Perlin{ self::$G44 = self::$G4 * 4.0 - 1.0; } + /** + * @param int[] $g + * @param float $x + * @param float $y + * + * @return float + */ protected static function dot2D($g, $x, $y){ return $g[0] * $x + $g[1] * $y; } + /** + * @param int[] $g + * @param float $x + * @param float $y + * @param float $z + * + * @return float + */ protected static function dot3D($g, $x, $y, $z){ return $g[0] * $x + $g[1] * $y + $g[2] * $z; } + /** + * @param int[] $g + * @param float $x + * @param float $y + * @param float $z + * @param float $w + * + * @return float + */ protected static function dot4D($g, $x, $y, $z, $w){ return $g[0] * $x + $g[1] * $y + $g[2] * $z + $g[3] * $w; } diff --git a/src/pocketmine/level/generator/populator/TallGrass.php b/src/pocketmine/level/generator/populator/TallGrass.php index 1c89dddf9..5c110ead9 100644 --- a/src/pocketmine/level/generator/populator/TallGrass.php +++ b/src/pocketmine/level/generator/populator/TallGrass.php @@ -35,10 +35,16 @@ class TallGrass extends Populator{ /** @var int */ private $baseAmount = 0; + /** + * @param int $amount + */ public function setRandomAmount($amount){ $this->randomAmount = $amount; } + /** + * @param int $amount + */ public function setBaseAmount($amount){ $this->baseAmount = $amount; } diff --git a/src/pocketmine/level/generator/populator/Tree.php b/src/pocketmine/level/generator/populator/Tree.php index a9e031a00..93763c888 100644 --- a/src/pocketmine/level/generator/populator/Tree.php +++ b/src/pocketmine/level/generator/populator/Tree.php @@ -40,14 +40,23 @@ class Tree extends Populator{ /** @var int */ private $type; + /** + * @param int $type + */ public function __construct($type = Sapling::OAK){ $this->type = $type; } + /** + * @param int $amount + */ public function setRandomAmount($amount){ $this->randomAmount = $amount; } + /** + * @param int $amount + */ public function setBaseAmount($amount){ $this->baseAmount = $amount; } diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 9e6c7d7c3..1101a24ed 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -61,6 +61,10 @@ class Network{ } + /** + * @param float $upload + * @param float $download + */ public function addStatistics($upload, $download){ $this->upload += $upload; $this->download += $download; diff --git a/src/pocketmine/network/mcpe/RakLibInterface.php b/src/pocketmine/network/mcpe/RakLibInterface.php index 1877b0a13..6312bac5b 100644 --- a/src/pocketmine/network/mcpe/RakLibInterface.php +++ b/src/pocketmine/network/mcpe/RakLibInterface.php @@ -217,6 +217,9 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ ); } + /** + * @param bool $name + */ public function setPortCheck($name){ $this->interface->sendOption("portChecking", (bool) $name); } diff --git a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php index 78ae5a584..ae45fb72b 100644 --- a/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php @@ -162,6 +162,13 @@ class CraftingDataPacket extends DataPacket{ $this->cleanRecipes = $this->getBool(); } + /** + * @param object $entry + * @param NetworkBinaryStream $stream + * @param int $pos + * + * @return int + */ private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos){ if($entry instanceof ShapelessRecipe){ return self::writeShapelessRecipe($entry, $stream, $pos); diff --git a/src/pocketmine/network/mcpe/protocol/DataPacket.php b/src/pocketmine/network/mcpe/protocol/DataPacket.php index aeeeaf054..9d789f359 100644 --- a/src/pocketmine/network/mcpe/protocol/DataPacket.php +++ b/src/pocketmine/network/mcpe/protocol/DataPacket.php @@ -156,10 +156,17 @@ abstract class DataPacket extends NetworkBinaryStream{ return $data; } + /** + * @param string $name + */ public function __get($name){ throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); } + /** + * @param string $name + * @param mixed $value + */ public function __set($name, $value){ throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); } diff --git a/src/pocketmine/network/rcon/RCONInstance.php b/src/pocketmine/network/rcon/RCONInstance.php index ee4471aa9..488c5206a 100644 --- a/src/pocketmine/network/rcon/RCONInstance.php +++ b/src/pocketmine/network/rcon/RCONInstance.php @@ -95,6 +95,14 @@ class RCONInstance extends Thread{ $this->start(PTHREADS_INHERIT_NONE); } + /** + * @param resource $client + * @param int $requestID + * @param int $packetType + * @param string $payload + * + * @return int|false + */ private function writePacket($client, int $requestID, int $packetType, string $payload){ $pk = Binary::writeLInt($requestID) . Binary::writeLInt($packetType) @@ -103,6 +111,14 @@ class RCONInstance extends Thread{ return socket_write($client, Binary::writeLInt(strlen($pk)) . $pk); } + /** + * @param resource $client + * @param int $requestID reference parameter + * @param int $packetType reference parameter + * @param string $payload reference parameter + * + * @return bool + */ private function readPacket($client, ?int &$requestID, ?int &$packetType, ?string &$payload){ $d = @socket_read($client, 4); @@ -251,6 +267,9 @@ class RCONInstance extends Thread{ } } + /** + * @param resource $client + */ private function disconnectClient($client) : void{ socket_getpeername($client, $ip, $port); @socket_set_option($client, SOL_SOCKET, SO_LINGER, ["l_onoff" => 1, "l_linger" => 1]); diff --git a/src/pocketmine/plugin/MethodEventExecutor.php b/src/pocketmine/plugin/MethodEventExecutor.php index e5651846d..f25229fdb 100644 --- a/src/pocketmine/plugin/MethodEventExecutor.php +++ b/src/pocketmine/plugin/MethodEventExecutor.php @@ -31,6 +31,9 @@ class MethodEventExecutor implements EventExecutor{ /** @var string */ private $method; + /** + * @param string $method + */ public function __construct($method){ $this->method = $method; } @@ -39,6 +42,9 @@ class MethodEventExecutor implements EventExecutor{ $listener->{$this->getMethod()}($event); } + /** + * @return string + */ public function getMethod(){ return $this->method; } diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index 3ee06889b..f63730862 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -286,6 +286,12 @@ class MainLogger extends \AttachableThreadedLogger{ $this->notify(); } + /** + * @param string $message + * @param string $level + * @param string $prefix + * @param string $color + */ protected function send($message, $level, $prefix, $color){ /** @var \DateTime|null $time */ static $time = null; diff --git a/src/pocketmine/utils/ReversePriorityQueue.php b/src/pocketmine/utils/ReversePriorityQueue.php index 0c1aafd2c..d9fa2d0e0 100644 --- a/src/pocketmine/utils/ReversePriorityQueue.php +++ b/src/pocketmine/utils/ReversePriorityQueue.php @@ -25,7 +25,14 @@ namespace pocketmine\utils; class ReversePriorityQueue extends \SplPriorityQueue{ + /** + * @param mixed $priority1 + * @param mixed $priority2 + * + * @return int + */ public function compare($priority1, $priority2){ + //TODO: this will crash if non-numeric priorities are used return (int) -($priority1 - $priority2); } } diff --git a/src/pocketmine/utils/ServerKiller.php b/src/pocketmine/utils/ServerKiller.php index 4e5ff8454..934585a9c 100644 --- a/src/pocketmine/utils/ServerKiller.php +++ b/src/pocketmine/utils/ServerKiller.php @@ -35,6 +35,9 @@ class ServerKiller extends Thread{ /** @var bool */ private $stopped = false; + /** + * @param int $time + */ public function __construct($time = 15){ $this->time = $time; } diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 78e29b41f..50538bd9c 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -554,6 +554,9 @@ class Utils{ return json_decode(base64_decode(strtr($payloadB64, '-_', '+/'), true), true); } + /** + * @param int $pid + */ public static function kill($pid) : void{ if(MainLogger::isRegisteredStatic()){ MainLogger::getLogger()->syncFlushBuffer(); @@ -654,6 +657,11 @@ class Utils{ return self::printableTrace(self::currentTrace(++$skipFrames)); } + /** + * @param string $path + * + * @return string + */ public static function cleanPath($path){ $result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path);