php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53133 Scope of use keyword is not documented.
Submitted: 2010-10-22 06:01 UTC Modified: 2010-10-24 16:15 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: longhairedgit+bugs dot php dot net at gmail dot com Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.3 OS: All
Private report: No CVE-ID: None
 [2010-10-22 06:01 UTC] longhairedgit+bugs dot php dot net at gmail dot com
Description:
------------
It seems to me that http://www.php.net/manual/en/language.namespaces.importing.php
is supposed to be the main documentation of the 'use' keyword for importing
namespaces.
If that's the case, it is woefully inadequate.
Please, look at the language references for any other modern language, and 
add some documentation on the scope of the operator.
Does it have till-end-of-current-file scope? or is it block-scoped? If a file is included, using 'include' for example, is the outer code affected by the 'use' statements within the include.

The same questions go for the namespace operator itself. 

If I do this, to protect users of my library from name clashes:

namespace MyLibrary {

 use AnotherLibrary;

//my library.

}

is only code within the {} affected by the 'use'?
or does code that includes my php file suddendly have AnotherLibrary
also added to their toplevel namespace? or do they have MyLibrary\AnotherLibrary ?

Unless you properly document this, people have to try to make reasonable guesses about these things, or find them out by trial and error.

ie by not documenting it you just leaving it as 'implementation dependent'. 

If there is some other more canonical reference about the language, please add links to it in the manual above!




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-24 16:15 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=304702
Log: Fixed bug #53133 (Scope of use keyword is not documented)
 [2010-10-24 16:15 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-10-24 16:15 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:08 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=eb41c5d7b3755ce421723a0a46bd9d4e309c0481
Log: Fixed bug #53133 (Scope of use keyword is not documented)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 09:00:02 2026 UTC