Doc #65308 [Com]: register_shutdown_function can take a closure, not just a callback name
| From: | fgmarand at gmail dot com | Date: | Tue, 23 Jul 2013 09:11:13 +0000 |
| Subject: | Doc #65308 [Com]: register_shutdown_function can take a closure, not just a callback name | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10107@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65308&edit=1
ID: 65308
Comment by: fgmarand at gmail dot com
Reported by: fgmarand at gmail dot com
Summary: register_shutdown_function can take a closure, not
just a callback name
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: Linux
PHP Version: 5.4.17
Block user comment: N
Private report: N
New Comment:
It is indeed not strictly described as invalid, but not as valid either. And
IIRC the "callable" hint appeared in 5.4, whereas "callback" has used in PHP
documentation since the dawn of time to describe function/(object|class,method)
and anonymous functions from create_function, while closures appeared in 5.3
What I suggest is simply to make it explicitly valid, probably as a version note
in the changelog, noting that from 5.3 on, closures are a valid callback type.
This will not make the main doc more complex but will spare other devs some
doubt/grief: from reading the doc, I thought it wouldn't work, and only tried a
closure "just in case".
Maybe I should roll a patch to show how it could look IMHO ?
Previous Comments:
------------------------------------------------------------------------
[2013-07-22 18:12:38] mail+php at requinix dot net
I don't see anything that says it only supports strings while it does mention
callable and callback... Closures certainly qualify for both.
------------------------------------------------------------------------
[2013-07-22 08:07:27] fgmarand at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.register-shutdown-
function#refsect1-function.register-shutdown-function-description
---
register_shutdown_function(function () { echo "Hello world\n"; });
This actually works, although the manual has no mention of Closure support.
Expected result:
----------------
According to the doc, this should cause an invalid argument error,
Actual result:
--------------
It works, so it should be documented, since PHP is moving from "function
name/array" callbacks to Closures for a number of versions.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65308&edit=1