phpdoc armageddon for master, pass 1

This commit is contained in:
Dylan K. Taylor
2020-01-22 11:55:03 +00:00
parent 4bae3baa74
commit 67bcc1c0fb
397 changed files with 0 additions and 5391 deletions

View File

@@ -46,7 +46,6 @@ final class Color{
/**
* Returns the alpha (opacity) value of this colour.
* @return int
*/
public function getA() : int{
return $this->a;
@@ -54,7 +53,6 @@ final class Color{
/**
* Retuns the red value of this colour.
* @return int
*/
public function getR() : int{
return $this->r;
@@ -62,7 +60,6 @@ final class Color{
/**
* Returns the green value of this colour.
* @return int
*/
public function getG() : int{
return $this->g;
@@ -70,7 +67,6 @@ final class Color{
/**
* Returns the blue value of this colour.
* @return int
*/
public function getB() : int{
return $this->b;
@@ -79,10 +75,7 @@ final class Color{
/**
* Mixes the supplied list of colours together to produce a result colour.
*
* @param Color $color1
* @param Color ...$colors
*
* @return Color
*/
public static function mix(Color $color1, Color ...$colors) : Color{
$colors[] = $color1;
@@ -102,10 +95,6 @@ final class Color{
/**
* Returns a Color from the supplied RGB colour code (24-bit)
*
* @param int $code
*
* @return Color
*/
public static function fromRGB(int $code) : Color{
return new Color(($code >> 16) & 0xff, ($code >> 8) & 0xff, $code & 0xff);
@@ -113,10 +102,6 @@ final class Color{
/**
* Returns a Color from the supplied ARGB colour code (32-bit)
*
* @param int $code
*
* @return Color
*/
public static function fromARGB(int $code) : Color{
return new Color(($code >> 16) & 0xff, ($code >> 8) & 0xff, $code & 0xff, ($code >> 24) & 0xff);
@@ -124,7 +109,6 @@ final class Color{
/**
* Returns an ARGB 32-bit colour value.
* @return int
*/
public function toARGB() : int{
return ($this->a << 24) | ($this->r << 16) | ($this->g << 8) | $this->b;
@@ -132,10 +116,6 @@ final class Color{
/**
* Returns a Color from the supplied RGBA colour code (32-bit)
*
* @param int $c
*
* @return Color
*/
public static function fromRGBA(int $c) : Color{
return new Color(($c >> 24) & 0xff, ($c >> 16) & 0xff, ($c >> 8) & 0xff, $c & 0xff);
@@ -143,7 +123,6 @@ final class Color{
/**
* Returns an RGBA 32-bit colour value.
* @return int
*/
public function toRGBA() : int{
return ($this->r << 24) | ($this->g << 16) | ($this->b << 8) | $this->a;

View File

@@ -129,20 +129,11 @@ class Config{
$this->changed = $changed;
}
/**
* @param string $str
*
* @return string
*/
public static function fixYAMLIndexes(string $str) : string{
return preg_replace("#^( *)(y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF)( *)\:#m", "$1\"$2\"$3:", $str);
}
/**
* @param string $file
* @param int $type
* @param array $default
*
* @throws \InvalidArgumentException if config type could not be auto-detected
* @throws \InvalidStateException if config type is invalid
*/
@@ -196,8 +187,6 @@ class Config{
/**
* Returns the path of the config.
*
* @return string
*/
public function getPath() : string{
return $this->file;
@@ -238,8 +227,6 @@ class Config{
/**
* Sets the options for the JSON encoding when saving
*
* @param int $options
*
* @return Config $this
* @throws \RuntimeException if the Config is not in JSON
* @see json_encode
@@ -257,8 +244,6 @@ class Config{
/**
* Enables the given option in addition to the currently set JSON options
*
* @param int $option
*
* @return Config $this
* @throws \RuntimeException if the Config is not in JSON
* @see json_encode
@@ -276,8 +261,6 @@ class Config{
/**
* Disables the given option for the JSON encoding when saving
*
* @param int $option
*
* @return Config $this
* @throws \RuntimeException if the Config is not in JSON
* @see json_encode
@@ -295,7 +278,6 @@ class Config{
/**
* Returns the options for the JSON encoding when saving
*
* @return int
* @throws \RuntimeException if the Config is not in JSON
* @see json_encode
*/
@@ -442,9 +424,6 @@ class Config{
}
}
/**
* @param array $v
*/
public function setAll(array $v) : void{
$this->config = $v;
$this->changed = true;
@@ -453,8 +432,6 @@ class Config{
/**
* @param string $k
* @param bool $lowercase If set, searches Config in single-case / lowercase.
*
* @return bool
*/
public function exists($k, bool $lowercase = false) : bool{
if($lowercase){
@@ -474,27 +451,16 @@ class Config{
$this->changed = true;
}
/**
* @param bool $keys
*
* @return array
*/
public function getAll(bool $keys = false) : array{
return ($keys ? array_keys($this->config) : $this->config);
}
/**
* @param array $defaults
*/
public function setDefaults(array $defaults) : void{
$this->fillDefaults($defaults, $this->config);
}
/**
* @param array $default
* @param array $data reference parameter
*
* @return int
*/
private function fillDefaults(array $default, &$data) : int{
$changed = 0;
@@ -517,9 +483,6 @@ class Config{
return $changed;
}
/**
* @param string $content
*/
private function parseList(string $content) : void{
foreach(explode("\n", trim(str_replace("\r\n", "\n", $content))) as $v){
$v = trim($v);
@@ -530,9 +493,6 @@ class Config{
}
}
/**
* @return string
*/
private function writeProperties() : string{
$content = "#Properties Config file\r\n#" . date("D M j H:i:s T Y") . "\r\n";
foreach($this->config as $k => $v){
@@ -547,9 +507,6 @@ class Config{
return $content;
}
/**
* @param string $content
*/
private function parseProperties(string $content) : void{
if(preg_match_all('/^\s*([a-zA-Z0-9\-_\.]+)[ \t]*=([^\r\n]*)/um', $content, $matches) > 0){ //false or 0 matches
foreach($matches[1] as $i => $k){

View File

@@ -32,8 +32,6 @@ trait EnumTrait{
/**
* Registers the given object as an enum member.
*
* @param self $member
*
* @throws \InvalidArgumentException
*/
protected static function register(self $member) : void{
@@ -77,9 +75,6 @@ trait EnumTrait{
* Returns the enum member matching the given name.
* This is overridden to change the return typehint.
*
* @param string $name
*
* @return self
* @throws \InvalidArgumentException if no member matches.
*/
public static function fromString(string $name) : self{
@@ -95,7 +90,6 @@ trait EnumTrait{
private $runtimeId;
/**
* @param string $enumName
* @throws \InvalidArgumentException
*/
private function __construct(string $enumName){
@@ -110,9 +104,6 @@ trait EnumTrait{
$this->runtimeId = self::$nextId++;
}
/**
* @return string
*/
public function name() : string{
return $this->enumName;
}
@@ -121,8 +112,6 @@ trait EnumTrait{
* Returns a runtime-only identifier for this enum member. This will be different with each run, so don't try to
* hardcode it.
* This can be useful for switches or array indexing.
*
* @return int
*/
public function id() : int{
return $this->runtimeId;
@@ -130,10 +119,6 @@ trait EnumTrait{
/**
* Returns whether the two objects are equivalent.
*
* @param self $other
*
* @return bool
*/
public function equals(self $other) : bool{
return $this->enumName === $other->enumName;

View File

@@ -101,8 +101,6 @@ final class Filesystem{
* inform other processes that some file or folder is already in use, to avoid data corruption.
* If this function succeeds in gaining a lock on the file, it writes the current PID to the file.
*
* @param string $lockFilePath
*
* @return int|null process ID of the process currently holding the lock failure, null on success.
* @throws \InvalidArgumentException if the lock file path is invalid (e.g. parent directory doesn't exist, permission denied)
*/
@@ -132,7 +130,6 @@ final class Filesystem{
/**
* Releases a file lock previously acquired by createLockFile() and deletes the lock file.
*
* @param string $lockFilePath
* @throws \InvalidArgumentException if the lock file path is invalid (e.g. parent directory doesn't exist, permission denied)
*/
public static function releaseLockFile(string $lockFilePath) : void{

View File

@@ -36,10 +36,7 @@ final class Git{
/**
* Returns the git hash of the currently checked out head of the given repository, or null on failure.
*
* @param string $dir
* @param bool $dirty reference parameter, set to whether the repo has local changes
*
* @return string|null
*/
public static function getRepositoryState(string $dir, bool &$dirty) : ?string{
if(Process::execute("git -C \"$dir\" rev-parse HEAD", $out) === 0 and $out !== false and strlen($out = trim($out)) === 40){
@@ -54,10 +51,6 @@ final class Git{
/**
* Infallible, returns a string representing git state, or a string of zeros on failure.
* If the repo is dirty, a "-dirty" suffix is added.
*
* @param string $dir
*
* @return string
*/
public static function getRepositoryStatePretty(string $dir) : string{
$dirty = false;

View File

@@ -113,7 +113,6 @@ class Internet{
* Returns the machine's internal network IP address. If the machine is not behind a router, this may be the same
* as the external IP.
*
* @return string
* @throws InternetException
*/
public static function getInternalIP() : string{
@@ -135,9 +134,7 @@ class Internet{
* GETs an URL using cURL
* NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
*
* @param string $page
* @param int $timeout default 10
* @param array $extraHeaders
* @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
* @param array[] $headers reference parameter
* @param int $httpCode reference parameter
@@ -158,10 +155,7 @@ class Internet{
* POSTs data to an URL
* NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
*
* @param string $page
* @param array|string $args
* @param int $timeout
* @param array $extraHeaders
* @param string $err reference parameter, will be set to the output of curl_error(). Use this to retrieve errors that occured during the operation.
* @param array[] $headers reference parameter
* @param int $httpCode reference parameter
@@ -185,7 +179,6 @@ class Internet{
* General cURL shorthand function.
* NOTE: This is a blocking operation and can take a significant amount of time. It is inadvisable to use this method on the main thread.
*
* @param string $page
* @param float|int $timeout The maximum connect timeout and timeout in seconds, correct to ms.
* @param string[] $extraHeaders extra headers to send as a plain string array
* @param array $extraOpts extra CURLOPT_* to set as an [opt => value] map

View File

@@ -61,9 +61,6 @@ class MainLogger extends \AttachableThreadedLogger{
private $timezone;
/**
* @param string $logFile
* @param bool $logDebug
*
* @throws \RuntimeException
*/
public function __construct(string $logFile, bool $logDebug = false){
@@ -82,8 +79,6 @@ class MainLogger extends \AttachableThreadedLogger{
/**
* Returns the current logger format used for console output.
*
* @return string
*/
public function getFormat() : string{
return $this->format;
@@ -99,8 +94,6 @@ class MainLogger extends \AttachableThreadedLogger{
* - message
*
* @see http://php.net/manual/en/function.sprintf.php
*
* @param string $format
*/
public function setFormat(string $format) : void{
$this->format = $format;
@@ -141,15 +134,11 @@ class MainLogger extends \AttachableThreadedLogger{
$this->send($message, \LogLevel::DEBUG, "DEBUG", TextFormat::GRAY);
}
/**
* @param bool $logDebug
*/
public function setLogDebug(bool $logDebug) : void{
$this->logDebug = $logDebug;
}
/**
* @param \Throwable $e
* @param array|null $trace
*
* @return void

View File

@@ -47,8 +47,6 @@ final class Process{
}
/**
* @param bool $advanced
*
* @return int[]|int
*/
public static function getMemoryUsage(bool $advanced = false){

View File

@@ -86,8 +86,6 @@ class Random{
/**
* Returns an 31-bit integer (not signed)
*
* @return int
*/
public function nextInt() : int{
return $this->nextSignedInt() & 0x7fffffff;
@@ -95,8 +93,6 @@ class Random{
/**
* Returns a 32-bit integer (signed)
*
* @return int
*/
public function nextSignedInt() : int{
$t = ($this->x ^ ($this->x << 11)) & 0xffffffff;
@@ -112,8 +108,6 @@ class Random{
/**
* Returns a float between 0.0 and 1.0 (inclusive)
*
* @return float
*/
public function nextFloat() : float{
return $this->nextInt() / 0x7fffffff;
@@ -121,8 +115,6 @@ class Random{
/**
* Returns a float between -1.0 and 1.0 (inclusive)
*
* @return float
*/
public function nextSignedFloat() : float{
return $this->nextSignedInt() / 0x7fffffff;
@@ -130,8 +122,6 @@ class Random{
/**
* Returns a random boolean
*
* @return bool
*/
public function nextBoolean() : bool{
return ($this->nextSignedInt() & 0x01) === 0;
@@ -142,8 +132,6 @@ class Random{
*
* @param int $start default 0
* @param int $end default 0x7fffffff
*
* @return int
*/
public function nextRange(int $start = 0, int $end = 0x7fffffff) : int{
return $start + ($this->nextInt() % ($end + 1 - $start));

View File

@@ -39,9 +39,6 @@ trait RegistryTrait{
/**
* Adds the given object to the registry.
*
* @param string $name
* @param object $member
*
* @throws \InvalidArgumentException
*/
private static function _registryRegister(string $name, object $member) : void{
@@ -72,9 +69,6 @@ trait RegistryTrait{
}
/**
* @param string $name
*
* @return object
* @throws \InvalidArgumentException
*/
private static function _registryFromString(string $name) : object{
@@ -113,8 +107,6 @@ trait RegistryTrait{
/**
* Generates code for static methods for all known registry members.
*
* @return string
*/
public static function _generateGetters() : string{
$lines = [];
@@ -132,8 +124,6 @@ public static function %1$s() : %2$s{
/**
* Generates a block of @ method annotations for accessors for this registry's known members.
*
* @return string
*/
public static function _generateMethodAnnotations() : string{
$traitName = (new \ReflectionClass(__TRAIT__))->getShortName();

View File

@@ -199,8 +199,6 @@ abstract class Terminal{
* Note that this is platform-dependent and might produce different results depending on the terminal type and/or OS.
*
* @param string|array $string
*
* @return string
*/
public static function toANSI($string) : string{
if(!is_array($string)){
@@ -289,8 +287,6 @@ abstract class Terminal{
/**
* Emits a string containing Minecraft colour codes to the console formatted with native colours.
*
* @param string $line
*/
public static function write(string $line) : void{
echo self::toANSI($line);
@@ -299,8 +295,6 @@ abstract class Terminal{
/**
* Emits a string containing Minecraft colour codes to the console formatted with native colours, followed by a
* newline character.
*
* @param string $line
*/
public static function writeLine(string $line) : void{
echo self::toANSI($line) . self::$FORMAT_RESET . PHP_EOL;

View File

@@ -68,10 +68,6 @@ abstract class TextFormat{
/**
* Splits the string by Format tokens
*
* @param string $string
*
* @return array
*/
public static function tokenize(string $string) : array{
return preg_split("/(" . TextFormat::ESCAPE . "[0-9a-fk-or])/u", $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
@@ -80,9 +76,6 @@ abstract class TextFormat{
/**
* Cleans the string from Minecraft codes, ANSI Escape Codes and invalid UTF-8 characters
*
* @param string $string
* @param bool $removeFormat
*
* @return string valid clean UTF-8
*/
public static function clean(string $string, bool $removeFormat = true) : string{
@@ -97,10 +90,7 @@ abstract class TextFormat{
/**
* Replaces placeholders of § with the correct character. Only valid codes (as in the constants of the TextFormat class) will be converted.
*
* @param string $string
* @param string $placeholder default "&"
*
* @return string
*/
public static function colorize(string $string, string $placeholder = "&") : string{
return preg_replace('/' . preg_quote($placeholder, "/") . '([0-9a-fk-or])/u', TextFormat::ESCAPE . '$1', $string);
@@ -110,8 +100,6 @@ abstract class TextFormat{
* Returns an JSON-formatted string with colors/markup
*
* @param string|array $string
*
* @return string
*/
public static function toJSON($string) : string{
if(!is_array($string)){
@@ -298,8 +286,6 @@ abstract class TextFormat{
* Returns an HTML-formatted string with colors/markup
*
* @param string|array $string
*
* @return string
*/
public static function toHTML($string) : string{
if(!is_array($string)){

View File

@@ -60,10 +60,7 @@ final class UUID{
/**
* Creates an UUID from an hexadecimal representation
*
* @param string $uuid
* @param int $version
*
* @return UUID
*/
public static function fromString(string $uuid, ?int $version = null) : UUID{
return self::fromBinary(hex2bin(str_replace("-", "", trim($uuid))), $version);
@@ -72,11 +69,8 @@ final class UUID{
/**
* Creates an UUID from a binary representation
*
* @param string $uuid
* @param int $version
*
* @return UUID
*
* @throws \InvalidArgumentException
*/
public static function fromBinary(string $uuid, ?int $version = null) : UUID{
@@ -91,8 +85,6 @@ final class UUID{
* Creates an UUIDv3 from binary data or list of binary data
*
* @param string ...$data
*
* @return UUID
*/
public static function fromData(string ...$data) : UUID{
$hash = hash("md5", implode($data), true);
@@ -120,8 +112,6 @@ final class UUID{
}
/**
* @param int $partNumber
*
* @return int
* @throws \InvalidArgumentException
*/

View File

@@ -95,9 +95,6 @@ class Utils{
/**
* Returns a readable identifier for the given Closure, including file and line.
*
* @param \Closure $closure
*
* @return string
* @throws \ReflectionException
*/
public static function getNiceClosureName(\Closure $closure) : string{
@@ -123,9 +120,6 @@ class Utils{
/**
* Returns a readable identifier for the class of the given object. Sanitizes class names for anonymous classes.
*
* @param object $obj
*
* @return string
* @throws \ReflectionException
*/
public static function getNiceClassName(object $obj) : string{
@@ -163,8 +157,6 @@ class Utils{
* The rest of the hash will change depending on other factors.
*
* @param string $extra optional, additional data to identify the machine
*
* @return UUID
*/
public static function getMachineUniqueId(string $extra = "") : UUID{
if(self::$serverUniqueId !== null and $extra === ""){
@@ -233,10 +225,6 @@ class Utils{
* Linux => Linux
* BSD => bsd
* Other => other
*
* @param bool $recalculate
*
* @return string
*/
public static function getOS(bool $recalculate = false) : string{
if(self::$os === null or $recalculate){
@@ -265,11 +253,6 @@ class Utils{
return self::$os;
}
/**
* @param bool $recalculate
*
* @return int
*/
public static function getCoreCount(bool $recalculate = false) : int{
static $processors = 0;
@@ -307,10 +290,6 @@ class Utils{
/**
* Returns a prettified hexdump
*
* @param string $bin
*
* @return string
*/
public static function hexdump(string $bin) : string{
$output = "";
@@ -329,8 +308,6 @@ class Utils{
* Returns a string that can be printed, replaces non-printable characters
*
* @param mixed $str
*
* @return string
*/
public static function printable($str) : string{
if(!is_string($str)){
@@ -373,8 +350,6 @@ class Utils{
/**
* @param string $token
*
* @return array of claims
*
* @throws \UnexpectedValueException
@@ -399,9 +374,6 @@ class Utils{
/**
* @param object $value
* @param bool $includeCurrent
*
* @return int
*/
public static function getReferenceCount($value, bool $includeCurrent = true) : int{
ob_start();
@@ -415,12 +387,6 @@ class Utils{
return -1;
}
/**
* @param array $trace
* @param int $maxStringLength
*
* @return array
*/
public static function printableTrace(array $trace, int $maxStringLength = 80) : array{
$messages = [];
for($i = 0; isset($trace[$i]); ++$i){
@@ -450,11 +416,6 @@ class Utils{
return $messages;
}
/**
* @param int $skipFrames
*
* @return array
*/
public static function currentTrace(int $skipFrames = 0) : array{
++$skipFrames; //omit this frame from trace, in addition to other skipped frames
if(function_exists("xdebug_get_function_stack")){
@@ -469,11 +430,6 @@ class Utils{
return array_values($trace);
}
/**
* @param int $skipFrames
*
* @return array
*/
public static function printableCurrentTrace(int $skipFrames = 0) : array{
return self::printableTrace(self::currentTrace(++$skipFrames));
}
@@ -481,8 +437,6 @@ class Utils{
/**
* Extracts one-line tags from the doc-comment
*
* @param string $docComment
*
* @return string[] an array of tagName => tag value. If the tag has no value, an empty string is used as the value.
*/
public static function parseDocComment(string $docComment) : array{

View File

@@ -48,11 +48,6 @@ class VersionString{
/** @var bool */
private $development = false;
/**
* @param string $baseVersion
* @param bool $isDevBuild
* @param int $buildNumber
*/
public function __construct(string $baseVersion, bool $isDevBuild = false, int $buildNumber = 0){
$this->baseVersion = $baseVersion;
$this->development = $isDevBuild;
@@ -117,12 +112,6 @@ class VersionString{
return $this->getFullVersion();
}
/**
* @param VersionString $target
* @param bool $diff
*
* @return int
*/
public function compare(VersionString $target, bool $diff = false) : int{
$number = $this->getNumber();
$tNumber = $target->getNumber();