|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #72662 Anonymous function example 5 relies on PHP 7 syntax
Submitted: 2016-07-23 23:35 UTC Modified: 2016-07-24 11:23 UTC
From: playit2thelimit at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Class/Object related
PHP Version: 5.6.24 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: playit2thelimit at gmail dot com
New email:
PHP Version: OS:


 [2016-07-23 23:35 UTC] playit2thelimit at gmail dot com
From manual page:

Trying to understand example #5, but it does not compile.

  - Chris

Test script:

class Test
    public function testing()
        (function() {

(new Test)->testing(); // as of PHP 5.4


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-24 05:49 UTC]
-Summary: Parse error: syntax error, unexpected '(' in C:\ .... +Summary: Anonymous function example 5 relies on PHP 7 syntax -Package: Documentation problem +Package: Class/Object related
 [2016-07-24 05:49 UTC]

Yeah, that (function{})() syntax requires PHP 7.

I'm not sure it's the best example, either. The docs are trying to show that $this is available inside the function because the function was defined within the class, but in the example it's both defined *and called from* within the class.
I think code like <> demonstrates the concept better.
 [2016-07-24 11:23 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix #72662: Anonymous function example 5 relies on PHP 7 syntax
 [2016-07-24 11:23 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-07-24 11:23 UTC]
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]
Automatic comment on behalf of cmb
Log: Fix #72662: Anonymous function example 5 relies on PHP 7 syntax
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 18:01:28 2024 UTC