Doc #61999 [Opn->Dup]: Static lambdas not documented
| From: | nikic@php.net | Date: | Wed, 20 Apr 2016 16:26:15 +0000 |
| Subject: | Doc #61999 [Opn->Dup]: Static lambdas not documented | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-13416@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: nikic@php.net
Reported by: kenaniah at gmail dot com
Summary: Static lambdas not documented
-Status: Open
+Status: Duplicate
Type: Documentation Problem
Package: Documentation problem
Operating System: Any
PHP Version: 5.4.3
Block user comment: N
Private report: N
New Comment:
Duplicate of (newer) bug #71348.
Previous Comments:
------------------------------------------------------------------------
[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