phpdoc: populate missing parameter typeinfo

This commit is contained in:
Dylan K. Taylor 2020-01-11 21:53:24 +00:00
parent c329ff7d4f
commit 17720041a3
20 changed files with 260 additions and 3 deletions

View File

@ -343,10 +343,16 @@ class CrashDump{
$this->addLine("OS : " . PHP_OS . ", " . Utils::getOS()); $this->addLine("OS : " . PHP_OS . ", " . Utils::getOS());
} }
/**
* @param string $line
*/
public function addLine($line = ""){ public function addLine($line = ""){
fwrite($this->fp, $line . PHP_EOL); fwrite($this->fp, $line . PHP_EOL);
} }
/**
* @param string $str
*/
public function add($str){ public function add($str){
fwrite($this->fp, $str); fwrite($this->fp, $str);
} }

View File

@ -2204,6 +2204,9 @@ class Server{
$this->forceShutdown(); $this->forceShutdown();
} }
/**
* @param int $signo
*/
public function handleSignal($signo){ public function handleSignal($signo){
if($signo === SIGTERM or $signo === SIGINT or $signo === SIGHUP){ if($signo === SIGTERM or $signo === SIGINT or $signo === SIGHUP){
$this->shutdown(); $this->shutdown();
@ -2470,6 +2473,9 @@ class Server{
} }
} }
/**
* @param int $type
*/
public function sendUsage($type = SendUsageTask::TYPE_STATUS){ public function sendUsage($type = SendUsageTask::TYPE_STATUS){
if((bool) $this->getProperty("anonymous-statistics.enabled", true)){ if((bool) $this->getProperty("anonymous-statistics.enabled", true)){
$this->asyncPool->submitTask(new SendUsageTask($this, $type, $this->uniquePlayers)); $this->asyncPool->submitTask(new SendUsageTask($this, $type, $this->uniquePlayers));

View File

@ -58,6 +58,11 @@ class AttributeMap implements \ArrayAccess{
}); });
} }
/**
* @param int $offset
*
* @return bool
*/
public function offsetExists($offset) : bool{ public function offsetExists($offset) : bool{
return isset($this->attributes[$offset]); return isset($this->attributes[$offset]);
} }
@ -79,6 +84,9 @@ class AttributeMap implements \ArrayAccess{
$this->attributes[$offset]->setValue($value); $this->attributes[$offset]->setValue($value);
} }
/**
* @param int $offset
*/
public function offsetUnset($offset) : void{ public function offsetUnset($offset) : void{
throw new \RuntimeException("Could not unset an attribute from an attribute map"); throw new \RuntimeException("Could not unset an attribute from an attribute map");
} }

View File

@ -342,6 +342,9 @@ class RegionLoader{
fwrite($this->filePointer, pack("N*", ...$write), 4096 * 2); fwrite($this->filePointer, pack("N*", ...$write), 4096 * 2);
} }
/**
* @param int $index
*/
protected function writeLocationIndex($index){ protected function writeLocationIndex($index){
fseek($this->filePointer, $index << 2); fseek($this->filePointer, $index << 2);
fwrite($this->filePointer, Binary::writeInt(($this->locationTable[$index]->getFirstSector() << 8) | $this->locationTable[$index]->getSectorCount()), 4); fwrite($this->filePointer, Binary::writeInt(($this->locationTable[$index]->getFirstSector() << 8) | $this->locationTable[$index]->getSectorCount()), 4);

View File

@ -66,18 +66,29 @@ abstract class BiomeSelector{
} }
} }
/**
* @param float $x
* @param float $z
*
* @return float
*/
public function getTemperature($x, $z){ public function getTemperature($x, $z){
return ($this->temperature->noise2D($x, $z, true) + 1) / 2; return ($this->temperature->noise2D($x, $z, true) + 1) / 2;
} }
/**
* @param float $x
* @param float $z
*
* @return float
*/
public function getRainfall($x, $z){ public function getRainfall($x, $z){
return ($this->rainfall->noise2D($x, $z, true) + 1) / 2; return ($this->rainfall->noise2D($x, $z, true) + 1) / 2;
} }
/** /**
* TODO: not sure on types here * @param int $x
* @param int|float $x * @param int $z
* @param int|float $z
* *
* @return Biome * @return Biome
*/ */

View File

@ -46,22 +46,62 @@ abstract class Noise{
/** @var float */ /** @var float */
protected $expansion; protected $expansion;
/**
* @param float $x
*
* @return int
*/
public static function floor($x) : int{ public static function floor($x) : int{
return $x >= 0 ? (int) $x : (int) ($x - 1); return $x >= 0 ? (int) $x : (int) ($x - 1);
} }
/**
* @param float $x
*
* @return float
*/
public static function fade($x){ public static function fade($x){
return $x * $x * $x * ($x * ($x * 6 - 15) + 10); 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){ public static function lerp($x, $y, $z){
return $y + $x * ($z - $y); 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){ public static function linearLerp($x, $x1, $x2, $q0, $q1){
return (($x2 - $x) / ($x2 - $x1)) * $q0 + (($x - $x1) / ($x2 - $x1)) * $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){ public static function bilinearLerp($x, $y, $q00, $q01, $q10, $q11, $x1, $x2, $y1, $y2){
$dx1 = (($x2 - $x) / ($x2 - $x1)); $dx1 = (($x2 - $x) / ($x2 - $x1));
$dx2 = (($x - $x1) / ($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){ 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)); $dx1 = (($x2 - $x) / ($x2 - $x1));
$dx2 = (($x - $x1) / ($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){ public static function grad($hash, $x, $y, $z){
$hash &= 15; $hash &= 15;
$u = $hash < 8 ? $x : $y; $u = $hash < 8 ? $x : $y;
@ -102,10 +171,30 @@ abstract class Noise{
return (($hash & 1) === 0 ? $u : -$u) + (($hash & 2) === 0 ? $v : -$v); 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); abstract public function getNoise2D($x, $z);
/**
* @param float $x
* @param float $y
* @param float $z
*
* @return float
*/
abstract public function getNoise3D($x, $y, $z); 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){ public function noise2D($x, $z, $normalized = false){
$result = 0; $result = 0;
$amp = 1; $amp = 1;
@ -129,6 +218,14 @@ abstract class Noise{
return $result; return $result;
} }
/**
* @param float $x
* @param float $y
* @param float $z
* @param bool $normalized
*
* @return float
*/
public function noise3D($x, $y, $z, $normalized = false){ public function noise3D($x, $y, $z, $normalized = false){
$result = 0; $result = 0;
$amp = 1; $amp = 1;
@ -304,6 +401,11 @@ abstract class Noise{
return $noiseArray; return $noiseArray;
} }
/**
* @param float $x
* @param float $y
* @param float $z
*/
public function setOffset($x, $y, $z){ public function setOffset($x, $y, $z){
$this->offsetX = $x; $this->offsetX = $x;
$this->offsetY = $y; $this->offsetY = $y;

View File

@ -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){ public function __construct(Random $random, $octaves, $persistence, $expansion = 1){
$this->octaves = $octaves; $this->octaves = $octaves;
$this->persistence = $persistence; $this->persistence = $persistence;

View File

@ -83,6 +83,12 @@ class Simplex extends Perlin{
protected $offsetW; protected $offsetW;
/**
* @param Random $random
* @param int $octaves
* @param float $persistence
* @param float $expansion
*/
public function __construct(Random $random, $octaves, $persistence, $expansion = 1){ public function __construct(Random $random, $octaves, $persistence, $expansion = 1){
parent::__construct($random, $octaves, $persistence, $expansion); parent::__construct($random, $octaves, $persistence, $expansion);
$this->offsetW = $random->nextFloat() * 256; $this->offsetW = $random->nextFloat() * 256;
@ -100,14 +106,38 @@ class Simplex extends Perlin{
self::$G44 = self::$G4 * 4.0 - 1.0; 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){ protected static function dot2D($g, $x, $y){
return $g[0] * $x + $g[1] * $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){ protected static function dot3D($g, $x, $y, $z){
return $g[0] * $x + $g[1] * $y + $g[2] * $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){ protected static function dot4D($g, $x, $y, $z, $w){
return $g[0] * $x + $g[1] * $y + $g[2] * $z + $g[3] * $w; return $g[0] * $x + $g[1] * $y + $g[2] * $z + $g[3] * $w;
} }

View File

@ -35,10 +35,16 @@ class TallGrass extends Populator{
/** @var int */ /** @var int */
private $baseAmount = 0; private $baseAmount = 0;
/**
* @param int $amount
*/
public function setRandomAmount($amount){ public function setRandomAmount($amount){
$this->randomAmount = $amount; $this->randomAmount = $amount;
} }
/**
* @param int $amount
*/
public function setBaseAmount($amount){ public function setBaseAmount($amount){
$this->baseAmount = $amount; $this->baseAmount = $amount;
} }

View File

@ -40,14 +40,23 @@ class Tree extends Populator{
/** @var int */ /** @var int */
private $type; private $type;
/**
* @param int $type
*/
public function __construct($type = Sapling::OAK){ public function __construct($type = Sapling::OAK){
$this->type = $type; $this->type = $type;
} }
/**
* @param int $amount
*/
public function setRandomAmount($amount){ public function setRandomAmount($amount){
$this->randomAmount = $amount; $this->randomAmount = $amount;
} }
/**
* @param int $amount
*/
public function setBaseAmount($amount){ public function setBaseAmount($amount){
$this->baseAmount = $amount; $this->baseAmount = $amount;
} }

View File

@ -61,6 +61,10 @@ class Network{
} }
/**
* @param float $upload
* @param float $download
*/
public function addStatistics($upload, $download){ public function addStatistics($upload, $download){
$this->upload += $upload; $this->upload += $upload;
$this->download += $download; $this->download += $download;

View File

@ -217,6 +217,9 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
); );
} }
/**
* @param bool $name
*/
public function setPortCheck($name){ public function setPortCheck($name){
$this->interface->sendOption("portChecking", (bool) $name); $this->interface->sendOption("portChecking", (bool) $name);
} }

View File

@ -162,6 +162,13 @@ class CraftingDataPacket extends DataPacket{
$this->cleanRecipes = $this->getBool(); $this->cleanRecipes = $this->getBool();
} }
/**
* @param object $entry
* @param NetworkBinaryStream $stream
* @param int $pos
*
* @return int
*/
private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos){ private static function writeEntry($entry, NetworkBinaryStream $stream, int $pos){
if($entry instanceof ShapelessRecipe){ if($entry instanceof ShapelessRecipe){
return self::writeShapelessRecipe($entry, $stream, $pos); return self::writeShapelessRecipe($entry, $stream, $pos);

View File

@ -156,10 +156,17 @@ abstract class DataPacket extends NetworkBinaryStream{
return $data; return $data;
} }
/**
* @param string $name
*/
public function __get($name){ public function __get($name){
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
} }
/**
* @param string $name
* @param mixed $value
*/
public function __set($name, $value){ public function __set($name, $value){
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name); throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
} }

View File

@ -95,6 +95,14 @@ class RCONInstance extends Thread{
$this->start(PTHREADS_INHERIT_NONE); $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){ private function writePacket($client, int $requestID, int $packetType, string $payload){
$pk = Binary::writeLInt($requestID) $pk = Binary::writeLInt($requestID)
. Binary::writeLInt($packetType) . Binary::writeLInt($packetType)
@ -103,6 +111,14 @@ class RCONInstance extends Thread{
return socket_write($client, Binary::writeLInt(strlen($pk)) . $pk); 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){ private function readPacket($client, ?int &$requestID, ?int &$packetType, ?string &$payload){
$d = @socket_read($client, 4); $d = @socket_read($client, 4);
@ -251,6 +267,9 @@ class RCONInstance extends Thread{
} }
} }
/**
* @param resource $client
*/
private function disconnectClient($client) : void{ private function disconnectClient($client) : void{
socket_getpeername($client, $ip, $port); socket_getpeername($client, $ip, $port);
@socket_set_option($client, SOL_SOCKET, SO_LINGER, ["l_onoff" => 1, "l_linger" => 1]); @socket_set_option($client, SOL_SOCKET, SO_LINGER, ["l_onoff" => 1, "l_linger" => 1]);

View File

@ -31,6 +31,9 @@ class MethodEventExecutor implements EventExecutor{
/** @var string */ /** @var string */
private $method; private $method;
/**
* @param string $method
*/
public function __construct($method){ public function __construct($method){
$this->method = $method; $this->method = $method;
} }
@ -39,6 +42,9 @@ class MethodEventExecutor implements EventExecutor{
$listener->{$this->getMethod()}($event); $listener->{$this->getMethod()}($event);
} }
/**
* @return string
*/
public function getMethod(){ public function getMethod(){
return $this->method; return $this->method;
} }

View File

@ -286,6 +286,12 @@ class MainLogger extends \AttachableThreadedLogger{
$this->notify(); $this->notify();
} }
/**
* @param string $message
* @param string $level
* @param string $prefix
* @param string $color
*/
protected function send($message, $level, $prefix, $color){ protected function send($message, $level, $prefix, $color){
/** @var \DateTime|null $time */ /** @var \DateTime|null $time */
static $time = null; static $time = null;

View File

@ -25,7 +25,14 @@ namespace pocketmine\utils;
class ReversePriorityQueue extends \SplPriorityQueue{ class ReversePriorityQueue extends \SplPriorityQueue{
/**
* @param mixed $priority1
* @param mixed $priority2
*
* @return int
*/
public function compare($priority1, $priority2){ public function compare($priority1, $priority2){
//TODO: this will crash if non-numeric priorities are used
return (int) -($priority1 - $priority2); return (int) -($priority1 - $priority2);
} }
} }

View File

@ -35,6 +35,9 @@ class ServerKiller extends Thread{
/** @var bool */ /** @var bool */
private $stopped = false; private $stopped = false;
/**
* @param int $time
*/
public function __construct($time = 15){ public function __construct($time = 15){
$this->time = $time; $this->time = $time;
} }

View File

@ -554,6 +554,9 @@ class Utils{
return json_decode(base64_decode(strtr($payloadB64, '-_', '+/'), true), true); return json_decode(base64_decode(strtr($payloadB64, '-_', '+/'), true), true);
} }
/**
* @param int $pid
*/
public static function kill($pid) : void{ public static function kill($pid) : void{
if(MainLogger::isRegisteredStatic()){ if(MainLogger::isRegisteredStatic()){
MainLogger::getLogger()->syncFlushBuffer(); MainLogger::getLogger()->syncFlushBuffer();
@ -654,6 +657,11 @@ class Utils{
return self::printableTrace(self::currentTrace(++$skipFrames)); return self::printableTrace(self::currentTrace(++$skipFrames));
} }
/**
* @param string $path
*
* @return string
*/
public static function cleanPath($path){ public static function cleanPath($path){
$result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path); $result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path);