PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
pocketmine\utils\Utils Class Reference
+ Collaboration diagram for pocketmine\utils\Utils:

Static Public Member Functions

static assumeNotFalse (mixed $value, \Closure|string $context="This should never be false")
 
static checkFloatNotInfOrNaN (string $name, float $float)
 
static checkLocationNotInfOrNaN (Location $location)
 
static checkUTF8 (string $string)
 
static checkVector3NotInfOrNaN (Vector3 $vector3)
 
static cloneCallback ()
 
static cloneObjectArray (array $array)
 
static currentTrace (int $skipFrames=0)
 
static getCoreCount (bool $recalculate=false)
 
static getMachineUniqueId (string $extra="")
 
static getNiceClassName (object $obj)
 
static getNiceClosureName (\Closure $closure)
 
static getOpcacheJitMode ()
 
static getOS (bool $recalculate=false)
 
static getRandomFloat ()
 
static getReferenceCount (object $value, bool $includeCurrent=true)
 
static hexdump (string $bin)
 
static javaStringHash (string $string)
 
static parseDocComment (string $docComment)
 
static printable (mixed $str)
 
static printableCurrentTrace (int $skipFrames=0)
 
static printableExceptionInfo (\Throwable $e, $trace=null)
 
static printableTrace (array $trace, int $maxStringLength=80)
 
static printableTraceWithMetadata (array $rawTrace, int $maxStringLength=80)
 
static promoteKeys (array $array)
 
static stringifyKeys (array $array)
 
static testValidInstance (string $className, string $baseName)
 
static validateArrayValueType (array $array, \Closure $validator)
 
static validateCallableSignature (callable|CallbackType $signature, callable $subject)
 

Public Attributes

const OS_ANDROID = "android"
 
const OS_BSD = "bsd"
 
const OS_IOS = "ios"
 
const OS_LINUX = "linux"
 
const OS_MACOS = "mac"
 
const OS_UNKNOWN = "other"
 
const OS_WINDOWS = "win"
 

Detailed Description

Big collection of functions

Definition at line 105 of file Utils.php.

Member Function Documentation

◆ 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 638 of file Utils.php.

◆ checkFloatNotInfOrNaN()

static pocketmine\utils\Utils::checkFloatNotInfOrNaN ( string $name,
float $float )
static

Definition at line 645 of file Utils.php.

◆ checkLocationNotInfOrNaN()

static pocketmine\utils\Utils::checkLocationNotInfOrNaN ( Location $location)
static

Definition at line 664 of file Utils.php.

◆ checkUTF8()

static pocketmine\utils\Utils::checkUTF8 ( string $string)
static

Definition at line 626 of file Utils.php.

◆ checkVector3NotInfOrNaN()

static pocketmine\utils\Utils::checkVector3NotInfOrNaN ( Vector3 $vector3)
static

Definition at line 654 of file Utils.php.

◆ cloneCallback()

static pocketmine\utils\Utils::cloneCallback ( )
static

@phpstan-return \Closure(object) : object

Definition at line 171 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 187 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 505 of file Utils.php.

◆ getCoreCount()

static pocketmine\utils\Utils::getCoreCount ( bool $recalculate = false)
static

Definition at line 304 of file Utils.php.

◆ 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$extraoptional, additional data to identify the machine

Definition at line 201 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 154 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 124 of file Utils.php.

◆ getOpcacheJitMode()

static pocketmine\utils\Utils::getOpcacheJitMode ( )
static

Returns an integer describing the current OPcache JIT setting.

See also
https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit

Definition at line 672 of file Utils.php.

◆ getOS()

static pocketmine\utils\Utils::getOS ( bool $recalculate = false)
static

Returns the current Operating System Windows => win MacOS => mac iOS => ios Android => android Linux => Linux BSD => bsd Other => other

Definition at line 277 of file Utils.php.

Referenced by pocketmine\utils\Process\getAdvancedMemoryUsage().

+ Here is the caller graph for this function:

◆ getRandomFloat()

static pocketmine\utils\Utils::getRandomFloat ( )
static

Returns a random float between 0.0 and 1.0 Drop-in replacement for lcg_value()

Definition at line 698 of file Utils.php.

◆ getReferenceCount()

static pocketmine\utils\Utils::getReferenceCount ( object $value,
bool $includeCurrent = true )
static

Definition at line 375 of file Utils.php.

◆ hexdump()

static pocketmine\utils\Utils::hexdump ( string $bin)
static

Returns a prettified hexdump

Definition at line 339 of file Utils.php.

◆ javaStringHash()

static pocketmine\utils\Utils::javaStringHash ( string $string)
static

Definition at line 362 of file Utils.php.

◆ 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 531 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 354 of file Utils.php.

◆ printableCurrentTrace()

static pocketmine\utils\Utils::printableCurrentTrace ( int $skipFrames = 0)
static
Returns
string[]

Definition at line 522 of file Utils.php.

◆ printableExceptionInfo()

static pocketmine\utils\Utils::printableExceptionInfo ( \Throwable $e,
$trace = null )
static
Parameters
mixed[][]$trace
Returns
string[]

Definition at line 411 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[] @phpstan-return list<string>

Definition at line 452 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 486 of file Utils.php.

◆ promoteKeys()

static pocketmine\utils\Utils::promoteKeys ( array $array)
static

Gets rid of PHPStan BenevolentUnionType on array keys, so that wrong type errors get reported properly Use this if you don't care what the key type is and just want proper PHPStan error reporting

@phpstan-template TValueType @phpstan-param array<TValueType> $array @phpstan-return array<int|string, TValueType>

Definition at line 622 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 608 of file Utils.php.

◆ testValidInstance()

static pocketmine\utils\Utils::testValidInstance ( string $className,
string $baseName )
static

@phpstan-param class-string $className @phpstan-param class-string $baseName

Definition at line 542 of file Utils.php.

◆ 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 588 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$signatureDummy callable with the required parameters and return type
callable$subjectCallable to check the signature of @phpstan-param anyCallable|CallbackType $signature @phpstan-param anyCallable $subject
Exceptions

DaveRandom\CallbackValidator\InvalidCallbackException

Exceptions

TypeError

Definition at line 574 of file Utils.php.

Member Data Documentation

◆ OS_ANDROID

const pocketmine\utils\Utils::OS_ANDROID = "android"

Definition at line 109 of file Utils.php.

◆ OS_BSD

const pocketmine\utils\Utils::OS_BSD = "bsd"

Definition at line 111 of file Utils.php.

◆ OS_IOS

const pocketmine\utils\Utils::OS_IOS = "ios"

Definition at line 107 of file Utils.php.

◆ OS_LINUX

const pocketmine\utils\Utils::OS_LINUX = "linux"

Definition at line 110 of file Utils.php.

◆ OS_MACOS

const pocketmine\utils\Utils::OS_MACOS = "mac"

Definition at line 108 of file Utils.php.

◆ OS_UNKNOWN

const pocketmine\utils\Utils::OS_UNKNOWN = "other"

Definition at line 112 of file Utils.php.

◆ OS_WINDOWS

const pocketmine\utils\Utils::OS_WINDOWS = "win"

Definition at line 106 of file Utils.php.


The documentation for this class was generated from the following file: