mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
populate missing array value types in utils namespace, pass 1
This commit is contained in:
parent
60b405d944
commit
da43ae82fe
@ -68,7 +68,7 @@ class Config{
|
||||
public const ENUM = 5; // .txt, .list, .enum
|
||||
public const ENUMERATION = Config::ENUM;
|
||||
|
||||
/** @var array */
|
||||
/** @var mixed[] */
|
||||
private $config = [];
|
||||
|
||||
/** @var mixed[] */
|
||||
@ -106,10 +106,10 @@ class Config{
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $file Path of the file to be loaded
|
||||
* @param int $type Config type to load, -1 by default (detect)
|
||||
* @param array $default Array with the default values that will be written to the file if it did not exist
|
||||
* @param null $correct reference parameter, Sets correct to true if everything has been loaded correctly
|
||||
* @param string $file Path of the file to be loaded
|
||||
* @param int $type Config type to load, -1 by default (detect)
|
||||
* @param mixed[] $default Array with the default values that will be written to the file if it did not exist
|
||||
* @param null $correct reference parameter, Sets correct to true if everything has been loaded correctly
|
||||
*/
|
||||
public function __construct(string $file, int $type = Config::DETECT, array $default = [], &$correct = null){
|
||||
$this->load($file, $type, $default);
|
||||
@ -140,6 +140,9 @@ class Config{
|
||||
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 mixed[] $default
|
||||
*/
|
||||
public function load(string $file, int $type = Config::DETECT, array $default = []) : bool{
|
||||
$this->correct = true;
|
||||
$this->file = $file;
|
||||
@ -441,6 +444,8 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $v
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAll(array $v){
|
||||
@ -472,11 +477,16 @@ class Config{
|
||||
$this->changed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getAll(bool $keys = false) : array{
|
||||
return ($keys ? array_keys($this->config) : $this->config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $defaults
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaults(array $defaults){
|
||||
|
@ -203,7 +203,7 @@ abstract class Terminal{
|
||||
* Returns a string with colorized ANSI Escape codes for the current terminal
|
||||
* Note that this is platform-dependent and might produce different results depending on the terminal type and/or OS.
|
||||
*
|
||||
* @param string|array $string
|
||||
* @param string|string[] $string
|
||||
*/
|
||||
public static function toANSI($string) : string{
|
||||
if(!is_array($string)){
|
||||
|
@ -68,6 +68,8 @@ abstract class TextFormat{
|
||||
|
||||
/**
|
||||
* Splits the string by Format tokens
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
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);
|
||||
@ -99,7 +101,7 @@ abstract class TextFormat{
|
||||
/**
|
||||
* Returns an JSON-formatted string with colors/markup
|
||||
*
|
||||
* @param string|array $string
|
||||
* @param string|string[] $string
|
||||
*/
|
||||
public static function toJSON($string) : string{
|
||||
if(!is_array($string)){
|
||||
@ -285,7 +287,7 @@ abstract class TextFormat{
|
||||
/**
|
||||
* Returns an HTML-formatted string with colors/markup
|
||||
*
|
||||
* @param string|array $string
|
||||
* @param string|string[] $string
|
||||
*/
|
||||
public static function toHTML($string) : string{
|
||||
if(!is_array($string)){
|
||||
|
@ -51,6 +51,9 @@ abstract class Timezone{
|
||||
return ini_get('date.timezone');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function init() : array{
|
||||
$messages = [];
|
||||
do{
|
||||
|
@ -524,6 +524,9 @@ class Utils{
|
||||
return proc_close($process);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public static function decodeJWT(string $token) : array{
|
||||
list($headB64, $payloadB64, $sigB64) = explode(".", $token);
|
||||
|
||||
@ -569,6 +572,11 @@ class Utils{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[][] $trace
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function printableTrace(array $trace, int $maxStringLength = 80) : array{
|
||||
$messages = [];
|
||||
for($i = 0; isset($trace[$i]); ++$i){
|
||||
@ -598,6 +606,9 @@ class Utils{
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed[][]
|
||||
*/
|
||||
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")){
|
||||
@ -612,6 +623,9 @@ class Utils{
|
||||
return array_values($trace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function printableCurrentTrace(int $skipFrames = 0) : array{
|
||||
return self::printableTrace(self::currentTrace(++$skipFrames));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user