Doc #77148 [Opn->Ver]: No mention of __FUNCTION__ being self-referential inside a closure
| From: | cmb@php.net | Date: | Wed, 14 Nov 2018 11:51:51 +0000 |
| Subject: | Doc #77148 [Opn->Ver]: No mention of __FUNCTION__ being self-referential inside a closure | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16136@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77148&edit=1
ID: 77148
Updated by: cmb@php.net
Reported by: roy-orbison at devo dot net dot au
Summary: No mention of __FUNCTION__ being self-referential
inside a closure
-Status: Open
+Status: Verified
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
According to <https://3v4l.org/731uA>, the behavior is
identical
for all PHP versions since anonymous functions have been
introduced. I think it makes sense to document this.
Previous Comments:
------------------------------------------------------------------------
[2018-11-14 04:21:37] roy-orbison at devo dot net dot au
Description:
------------
---
From manual page: https://php.net/language.constants.predefined
From manual page: https://php.net/functions.anonymous
---
__FUNCTION__ seems to correctly refer to an anonymous function within itself, but there's no
information on either of the above pages. Based on internet searches it wasn't always the case,
but I couldn't find the changelog where it was fixed.
Does it not work 100% of the time? Is there some reason it's not officially documented?
Test script:
---------------
<?php
call_user_func(function() {
var_dump(__FUNCTION__);
});
Actual result:
--------------
/path/to/closure-test.php:3:string '{closure}' (length=9)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77148&edit=1