mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 20:14:31 +00:00
Merge remote-tracking branch 'origin/stable' into next-minor
This commit is contained in:
@@ -59,6 +59,7 @@ use function interface_exists;
|
||||
use function is_a;
|
||||
use function is_array;
|
||||
use function is_bool;
|
||||
use function is_float;
|
||||
use function is_infinite;
|
||||
use function is_int;
|
||||
use function is_nan;
|
||||
@@ -435,6 +436,19 @@ final class Utils{
|
||||
return $lines;
|
||||
}
|
||||
|
||||
private static function stringifyValueForTrace(mixed $value, int $maxStringLength) : string{
|
||||
return match(true){
|
||||
is_object($value) => "object " . self::getNiceClassName($value) . "#" . spl_object_id($value),
|
||||
is_array($value) => "array[" . count($value) . "]",
|
||||
is_string($value) => "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength),
|
||||
is_bool($value) => $value ? "true" : "false",
|
||||
is_int($value) => "int " . $value,
|
||||
is_float($value) => "float " . $value,
|
||||
$value === null => "null",
|
||||
default => gettype($value) . " " . Utils::printable((string) $value)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[][] $trace
|
||||
* @phpstan-param list<array<string, mixed>> $trace
|
||||
@@ -451,22 +465,15 @@ final class Utils{
|
||||
}else{
|
||||
$args = $trace[$i]["params"];
|
||||
}
|
||||
/** @var mixed[] $args */
|
||||
|
||||
$params = implode(", ", array_map(function($value) use($maxStringLength) : string{
|
||||
if(is_object($value)){
|
||||
return "object " . self::getNiceClassName($value) . "#" . spl_object_id($value);
|
||||
}
|
||||
if(is_array($value)){
|
||||
return "array[" . count($value) . "]";
|
||||
}
|
||||
if(is_string($value)){
|
||||
return "string[" . strlen($value) . "] " . substr(Utils::printable($value), 0, $maxStringLength);
|
||||
}
|
||||
if(is_bool($value)){
|
||||
return $value ? "true" : "false";
|
||||
}
|
||||
return gettype($value) . " " . Utils::printable((string) $value);
|
||||
}, $args));
|
||||
$paramsList = [];
|
||||
$offset = 0;
|
||||
foreach($args as $argId => $value){
|
||||
$paramsList[] = ($argId === $offset ? "" : "$argId: ") . self::stringifyValueForTrace($value, $maxStringLength);
|
||||
$offset++;
|
||||
}
|
||||
$params = implode(", ", $paramsList);
|
||||
}
|
||||
$messages[] = "#$i " . (isset($trace[$i]["file"]) ? Filesystem::cleanPath($trace[$i]["file"]) : "") . "(" . (isset($trace[$i]["line"]) ? $trace[$i]["line"] : "") . "): " . (isset($trace[$i]["class"]) ? $trace[$i]["class"] . (($trace[$i]["type"] === "dynamic" || $trace[$i]["type"] === "->") ? "->" : "::") : "") . $trace[$i]["function"] . "(" . Utils::printable($params) . ")";
|
||||
}
|
||||
|
Reference in New Issue
Block a user