Re: Re: namespaces: import name conflicts with defined class
| From: | Marcus Boerger | Date: | Wed, 03 Oct 2007 15:17:45 +0000 |
| Subject: | Re: Re: namespaces: import name conflicts with defined class | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32599@lists.php.net to get a copy of this message | ||
Hello Benjamin,
if your exception is so general that it is called exception you can
obviously simply use exception. If your exception is actually doing
something than name that something. Meaning the name of the exception class
is carrying information already. Thus every exception should be specialized.
Now namespaces are a tool to help you structure your code and avoid naming
issues. They are not a tool to shorten your names or aid you in typing less.
And especially namespaces are not there to overcome any naming limitations
or tricking the naming rules.
marcus
Wednesday, October 3, 2007, 11:19:00 AM, you wrote:
> On 02.10.2007, at 22:04, Stanislav Malyshev wrote:
>>> <?php
>>> import ::Exception as Notused;
>>> import Foo::Exception;
>>> ?>
>>>
>>
>> I wouldn't actually recommend using such code. If you have
>> Foo::Exception just use Foo::Exception - it's short enough :)
>>
> And what if not? "throw App::package::subpackage::Exception" in a
> file that has the namespace "App::package::subpackage" is just wrong,
> importing the Exception as a different name as well. Importing the
> global Exception as something else - i don't even know what to answer
> to that ... this problem makes the whole concept just seem broken, is
> there even a concept? ;)
> regards,
> Benjamin
Best regards,
Marcus