Big collection of functions
Definition at line 103 of file Utils.php.
◆ assumeNotFalse()
static pocketmine\utils\Utils::assumeNotFalse |
( |
mixed | $value, |
|
|
\Closure|string | $context = "This should never be false" ) |
|
static |
@phpstan-template TValue @phpstan-param TValue|false $value @phpstan-param string|\Closure() : string $context @phpstan-return TValue
Definition at line 623 of file Utils.php.
◆ checkFloatNotInfOrNaN()
static pocketmine\utils\Utils::checkFloatNotInfOrNaN |
( |
string | $name, |
|
|
float | $float ) |
|
static |
◆ checkLocationNotInfOrNaN()
static pocketmine\utils\Utils::checkLocationNotInfOrNaN |
( |
Location | $location | ) |
|
|
static |
◆ checkUTF8()
static pocketmine\utils\Utils::checkUTF8 |
( |
string | $string | ) |
|
|
static |
◆ checkVector3NotInfOrNaN()
static pocketmine\utils\Utils::checkVector3NotInfOrNaN |
( |
Vector3 | $vector3 | ) |
|
|
static |
◆ cloneCallback()
static pocketmine\utils\Utils::cloneCallback |
( |
| ) |
|
|
static |
@phpstan-return \Closure(object) : object
Definition at line 169 of file Utils.php.
◆ cloneObjectArray()
static pocketmine\utils\Utils::cloneObjectArray |
( |
array | $array | ) |
|
|
static |
@phpstan-template TKey of array-key @phpstan-template TValue of object
- Parameters
-
object[] | $array | @phpstan-param array<TKey, TValue> $array |
- Returns
- object[] @phpstan-return array<TKey, TValue>
Definition at line 185 of file Utils.php.
◆ currentTrace()
static pocketmine\utils\Utils::currentTrace |
( |
int | $skipFrames = 0 | ) |
|
|
static |
- Returns
- mixed[][] @phpstan-return list<array<string, mixed>>
Definition at line 502 of file Utils.php.
◆ getCoreCount()
static pocketmine\utils\Utils::getCoreCount |
( |
bool | $recalculate = false | ) |
|
|
static |
◆ getMachineUniqueId()
static pocketmine\utils\Utils::getMachineUniqueId |
( |
string | $extra = "" | ) |
|
|
static |
Gets this machine / server instance unique ID Returns a hash, the first 32 characters (or 16 if raw) will be an identifier that won't change frequently. The rest of the hash will change depending on other factors.
- Parameters
-
string | $extra | optional, additional data to identify the machine |
Definition at line 199 of file Utils.php.
◆ getNiceClassName()
static pocketmine\utils\Utils::getNiceClassName |
( |
object | $obj | ) |
|
|
static |
Returns a readable identifier for the class of the given object. Sanitizes class names for anonymous classes.
- Exceptions
-
ReflectionException
Definition at line 152 of file Utils.php.
◆ getNiceClosureName()
static pocketmine\utils\Utils::getNiceClosureName |
( |
\Closure | $closure | ) |
|
|
static |
Returns a readable identifier for the given Closure, including file and line.
@phpstan-param anyClosure $closure
- Exceptions
-
ReflectionException
Definition at line 122 of file Utils.php.
◆ getOpcacheJitMode()
static pocketmine\utils\Utils::getOpcacheJitMode |
( |
| ) |
|
|
static |
◆ getOS()
static pocketmine\utils\Utils::getOS |
( |
bool | $recalculate = false | ) |
|
|
static |
◆ getReferenceCount()
static pocketmine\utils\Utils::getReferenceCount |
( |
object | $value, |
|
|
bool | $includeCurrent = true ) |
|
static |
◆ hexdump()
static pocketmine\utils\Utils::hexdump |
( |
string | $bin | ) |
|
|
static |
Returns a prettified hexdump
Definition at line 337 of file Utils.php.
◆ javaStringHash()
static pocketmine\utils\Utils::javaStringHash |
( |
string | $string | ) |
|
|
static |
◆ parseDocComment()
static pocketmine\utils\Utils::parseDocComment |
( |
string | $docComment | ) |
|
|
static |
Extracts one-line tags from the doc-comment
- Returns
- string[] an array of tagName => tag value. If the tag has no value, an empty string is used as the value.
Definition at line 528 of file Utils.php.
◆ printable()
static pocketmine\utils\Utils::printable |
( |
mixed | $str | ) |
|
|
static |
Returns a string that can be printed, replaces non-printable characters
Definition at line 352 of file Utils.php.
◆ printableCurrentTrace()
static pocketmine\utils\Utils::printableCurrentTrace |
( |
int | $skipFrames = 0 | ) |
|
|
static |
◆ printableExceptionInfo()
static pocketmine\utils\Utils::printableExceptionInfo |
( |
\Throwable | $e, |
|
|
| $trace = null ) |
|
static |
- Parameters
-
- Returns
- string[]
Definition at line 409 of file Utils.php.
◆ printableTrace()
static pocketmine\utils\Utils::printableTrace |
( |
array | $trace, |
|
|
int | $maxStringLength = 80 ) |
|
static |
- Parameters
-
mixed[][] | $trace | @phpstan-param list<array<string, mixed>> $trace |
- Returns
- string[]
Definition at line 449 of file Utils.php.
◆ printableTraceWithMetadata()
static pocketmine\utils\Utils::printableTraceWithMetadata |
( |
array | $rawTrace, |
|
|
int | $maxStringLength = 80 ) |
|
static |
Similar to Utils::printableTrace()
, but associates metadata such as file and line number with each frame. This is used to transmit thread-safe information about crash traces to the main thread when a thread crashes.
- Parameters
-
mixed[][] | $rawTrace | @phpstan-param list<array<string, mixed>> $rawTrace |
- Returns
- ThreadCrashInfoFrame[]
Definition at line 483 of file Utils.php.
◆ stringifyKeys()
static pocketmine\utils\Utils::stringifyKeys |
( |
array | $array | ) |
|
|
static |
Generator which forces array keys to string during iteration. This is necessary because PHP has an anti-feature where it casts numeric string keys to integers, leading to various crashes.
@phpstan-template TKeyType of string @phpstan-template TValueType @phpstan-param array<TKeyType, TValueType> $array @phpstan-return \Generator<TKeyType, TValueType, void, void>
Definition at line 605 of file Utils.php.
◆ testValidInstance()
static pocketmine\utils\Utils::testValidInstance |
( |
string | $className, |
|
|
string | $baseName ) |
|
static |
◆ validateArrayValueType()
static pocketmine\utils\Utils::validateArrayValueType |
( |
array | $array, |
|
|
\Closure | $validator ) |
|
static |
@phpstan-template TMemberType @phpstan-param array<mixed, TMemberType> $array @phpstan-param \Closure(TMemberType) : void $validator
Definition at line 585 of file Utils.php.
◆ validateCallableSignature()
static pocketmine\utils\Utils::validateCallableSignature |
( |
callable|CallbackType | $signature, |
|
|
callable | $subject ) |
|
static |
Verifies that the given callable is compatible with the desired signature. Throws a TypeError if they are incompatible.
- Parameters
-
callable | CallbackType | $signature | Dummy callable with the required parameters and return type |
callable | $subject | Callable to check the signature of @phpstan-param anyCallable|CallbackType $signature @phpstan-param anyCallable $subject |
- Exceptions
-
DaveRandom\CallbackValidator\InvalidCallbackException
- Exceptions
-
TypeError
Definition at line 571 of file Utils.php.
◆ OS_ANDROID
const pocketmine\utils\Utils::OS_ANDROID = "android" |
◆ OS_BSD
const pocketmine\utils\Utils::OS_BSD = "bsd" |
◆ OS_IOS
const pocketmine\utils\Utils::OS_IOS = "ios" |
◆ OS_LINUX
const pocketmine\utils\Utils::OS_LINUX = "linux" |
◆ OS_MACOS
const pocketmine\utils\Utils::OS_MACOS = "mac" |
◆ OS_UNKNOWN
const pocketmine\utils\Utils::OS_UNKNOWN = "other" |
◆ OS_WINDOWS
const pocketmine\utils\Utils::OS_WINDOWS = "win" |
The documentation for this class was generated from the following file: