Doc #72662 [Opn->Csd]: Anonymous function example 5 relies on PHP 7 syntax
| From: | cmb@php.net | Date: | Sun, 24 Jul 2016 11:23:41 +0000 |
| Subject: | Doc #72662 [Opn->Csd]: Anonymous function example 5 relies on PHP 7 syntax | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13748@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72662&edit=1
ID: 72662
Updated by: cmb@php.net
Reported by: playit2thelimit at gmail dot com
Summary: Anonymous function example 5 relies on PHP 7 syntax
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Class/Object related
Operating System: Windows 7
PHP Version: 5.6.24
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2016-07-24 11:23:03] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=339708
Log: Fix #72662: Anonymous function example 5 relies on PHP 7 syntax
------------------------------------------------------------------------
[2016-07-24 05:49:05] requinix@php.net
http://php.net/manual/en/functions.anonymous.php#example-203
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 <https://3v4l.org/qVEF1> demonstrates
the concept better.
------------------------------------------------------------------------
[2016-07-23 23:35:36] playit2thelimit at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/functions.anonymous
---
Trying to understand example #5, but it does not compile.
Thanks!
- Chris
Test script:
---------------
<?php
class Test
{
public function testing()
{
(function() {
var_dump($this);
})();
}
}
(new Test)->testing(); // as of PHP 5.4
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72662&edit=1