Re: Namespace resolution rules has been changed?
| From: | Gregory Beaver | Date: | Fri, 14 Nov 2008 22:58:31 +0000 |
| Subject: | Re: Namespace resolution rules has been changed? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-41918@lists.php.net to get a copy of this message | ||
Marcin Kurzyna wrote:
> <?php
>
> namespace foo;
>
> use bar as A; /// ->resolves as A == \foo\bar
> use \bar as B; /// ->resolves as B == \bar
>
> ?>
Hi Marcin,
Stan also requested this, so it should be considered as a possibility.
Personally, I would rather not introduce this land mine. It requires
the user to do an implicit prepending of namespace name ("foo") to "bar"
in the use statement as well as a translation of "A", which could fast
lead to unreadable code.
It is probably best to simply require a fully qualified name where it is
intended. Thus
1) require leading "\" in use statements
2) allow "namespace\blah" in use statements, as this is a valid fully
qualified name.
<?php
namespace my\ns;
// this is a better way to do the suggested "use bar as A;"
use namespace\bar as A;
use \bar as B;
class mine extends \my\parentclass {}
?>
Stas, I'm sure you have an opinion on this?
Greg