php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #72331 most simple way to call anonymous function assigned to object property missing
Submitted: 2016-06-03 18:29 UTC Modified: 2016-06-07 13:26 UTC
From: contact at jaborandi dot org dot ru Assigned: cmb (profile)
Status: Closed Package: Class/Object related
PHP Version: PHP 7.0.0 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: contact at jaborandi dot org dot ru
New email:
PHP Version: OS:

 

 [2016-06-03 18:29 UTC] contact at jaborandi dot org dot ru
Description:
------------
When anonymous function is assigned to a variable, which is an object property, it can still be called in a regular way (without use of call_user_func, or Closure::call):

($object->property)($arg1, $arg2, ...);

This is not mentioned anywhere (I searched on here http://php.net/manual/en/functions.anonymous.php and on page of Callback/Callable and those about classes).

Think it should be added to "Anonymous function variable assignment example" section of the http://php.net/manual/en/functions.anonymous.php page

Did use advanced search before submission.

Thanks!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-07 13:13 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: Documentation problem +Package: Class/Object related -Assigned To: +Assigned To: cmb
 [2016-06-07 13:13 UTC] cmb@php.net
Thanks for reporting this issue.

> ($object->property)($arg1, $arg2, ...);

This syntax is allowed as of PHP 7.0.0 only[1], which would have
to be explicitly mentioned.

> Think it should be added to "Anonymous function variable
> assignment example" section […]

I think it should go to "Example #7 Calling an anonymous function
stored in a property"[2], as the "Anonymous functions" section[3]
is not concerned with class properties, and this example is
explicitly about accessing a callable object property.

[1] <https://wiki.php.net/rfc/uniform_variable_syntax>
[2] <http://php.net/manual/en/language.oop5.basic.php#example-211>
[3] <http://php.net/manual/en/functions.anonymous.php>
 [2016-06-07 13:25 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339308
Log: Fix #72331: most simple way to call anonymous function assigned to object property missing
 [2016-06-07 13:26 UTC] cmb@php.net
-Status: Verified +Status: Closed -Operating System: m745G2Q4 +Operating System: * -PHP Version: Irrelevant +PHP Version: PHP 7.0.0
 [2016-06-07 13:26 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:07 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=06df50f0b11dab8ad595fb8c544c478019ff1d17
Log: Fix #72331: most simple way to call anonymous function assigned to object property missing
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 01 01:01:28 2024 UTC