Skip to content

Latest commit

 

History

History
96 lines (69 loc) · 1.46 KB

File metadata and controls

96 lines (69 loc) · 1.46 KB

Closure


dump

converts a closure into a string.

Closure::dump(\Closure $oClosure, bool $bShrink = true) : string

Example

// closure 
$oClosure = function () use ($oDTRequestIn, $oDTRoute) {
    display($oDTRequestIn);
    display($oDTRoute);
};

// dump
$sClosure = Closure::dump($oClosure);

Content of $sClosure

// type: string
'function () use ($oDTRequestIn, $oDTRoute) { display($oDTRequestIn); display($oDTRoute); }'

is

checks whether the unknown parameter is of type closure object.

Closure::is(mixed $mUnknown) : bool

Example

// a closure
$oClosure = function () {
    display('I am a Closure.');
};

// check
$bIsClosure = Closure::is($oClosure);

// bool(true)
var_dump($bIsClosure);

Result

true

toString

with the Closure::toString method you can convert a Closure into a String, which is useful if you want to log a closure into a logfile for example.

Closure::toString(\Closure $oClosure, bool $bShrink = true) : string

Example

// a closure
$oClosure = function () {
    display('I am a Closure.');
};

$sClosure = Closure::toString($oClosure);

// string(43) "function () { display('I am a Closure.'); }"
var_dump($sClosure);

Result

function () { display('I am a Closure.'); }