Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<ReflectionMethod::exportReflectionMethod::getDeclaringClass>
^ReflectionMethodLast updated: Mon, 26 Oct 2026

ReflectionMethod::getClosure

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

ReflectionMethod::getClosure — Returns a dynamically created closure for the method

Description

public function ReflectionMethod::getClosure(?object $object = null): Closure

Create a closure which will call the method.

Parameters

object

Forbidden for static methods, required for other methods.

Return Values

Returns the newly created Closure.

Errors/Exceptions

Throws a ValueError if object is null but the method is non-static.

Throws a ReflectionException if object is not an instance of the class this method was declared in.

Changelog

Version Description
8.0.0 object is now nullable.

<ReflectionMethod::exportReflectionMethod::getDeclaringClass>
^ReflectionMethodLast updated: Mon, 26 Oct 2026