<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Converts a callable into a closure</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="closure.call.html">Closure::call</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.generator.html">Generator</a></div> <div class="up"><a href="class.closure.html">Closure</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="closure.fromcallable" class="refentry"> <div class="refnamediv"> <h1 class="refname">Closure::fromCallable</h1> <p class="verinfo">(PHP 7 >= 7.1.0)</p><p class="refpurpose"><span class="refname">Closure::fromCallable</span> — <span class="dc-title">Converts a callable into a closure</span></p> </div> <div class="refsect1 description" id="refsect1-closure.fromcallable-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="modifier">static</span> <span class="type"><a href="class.closure.html" class="type Closure">Closure</a></span> <span class="methodname"><strong>Closure::fromCallable</strong></span> ( <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callable</code></span> )</div> <p class="para rdfs-comment"> Create and return a new <a href="functions.anonymous.html" class="link">anonymous function</a> from given <code class="parameter">callable</code> using the current scope. This method checks if the <code class="parameter">callable</code> is callable in the current scope and throws a <a href="class.typeerror.html" class="classname">TypeError</a> if it is not. </p> </div> <div class="refsect1 parameters" id="refsect1-closure.fromcallable-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <code class="parameter">callable</code></dt> <dd> <p class="para"> The callable to convert. </p> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-closure.fromcallable-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the newly created <a href="class.closure.html" class="classname">Closure</a> or throws a <a href="class.typeerror.html" class="classname">TypeError</a> if the <code class="parameter">callable</code> is not callable in the current scope. </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="closure.call.html">Closure::call</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.generator.html">Generator</a></div> <div class="up"><a href="class.closure.html">Closure</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>