[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] =?utf-8?q?svn:_/phpdoc/en/trunk/_appendices/migration71/incompatible.xml_language/function
From:       Adam_Harvey <aharvey () php ! net>
Date:       2016-12-30 19:57:37
Message-ID: svn-aharvey-1483127857-341552-968191991 () svn ! php ! net
[Download RAW message or body]

aharvey                                  Fri, 30 Dec 2016 19:57:37 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=341552

Log:
Document new use() behaviour in PHP 7.1.

Fixes bug #73844 (Cannot use lexical variable $variable as a parameter name
inside array_walk()).

Bug: https://bugs.php.net/73844 (Assigned) Cannot use lexical variable $variable as a \
parameter name inside array_walk()  
Changed paths:
    U   phpdoc/en/trunk/appendices/migration71/incompatible.xml
    U   phpdoc/en/trunk/language/functions.xml

Modified: phpdoc/en/trunk/appendices/migration71/incompatible.xml
===================================================================
--- phpdoc/en/trunk/appendices/migration71/incompatible.xml	2016-12-30 16:48:21 UTC \
                (rev 341551)
+++ phpdoc/en/trunk/appendices/migration71/incompatible.xml	2016-12-30 19:57:37 UTC \
(rev 341552) @@ -490,6 +490,28 @@
   </para>
  </sect2>

+ <sect2 xml:id="migration71.incompatible.lexical-names">
+  <title>Lexically bound variables cannot reuse names</title>
+
+  <para>
+   Variables bound to a <link linkend="functions.anonymous">closure</link> via
+   the <literal>use</literal> construct cannot use the same name as any
+   &link.superglobals;, <varname>$this</varname>, or any parameter. For
+   example, all of these function definition will result in a fatal error:
+
+   <informalexample>
+    <programlisting role="php">
+<![CDATA[
+<?php
+$f = function () use ($_SERVER) {};
+$f = function () use ($this) {};
+$f = function ($param) use ($param) {};
+]]>
+    </programlisting>
+   </informalexample>
+  </para>
+ </sect2>
+
  <sect2 xml:id="migration71.incompatible.json">
   <title>JSON encoding and decoding</title>
   <para>

Modified: phpdoc/en/trunk/language/functions.xml
===================================================================
--- phpdoc/en/trunk/language/functions.xml	2016-12-30 16:48:21 UTC (rev 341551)
+++ phpdoc/en/trunk/language/functions.xml	2016-12-30 19:57:37 UTC (rev 341552)
@@ -1372,8 +1372,10 @@
    </example>

    <simpara>
-    Closures may also inherit variables from the parent scope.
-    Any such variables must be passed to the <literal>use</literal> language \
construct. +    Closures may also inherit variables from the parent scope. Any such
+    variables must be passed to the <literal>use</literal> language construct.
+    From PHP 7.1, these variables may not include &link.superglobals;,
+    <varname>$this</varname>, or variables with the same name as a parameter.
    </simpara>

    <example>
@@ -1623,6 +1625,14 @@
        </thead>
        <tbody>
         <row>
+         <entry>7.1.0</entry>
+         <entry>
+          Anonymous functions may not close over &link.superglobals;,
+          <varname>$this</varname>, or any variable with the same name as a
+          parameter.
+         </entry>
+        </row>
+        <row>
          <entry>5.4.0</entry>
          <entry>
           Anonymous functions may use <varname>$this</varname>, as well as be



-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic