vBulletin v6.1.0

vB_Utility_Functions
in package
uses vB_Utility_Trait_NoSerialize

AbstractYes

Miscellanious functions that do not depend on the vBulletin Framework being initialized

Table of Contents

Methods

__serialize()  : array<string|int, mixed>
__sleep()  : array<string|int, mixed>
__unserialize()  : void
__wakeup()  : void
callSupressError()  : mixed
Call while supressing the error output
callSupressErrorArray()  : mixed
Call while supressing the error output
getNonNegativeIntParam()  : int
Extract an integer from an array of params
getPositiveIntParam()  : int
Extract an integer from an array of params
isAbsolutePath()  : mixed
setPhpTimeout()  : bool
Set the php execution time limit accounting for evironments where the php function may be disabled.

Methods

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__sleep()

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(mixed $serialized) : void
Parameters
$serialized : mixed

callSupressError()

Call while supressing the error output

public static callSupressError(int $errorsToSuppress, callable $callback, mixed ...$args) : mixed

Intended to replace @ suprression and ad hoc supressions of warnings of various kinds we do. In generally we want to avoid setting the error_reporting values everywhere and overriding the user settings. On the other hand there are cases where it just can't be avoided easily when system functions are ill behaved or php libraries aren't fully compatible with all versions.

Parameters
$errorsToSuppress : int
$callback : callable
$args : mixed

,...

Tags
@return

$mixed.

callSupressErrorArray()

Call while supressing the error output

public static callSupressErrorArray(int $errorsToSuppress, callable $callback, array<string|int, mixed> $args) : mixed

The vardaic approach doesn't play nice with reference params (either no params are ref params or all of them are which causes errors if you pass a constant. This allows specific params to be labelled references within the array.

Parameters
$errorsToSuppress : int
$callback : callable
$args : array<string|int, mixed>
Tags
@return

$mixed.

getNonNegativeIntParam()

Extract an integer from an array of params

public static getNonNegativeIntParam(ArrayAccess|array<string|int, mixed> $params, string|int $key, int $default[, int $min = 0 ][, int $max = PHP_INT_MAX ]) : int

Similar to the above, except that a value of 0 is allowed and will not trigger the default. Non numeric values (using is_numeric) that will still trigger the default.

Parameters
$params : ArrayAccess|array<string|int, mixed>
$key : string|int

-- The value to extract. $params[$key] will be cast to an int if it exists.

$default : int

-- this value will be used if $params[$key] doesn't exist or is < 0 after converting to an int.

$min : int = 0

-- A value less than the min will be returned as the min. $min less than 0 will be treated as 0.

$max : int = PHP_INT_MAX

-- A value more less than the max value will be returned as the max.

Return values
int

getPositiveIntParam()

Extract an integer from an array of params

public static getPositiveIntParam(ArrayAccess|array<string|int, mixed> $params, string|int $key, int $default[, int $min = 1 ][, int $max = PHP_INT_MAX ]) : int

This is intended to replace some repeated multiline logic that is surprisingly difficult to compress and make certain functions difficult to understand. It also allows some more rigorous checking that would require even more boilerplate code for stuff that doesn't come up (for instance we generally don't check for negative numbers even though they usually aren't valid.

Parameters
$params : ArrayAccess|array<string|int, mixed>
$key : string|int

-- The value to extract. $params[$key] will be cast to an int if it exists.

$default : int

-- this value will be used if $params[$key] doesn't exist or is <= 0 after converting to an int.

$min : int = 1

-- A value less than the min will be returned as the min. $min less than 1 will be treated as 1.

$max : int = PHP_INT_MAX

-- A value more less than the max value will be returned as the max.

Return values
int

isAbsolutePath()

public static isAbsolutePath(mixed $path) : mixed
Parameters
$path : mixed

setPhpTimeout()

Set the php execution time limit accounting for evironments where the php function may be disabled.

public static setPhpTimeout(int $time) : bool
Parameters
$time : int

-- max execution time in seconds

Return values
bool

-- true if successful/false otherwise


        
On this page

Search results