proem/proem — Issue #39: Problem with "use" namespace keyword.
Author: trq
Created: 2012-01-16 12:23:31+00:00
State: open
Labels: Bug

I have here what I would refer to as doozy. I'm not sure anyone is going to be able to help as there is allot involved.

The issue could be in a number of locations, I am using PHPUnit as a test suite (and this is how I have found the issue) and PHP5.4rc5. The problem could be in either, or it could be in my code.

I am also using a cascading filesystem (explained [here](https://github.com/proem/proem/wiki/Overriding-framework-classes) and while I'm confident this isn't the issue. It has the potential to be involved I guess. If you need to see how this is implemented it is see here: https://github.com/proem/proem/blob/develop/lib/Proem/Api/Autoloader.php#L108

I have narrowed the problem down to two classes:

https://github.com/proem/proem/blob/develop/lib/Proem/Api/Chain.php & https://github.com/proem/proem/blob/develop/lib/Proem/Api/Proem.php

The tests that test these classes are:

https://github.com/proem/proem/blob/develop/tests/lib/Proem/Tests/ChainTest.php & https://github.com/proem/proem/blob/develop/tests/lib/Proem/Tests/ProemTest.php

As the code stands right now, everything is fine and all tests pass. However, I am about to start some more work on the Proem\Api\Proem class and it needs access to the Proem\Api\Chain class.

To do this, I add the line "use Proem\Chain;", the code becomes:

```
Fatal error: Cannot use Proem\Chain as Chain because the name is already in use in /home/thorpe/src/proem/lib/Proem/Api/Proem.php on line 32

If I alias the namespace ( "use Proem\Chain as C;" ) the tests pass again. The issue is I shouldn't have to use an alias here.

from the manual:
> Note:
>
> Importing rules are per file basis, meaning included files will NOT inherit the parent file's importing rules.[/quote]

Writing this post I have come to realise that the issue is likely that both the Chain class and the Proem class are in the same namespace yet I am trying to force the Chain class to be loaded from Proem\Chain instead of Proem\Api\Chain (this [i]is[/i] part of the cascading filesystem setup).

Anyway, if anyone has some ideas I would be grateful if you could take a look. Otherwise, it looks like I might need to do some re-shuffling.