Re: Re: namespaces: import name conflicts with defined class

From: Date: Wed, 03 Oct 2007 16:19:01 +0000
Subject: Re: Re: namespaces: import name conflicts with defined class
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-32604@lists.php.net to get a copy of this message
The exception example is well an exception. Here you must inherit exception. That is simply how PHP works, it is an intended limitation. That said in this case you should not use Exception for your own stuff. Name it after your library or product, like MyProductException.
Hey, i have an idea, why not use namespaces and call it MyProduct::Exception and name everything MyProduct::* - this way i won't get in conflict with global classes, oh wait ...
Right, you might want to have a class DOM because DOM means something different for your company.
Yep, that's why i call it Company::DomDocument, and hey, everyone with a different namespace can import it in his file as "DomDocument", right? That sounds very comfortable to me. *sigh*
Generally you should do all your stuff in a namespace and do not import anything into the global namespace.
You know that import works per File, right? There is no risk that one accidently tries to catch a MyProduct::Exception if he consciously used "import MyProduct::Exception;" in his file. regards, Benjamin

« previous php.internals (#32604) next »