From 06df50f0b11dab8ad595fb8c544c478019ff1d17 Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Tue, 7 Jun 2016 13:25:21 +0000 Subject: [PATCH] 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 --- language/oop5/basic.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/language/oop5/basic.xml b/language/oop5/basic.xml index 6f5ec49429..aa56c33116 100644 --- a/language/oop5/basic.xml +++ b/language/oop5/basic.xml @@ -263,7 +263,8 @@ method That means that calling an anonymous function 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. Calling an anonymous function stored in a property @@ -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; ]]> &example.outputs;