Fixed bug #53133 (Scope of use keyword is not documented)

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@304702 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Kalle Sommer Nielsen 2010-10-24 14:14:59 +00:00
parent 50f157563d
commit eb41c5d7b3

View file

@ -681,6 +681,42 @@ $obj = new \Another\thing; // instantiates object of class Another\thing
</programlisting>
</example>
</para>
<sect2 xml:id="language.namespaces.importing.scope">
<title>Scoping rules for importing</title>
<para>
The <literal>use</literal> keyword must be declared in the
outermost scope of a file (the global scope) or inside namespace
declarations. This is because the importing is done at compile
time and not runtime, so it cannot be block scoped. The following
example will show an illegal use of the <literal>use</literal>
keyword:
</para>
<para>
<example>
<title>Illegal importing rule</title>
<programlisting role="php">
<![CDATA[
<?php
namespace Languages;
class Greenlandic
{
use Languages\Danish;
...
}
?>
]]>
</programlisting>
</example>
</para>
<note>
<para>
Importing rules are per file basis, meaning included files will
<emphasis>NOT</emphasis> inherit the parent file's importing rules.
</para>
</note>
</sect2>
</sect1>
<sect1 xml:id="language.namespaces.global">
<title>Global space</title>