mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Merge commit 'da43ae82fe3b8839a4d153b0365f815cf9859d77'
# Conflicts: # resources/vanilla # src/utils/Config.php # src/utils/Timezone.php # src/utils/Utils.php
This commit is contained in:
commit
3a68f5e3d0
@ -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[] */
|
||||
@ -104,9 +104,9 @@ 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 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
|
||||
*/
|
||||
public function __construct(string $file, int $type = Config::DETECT, array $default = []){
|
||||
$this->load($file, $type, $default);
|
||||
@ -134,6 +134,8 @@ class Config{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $default
|
||||
*
|
||||
* @throws \InvalidArgumentException if config type could not be auto-detected
|
||||
* @throws \InvalidStateException if config type is invalid
|
||||
*/
|
||||
@ -424,6 +426,9 @@ class Config{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $v
|
||||
*/
|
||||
public function setAll(array $v) : void{
|
||||
$this->config = $v;
|
||||
$this->changed = true;
|
||||
@ -451,10 +456,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
|
||||
*/
|
||||
public function setDefaults(array $defaults) : void{
|
||||
$this->fillDefaults($defaults, $this->config);
|
||||
}
|
||||
|
@ -198,7 +198,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)){
|
||||
|
@ -353,7 +353,7 @@ class Utils{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array of claims
|
||||
* @return mixed[] array of claims
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
@ -390,6 +390,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){
|
||||
@ -419,6 +424,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")){
|
||||
@ -433,6 +441,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