php8.5
Home/ Manual/ reflection / reflectionfunctionabstract/ ReflectionFunctionAbstract::isClosure

ReflectionFunctionAbstract::isClosure

PHP function Edit on GitHub ✎

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

Checks if closure

Description

ReflectionFunctionAbstract::isClosure(): bool

Checks whether the reflected function is a Closure.

Parameters Parameters

Return Values

Returns true if the function is a Closure, otherwise false.

Examples

ReflectionFunctionAbstract::isClosure example

php
<?php
// Non-closure
$function1 = 'str_replace';
$reflection1 = new ReflectionFunction($function1);
var_dump($reflection1->isClosure());

// Closure
$function2 = function () {};
$reflection2 = new ReflectionFunction($function2);
var_dump($reflection2->isClosure());
?>

The above example will output:

output
bool(false)
bool(true)

See Also

  • ReflectionFunctionAbstract::isGenerator

Source: reference/reflection/reflectionfunctionabstract/isclosure.xml · from the official PHP manual (php/doc-en)