class Callback

PHP callable tools.

Traits

Static class.

Methods

static Closure
closure($callable, string $method = null) deprecated

No description

static mixed
invoke($callable, ...$args) deprecated

Invokes callback.

static mixed
invokeArgs($callable, array $args = []) deprecated

Invokes callback with an array of parameters.

static mixed
invokeSafe(string $function, array $args, callable $onError)

Invokes internal PHP function with own error handler.

static callable
check($callable, bool $syntax = false)

Checks that $callable is valid PHP callback. Otherwise throws exception. If the $syntax is set to true, only verifies that $callable has a valid structure to be used as a callback, but does not verify if the class or method actually exists.

static string
toString(mixed $callable)

Converts PHP callback to textual form. Class or method may not exists.

toReflection(callable $callable)

Returns reflection for method or function used in PHP callback.

static bool
isStatic(callable $callable)

Checks whether PHP callback is function or static method.

static callable
unwrap(Closure $closure)

Unwraps closure created by Closure::fromCallable().

Details

at line 27
static Closure closure($callable, string $method = null) deprecated

deprecated use Closure::fromCallable()

Parameters

$callable
string $method

Return Value

Closure

at line 42
static mixed invoke($callable, ...$args) deprecated

deprecated

Invokes callback.

Parameters

$callable
...$args

Return Value

mixed

at line 55
static mixed invokeArgs($callable, array $args = []) deprecated

deprecated

Invokes callback with an array of parameters.

Parameters

$callable
array $args

Return Value

mixed

at line 67
static mixed invokeSafe(string $function, array $args, callable $onError)

Invokes internal PHP function with own error handler.

Parameters

string $function
array $args
callable $onError

Return Value

mixed

at line 95
static callable check($callable, bool $syntax = false)

Checks that $callable is valid PHP callback. Otherwise throws exception. If the $syntax is set to true, only verifies that $callable has a valid structure to be used as a callback, but does not verify if the class or method actually exists.

Parameters

$callable
bool $syntax

Return Value

callable

Exceptions

InvalidArgumentException

at line 111
static string toString(mixed $callable)

Converts PHP callback to textual form. Class or method may not exists.

Parameters

mixed $callable

Return Value

string

at line 131
static ReflectionFunctionAbstract toReflection(callable $callable)

Returns reflection for method or function used in PHP callback.

Parameters

callable $callable type check is escalated to ReflectionException

Return Value

ReflectionFunctionAbstract

Exceptions

ReflectionException if callback is not valid

at line 152
static bool isStatic(callable $callable)

Checks whether PHP callback is function or static method.

Parameters

callable $callable

Return Value

bool

at line 161
static callable unwrap(Closure $closure)

Unwraps closure created by Closure::fromCallable().

Parameters

Closure $closure

Return Value

callable