Utils
in package
Big collection of functions
Table of Contents
- OS_ANDROID = "android"
- OS_BSD = "bsd"
- OS_IOS = "ios"
- OS_LINUX = "linux"
- OS_MACOS = "mac"
- OS_UNKNOWN = "other"
- OS_WINDOWS = "win"
- $os : string|null
- $serverUniqueId : UuidInterface|null
- checkUTF8() : void
- cloneCallback() : Closure
- cloneObjectArray() : array<string|int, object>
- currentTrace() : array<string|int, array<string|int, mixed>>
- getCoreCount() : int
- getMachineUniqueId() : UuidInterface
- 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.
- getNiceClassName() : string
- Returns a readable identifier for the class of the given object. Sanitizes class names for anonymous classes.
- getNiceClosureName() : string
- Returns a readable identifier for the given Closure, including file and line.
- getOS() : string
- Returns the current Operating System Windows => win MacOS => mac iOS => ios Android => android Linux => Linux BSD => bsd Other => other
- getReferenceCount() : int
- hexdump() : string
- Returns a prettified hexdump
- javaStringHash() : int
- parseDocComment() : array<string|int, string>
- Extracts one-line tags from the doc-comment
- printable() : string
- Returns a string that can be printed, replaces non-printable characters
- printableCurrentTrace() : array<string|int, string>
- printableExceptionInfo() : array<string|int, string>
- printableTrace() : array<string|int, string>
- stringifyKeys() : Generator
- Generator which forces array keys to string during iteration.
- testValidInstance() : void
- validateArrayValueType() : void
- validateCallableSignature() : void
- Verifies that the given callable is compatible with the desired signature. Throws a TypeError if they are incompatible.
- printableExceptionMessage() : string
Constants
OS_ANDROID
public
mixed
OS_ANDROID
= "android"
OS_BSD
public
mixed
OS_BSD
= "bsd"
OS_IOS
public
mixed
OS_IOS
= "ios"
OS_LINUX
public
mixed
OS_LINUX
= "linux"
OS_MACOS
public
mixed
OS_MACOS
= "mac"
OS_UNKNOWN
public
mixed
OS_UNKNOWN
= "other"
OS_WINDOWS
public
mixed
OS_WINDOWS
= "win"
Properties
$os
private
static string|null
$os
$serverUniqueId
private
static UuidInterface|null
$serverUniqueId
= null
Methods
checkUTF8()
public
static checkUTF8(string $string) : void
Parameters
- $string : string
Return values
void —cloneCallback()
public
static cloneCallback() : Closure
Tags
Return values
Closure —cloneObjectArray()
public
static cloneObjectArray(array<string|int, object> $array) : array<string|int, object>
Parameters
- $array : array<string|int, object>
Tags
Return values
array<string|int, object> —currentTrace()
public
static currentTrace([int $skipFrames = 0 ]) : array<string|int, array<string|int, mixed>>
Parameters
- $skipFrames : int = 0
Tags
Return values
array<string|int, array<string|int, mixed>> —getCoreCount()
public
static getCoreCount([bool $recalculate = false ]) : int
Parameters
- $recalculate : bool = false
Return values
int —getMachineUniqueId()
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.
public
static getMachineUniqueId([string $extra = "" ]) : UuidInterface
The rest of the hash will change depending on other factors.
Parameters
- $extra : string = ""
-
optional, additional data to identify the machine
Return values
UuidInterface —getNiceClassName()
Returns a readable identifier for the class of the given object. Sanitizes class names for anonymous classes.
public
static getNiceClassName(object $obj) : string
Parameters
- $obj : object
Tags
Return values
string —getNiceClosureName()
Returns a readable identifier for the given Closure, including file and line.
public
static getNiceClosureName(Closure $closure) : string
Parameters
- $closure : Closure
Tags
Return values
string —getOS()
Returns the current Operating System Windows => win MacOS => mac iOS => ios Android => android Linux => Linux BSD => bsd Other => other
public
static getOS([bool $recalculate = false ]) : string
Parameters
- $recalculate : bool = false
Return values
string —getReferenceCount()
public
static getReferenceCount(object $value[, bool $includeCurrent = true ]) : int
Parameters
- $value : object
- $includeCurrent : bool = true
Return values
int —hexdump()
Returns a prettified hexdump
public
static hexdump(string $bin) : string
Parameters
- $bin : string
Return values
string —javaStringHash()
public
static javaStringHash(string $string) : int
Parameters
- $string : string
Return values
int —parseDocComment()
Extracts one-line tags from the doc-comment
public
static parseDocComment(string $docComment) : array<string|int, string>
Parameters
- $docComment : string
Return values
array<string|int, string> —an array of tagName => tag value. If the tag has no value, an empty string is used as the value.
printable()
Returns a string that can be printed, replaces non-printable characters
public
static printable(mixed $str) : string
Parameters
- $str : mixed
Return values
string —printableCurrentTrace()
public
static printableCurrentTrace([int $skipFrames = 0 ]) : array<string|int, string>
Parameters
- $skipFrames : int = 0
Return values
array<string|int, string> —printableExceptionInfo()
public
static printableExceptionInfo(Throwable $e[, array<string|int, mixed> $trace = null ]) : array<string|int, string>
Parameters
- $e : Throwable
- $trace : array<string|int, mixed> = null
Return values
array<string|int, string> —printableTrace()
public
static printableTrace(array<string|int, array<string|int, mixed>> $trace[, int $maxStringLength = 80 ]) : array<string|int, string>
Parameters
- $trace : array<string|int, array<string|int, mixed>>
- $maxStringLength : int = 80
Tags
Return values
array<string|int, string> —stringifyKeys()
Generator which forces array keys to string during iteration.
public
static stringifyKeys(array<string|int, mixed> $array) : Generator
This is necessary because PHP has an anti-feature where it casts numeric string keys to integers, leading to various crashes.
Parameters
- $array : array<string|int, mixed>
Tags
Return values
Generator —testValidInstance()
public
static testValidInstance(string $className, string $baseName) : void
Parameters
- $className : string
- $baseName : string
Tags
Return values
void —validateArrayValueType()
public
static validateArrayValueType(array<string|int, mixed> $array, Closure $validator) : void
Parameters
- $array : array<string|int, mixed>
- $validator : Closure
Tags
Return values
void —validateCallableSignature()
Verifies that the given callable is compatible with the desired signature. Throws a TypeError if they are incompatible.
public
static validateCallableSignature(callable|CallbackType $signature, callable $subject) : void
Parameters
- $signature : callable|CallbackType
-
Dummy callable with the required parameters and return type
- $subject : callable
-
Callable to check the signature of
Tags
Return values
void —printableExceptionMessage()
private
static printableExceptionMessage(Throwable $e) : string
Parameters
- $e : Throwable