Constants

ARRAY_RECURSIVE_KEY

ARRAY_RECURSIVE_KEY = '¯\\_(ツ)_/¯'

Array recursive constant

Properties

$closure

$closure : \Closure

Type

\Closure — Wrapped closure

$reflector

$reflector : \Opis\Closure\ReflectionClosure

Type

ReflectionClosure — A reflection instance for closure

$code

$code : mixed

Type

mixed — Used at deserialization to hold variables

$reference

$reference : string

Type

string — Closure's ID

$scope

$scope : string

Type

string — Closure scope

$context

$context : \Opis\Closure\ClosureContext

Type

\Opis\Closure\ClosureContext — Context of closure, used in serialization

Methods

__construct()

__construct(\Closure  $closure) : mixed

Constructor

Parameters

\Closure $closure

Closure you want to serialize

Returns

mixed —

getClosure()

getClosure() : \Closure

Get the Closure object

Returns

\Closure —

The wrapped closure

getReflector()

getReflector() : \Opis\Closure\ReflectionClosure

Get the reflector for closure

Returns

\Opis\Closure\ReflectionClosure —

__invoke()

__invoke() : mixed

Implementation of magic method __invoke()

Returns

mixed —

serialize()

serialize() : string

Implementation of Serializable::serialize()

Returns

string —

The serialized closure

unserialize()

unserialize(string  $data) : mixed

Implementation of Serializable::unserialize()

Parameters

string $data

Serialized data

Throws

\Opis\Closure\SecurityException

Returns

mixed —

from()

from(\Closure  $closure) : self

Wraps a closure and sets the serialization context (if any)

Parameters

\Closure $closure

Closure to be wrapped

Returns

self —

The wrapped closure

enterContext()

enterContext() : mixed

Increments the context lock counter or creates a new context if none exist

Returns

mixed —

exitContext()

exitContext() : mixed

Decrements the context lock counter and destroy the context when it reaches to 0

Returns

mixed —

setSecretKey()

setSecretKey(string  $secret) : mixed

Parameters

string $secret

Returns

mixed —

addSecurityProvider()

addSecurityProvider(\Opis\Closure\ISecurityProvider  $securityProvider) : mixed

Parameters

\Opis\Closure\ISecurityProvider $securityProvider

Returns

mixed —

removeSecurityProvider()

removeSecurityProvider() : mixed

Remove security provider

Returns

mixed —

getSecurityProvider()

getSecurityProvider() : null|\Opis\Closure\ISecurityProvider

Returns

null|\Opis\Closure\ISecurityProvider —

createClosure()

createClosure(mixed  $args, string  $code) : \Closure

Creates a new closure from arbitrary code, emulating create_function, but without using eval

Parameters

mixed $args
string $code

Returns

\Closure —

transformUseVariables()

transformUseVariables(array  $data) : array

Transform the use variables before serialization.

Parameters

array $data

The Closure's use variables

Returns

array —

resolveUseVariables()

resolveUseVariables(array  $data) : array

Resolve the use variables after unserialization.

Parameters

array $data

The Closure's transformed use variables

Returns

array —