Constants

ARRAY_RECURSIVE_KEY

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

Array recursive constant

Properties

$closure

$closure : \Closure

Type

\Closure — Wrapped 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

Methods

__construct()

__construct(\Closure  $closure) 

Constructor

Parameters

\Closure $closure

Closure you want to serialize

getClosure()

getClosure() : \Closure

Get the Closure object

Returns

\Closure —

The wrapped closure

__invoke()

__invoke() 

Implementation of magic method __invoke()

serialize()

serialize() : string

Implementation of Serializable::serialize()

Returns

string —

The serialized closure

unserialize()

unserialize(string  $data) 

Implementation of Serializable::unserialize()

Parameters

string $data

Serialized data

Throws

\Opis\Closure\SecurityException

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() 

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

exitContext()

exitContext() 

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

setSecretKey()

setSecretKey(string  $secret) 

Parameters

string $secret

addSecurityProvider()

addSecurityProvider(\Opis\Closure\ISecurityProvider  $securityProvider) 

Parameters

\Opis\Closure\ISecurityProvider $securityProvider

removeSecurityProvider()

removeSecurityProvider() 

Remove security provider

createClosure()

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

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

Parameters

$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