Doc #61999 [Dup->Csd]: Static lambdas not documented
| From: | tpunt@php.net | Date: | Sun, 22 May 2016 20:06:51 +0000 |
| Subject: | Doc #61999 [Dup->Csd]: Static lambdas not documented | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13464@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61999&edit=1
ID: 61999
Updated by: tpunt@php.net
Reported by: kenaniah at gmail dot com
Summary: Static lambdas not documented
-Status: Duplicate
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Any
PHP Version: 5.4.3
Assigned To: tpunt
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2016-05-22 20:06:12] tpunt@php.net
Automatic comment from SVN on behalf of tpunt
Revision: http://svn.php.net/viewvc/?view=revision&revision=339217
Log: Resolve doc by #61999
------------------------------------------------------------------------
[2016-04-20 16:26:13] nikic@php.net
Duplicate of (newer) bug #71348.
------------------------------------------------------------------------
[2012-05-10 18:55:01] kenaniah at gmail dot com
Description:
------------
Neither http://php.net/manual/en/class.closure.php nor
http://www.php.net/manual/en/functions.anonymous.php
mention that anonymous
functions / lambdas bind the object they are defined in to $this, and that the
automatic binding functionality can be avoided by declaring the lambda as
static:
<?php
$lambda = static function() { ... }
?>
There should probably be a warning about generating lambdas in object contexts
as it silently binds a reference to the defining object, which could cause all
sorts headaches when attempting to cause the destruction of an object.
Defining a static lambda like the code sample above prevents the lambda from
binding to its defining object. Please patch the documentation accordingly.
Thanks!
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61999&edit=1