mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
50f157563d
commit
eb41c5d7b3
1 changed files with 36 additions and 0 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue