diff --git a/src/CrashDump.php b/src/CrashDump.php index 77e193fff..a2d50d044 100644 --- a/src/CrashDump.php +++ b/src/CrashDump.php @@ -316,10 +316,16 @@ class CrashDump{ $this->addLine("OS : " . PHP_OS . ", " . Utils::getOS()); } + /** + * @param string $line + */ public function addLine($line = "") : void{ fwrite($this->fp, $line . PHP_EOL); } + /** + * @param string $str + */ public function add($str) : void{ fwrite($this->fp, $str); } diff --git a/src/network/mcpe/protocol/CraftingDataPacket.php b/src/network/mcpe/protocol/CraftingDataPacket.php index 0de48cd26..e25202b4b 100644 --- a/src/network/mcpe/protocol/CraftingDataPacket.php +++ b/src/network/mcpe/protocol/CraftingDataPacket.php @@ -161,6 +161,13 @@ class CraftingDataPacket extends DataPacket implements ClientboundPacket{ $this->cleanRecipes = $this->getBool(); } + /** + * @param object $entry + * @param NetworkBinaryStream $stream + * @param int $pos + * + * @return int + */ private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos) : int{ if($entry instanceof ShapelessRecipe){ return self::writeShapelessRecipe($entry, $stream, $pos); diff --git a/src/network/mcpe/protocol/DataPacket.php b/src/network/mcpe/protocol/DataPacket.php index 678409e27..7e90ce6c9 100644 --- a/src/network/mcpe/protocol/DataPacket.php +++ b/src/network/mcpe/protocol/DataPacket.php @@ -119,10 +119,17 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{ 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/utils/Filesystem.php b/src/utils/Filesystem.php index 094f7e45f..689a4fcdd 100644 --- a/src/utils/Filesystem.php +++ b/src/utils/Filesystem.php @@ -73,6 +73,11 @@ final class Filesystem{ } } + /** + * @param string $path + * + * @return string + */ public static function cleanPath($path){ $result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path); diff --git a/src/utils/MainLogger.php b/src/utils/MainLogger.php index 9287ecc05..af7afb8e5 100644 --- a/src/utils/MainLogger.php +++ b/src/utils/MainLogger.php @@ -223,6 +223,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) : void{ $time = new \DateTime('now', new \DateTimeZone($this->timezone)); diff --git a/src/utils/Process.php b/src/utils/Process.php index 356a1af2c..3728b159b 100644 --- a/src/utils/Process.php +++ b/src/utils/Process.php @@ -119,6 +119,9 @@ final class Process{ return count(ThreadManager::getInstance()->getAll()) + 3; //RakLib + MainLogger + Main Thread } + /** + * @param int $pid + */ public static function kill($pid) : void{ $logger = \GlobalLogger::get(); if($logger instanceof MainLogger){ diff --git a/src/utils/ReversePriorityQueue.php b/src/utils/ReversePriorityQueue.php index 0c1aafd2c..d9fa2d0e0 100644 --- a/src/utils/ReversePriorityQueue.php +++ b/src/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/utils/ServerKiller.php b/src/utils/ServerKiller.php index b8f2550d2..06059b84b 100644 --- a/src/utils/ServerKiller.php +++ b/src/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/world/generator/biome/BiomeSelector.php b/src/world/generator/biome/BiomeSelector.php index 843d520b2..187757442 100644 --- a/src/world/generator/biome/BiomeSelector.php +++ b/src/world/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/world/generator/noise/Noise.php b/src/world/generator/noise/Noise.php index 90e2b48eb..ecf42759d 100644 --- a/src/world/generator/noise/Noise.php +++ b/src/world/generator/noise/Noise.php @@ -33,10 +33,33 @@ use function assert; abstract class Noise{ + /** + * @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)); @@ -48,6 +71,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)); @@ -82,10 +126,30 @@ abstract class Noise{ $this->expansion = $expansion; } + /** + * @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; @@ -109,6 +173,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; diff --git a/src/world/generator/noise/Simplex.php b/src/world/generator/noise/Simplex.php index 85ee993b3..71ef32cff 100644 --- a/src/world/generator/noise/Simplex.php +++ b/src/world/generator/noise/Simplex.php @@ -209,6 +209,12 @@ class Simplex extends Noise{ return 32.0 * $n; } + /** + * @param float $x + * @param float $y + * + * @return float + */ public function getNoise2D($x, $y){ $x += $this->offsetX; $y += $this->offsetY; diff --git a/tests/phpstan/configs/gradual-level6.neon b/tests/phpstan/configs/gradual-level6.neon index f96da02ef..6aa3e3e80 100644 --- a/tests/phpstan/configs/gradual-level6.neon +++ b/tests/phpstan/configs/gradual-level6.neon @@ -7,6 +7,6 @@ parameters: rules: - PHPStan\Rules\Functions\MissingFunctionParameterTypehintRule - PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule - #- PHPStan\Rules\Methods\MissingMethodParameterTypehintRule + - PHPStan\Rules\Methods\MissingMethodParameterTypehintRule #- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule - PHPStan\Rules\Properties\MissingPropertyTypehintRule