svn: /phpdoc/en/trunk/language/ namespaces.xml

From: Date: Tue, 08 Mar 2011 17:07:49 +0000
Subject: svn: /phpdoc/en/trunk/language/ namespaces.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-7839@lists.php.net to get a copy of this message
vrana Tue, 08 Mar 2011 17:07:49 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=309025 Log: Namespaces importing (thanks to Jan Tvrdik) Changed paths: U phpdoc/en/trunk/language/namespaces.xml Modified: phpdoc/en/trunk/language/namespaces.xml =================================================================== --- phpdoc/en/trunk/language/namespaces.xml 2011-03-08 16:49:15 UTC (rev 309024) +++ phpdoc/en/trunk/language/namespaces.xml 2011-03-08 17:07:49 UTC (rev 309025) @@ -592,7 +592,8 @@ </para> <para> PHP namespaces support - two kinds of aliasing or importing: aliasing a class name, and aliasing a namespace name. + three kinds of aliasing or importing: aliasing a class name, aliasing an interface name, + and aliasing a namespace name. Note that importing a function or constant is not supported. </para> <para> @@ -610,13 +611,13 @@ use My\Full\NSname; // importing a global class -use \ArrayObject; +use ArrayObject; $obj = new namespace\Another; // instantiates object of class foo\Another $obj = new Another; // instantiates object of class My\Full\Classname NSname\subns\func(); // calls function My\Full\NSname\subns\func $a = new ArrayObject(array(1)); // instantiates object of class ArrayObject -// without the "use \ArrayObject" we would instantiate an object of class foo\ArrayObject +// without the "use ArrayObject" we would instantiate an object of class foo\ArrayObject ?> ]]> </programlisting> @@ -624,7 +625,7 @@ Note that for namespaced names (fully qualified namespace names containing namespace separator, such as <literal>Foo\Bar</literal> as opposed to global names that do not, such as <literal>FooBar</literal>), the leading backslash is unnecessary and not - allowed, as import names + recommended, as import names must be fully qualified, and are not processed relative to the current namespace. </para> <para>

« previous php.doc.cvs (#7839) next »