Doc #74049 [Com]: Unclear statement about vital difference between versions
| From: | teo8976 at gmail dot com | Date: | Sun, 05 Feb 2017 20:32:22 +0000 |
| Subject: | Doc #74049 [Com]: Unclear statement about vital difference between versions | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14415@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74049&edit=1
ID: 74049
Comment by: teo8976 at gmail dot com
Reported by: teo8976 at gmail dot com
Summary: Unclear statement about vital difference between
versions
Status: Open
Type: Documentation Problem
Package: Scripting Engine problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
By the way, it says "from PHP 7.1", but $this is not allowed in 5.x either
Previous Comments:
------------------------------------------------------------------------
[2017-02-05 20:29:25] teo8976 at gmail dot com
Oh, I see, "may not" as in "are not allowed to".
That's confusing, as "may not" usually means "may or may not", as in
"you don't know whether they do or they don't".
It should read "cannot include", then.
------------------------------------------------------------------------
[2017-02-05 20:18:30] requinix@php.net
I'm not sure I understand what the problem is. You don't know what "may not"
means?
It means these three examples
function() use($_GET) { } - https://3v4l.org/hqpiD
function() use($this) { } - https://3v4l.org/6Ten8
function($foo) use($foo) { } - https://3v4l.org/LiPQ4
are not allowed.
------------------------------------------------------------------------
[2017-02-05 19:00:49] teo8976 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/functions.anonymous
---
Regarding the "use" language construct:
"Closures may also inherit variables from the parent scope. Any such variables must be passed
to the use language construct. From PHP 7.1, these variables MAY NOT INCLUDE superglobals, $this, or
variables with the same name as a parameter"
(emphasys added)
What the heck does "MAY NOT" mean?? Either they include or they don't, or they do in
some cases, in which case the docs MUST specify which ones are included and which one are not, in
what cases and depending on what.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74049&edit=1