svn: /phpdoc/en/trunk/language/ namespaces.xml
| From: | Pasindu De Silva | Date: | Mon, 24 Aug 2015 04:33:10 +0000 |
| Subject: | svn: /phpdoc/en/trunk/language/ namespaces.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-13643@lists.php.net to get a copy of this message | ||
pasindu Mon, 24 Aug 2015 04:33:10 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=337597
Log:
Added group use from migration
Changed paths:
U phpdoc/en/trunk/language/namespaces.xml
Modified: phpdoc/en/trunk/language/namespaces.xml
===================================================================
--- phpdoc/en/trunk/language/namespaces.xml 2015-08-23 21:28:46 UTC (rev 337596)
+++ phpdoc/en/trunk/language/namespaces.xml 2015-08-24 04:33:10 UTC (rev 337597)
@@ -19,6 +19,26 @@
name using the directory separator to get <literal>/home/greg/foo.txt</literal>.
This
same principle extends to namespaces in the programming world.
</simpara>
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>&Version;</entry>
+ <entry>&Description;</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>7.0.0</entry>
+ <entry>
+ Added Group use Declarations.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
<simpara>
In the PHP world, namespaces are designed to solve two problems that authors
of libraries and applications encounter when creating re-usable code elements
@@ -412,6 +432,40 @@
</programlisting>
</example>
</para>
+ <para>
+ <title>Group <literal>use</literal> Declarations</title>
+ <para>
+ This gives the ability to group multiple <literal>use</literal> declarations
+ according to the parent namespace. This seeks to remove code verbosity when
+ importing multiple classes, functions, or constants that come under the same
+ namespace.
+ </para>
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+// Pre PHP 7 code
+use some\namespace\ClassA;
+use some\namespace\ClassB;
+use some\namespace\ClassC as C;
+
+use function some\namespace\fn_a;
+use function some\namespace\fn_b;
+use function some\namespace\fn_c;
+
+use const some\namespace\ConstA;
+use const some\namespace\ConstB;
+use const some\namespace\ConstC;
+
+// PHP 7+ code
+use some\namespace\{ClassA, ClassB, ClassC as C};
+use function some\namespace\{fn_a, fn_b, fn_c};
+use const some\namespace\{ConstA, ConstB, ConstC};
+]]>
+ </programlisting>
+ </informalexample>
+ </para>
</sect1>
<sect1 xml:id="language.namespaces.dynamic">
<title>Namespaces and dynamic language features</title>