Fix #72331: most simple way to call anonymous function assigned to object property missing

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@339308 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Christoph Michael Becker 2016-06-07 13:25:21 +00:00
parent ec6a5fb91f
commit 06df50f0b1

View file

@ -263,7 +263,8 @@ method
That means that calling an <link linkend="functions.anonymous">anonymous
function</link> which has been assigned to a property is not directly
possible. Instead the property has to be assigned to a variable first, for
instance.
instance. As of PHP 7.0.0 it is possible to call such a property directly
by enclosing it in parentheses.
</para>
<example>
<title>Calling an anonymous function stored in a property</title>
@ -281,8 +282,13 @@ class Foo
}
$obj = new Foo();
// as of PHP 5.3.0:
$func = $obj->bar;
echo $func(), PHP_EOL;
// alternatively, as of PHP 7.0.0:
echo ($obj->bar)(), PHP_EOL;
]]>
</programlisting>
&example.outputs;