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

From: Date: Tue, 02 Oct 2007 20:14:17 +0000
Subject: Re: Re: namespaces: import name conflicts with defined class
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-32569@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, Greg Beaver wrote: > Benjamin Schulz wrote: >> Of course i want to refer to my own exception in my application or >> framework as "Exception", and of course i want to use it without >> prefixes (import myStuff::Exception AS MyStuffException), i wouldn't use >> namespace otherwise (there is no other benefit, right?). > > If you are aliasing a class to the same name as an existing class, you > should also import that class with another name: > > <?php > import ::Exception as Notused; > import Foo::Exception; > ?> > > This is somewhat unintuitive, but is pretty simple to solve. But how to know in advance, e.g. think about other libraries, which public classes possibly exist? Isn't this problematic then? - - Markus -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHAqaZ1nS0RcInK9ARAorCAJ9BzOIgcJLqAjK6Oycuy2BLA5YHVQCgn/T/ 06+XdBwY4HSJ6aXJzZU1Sh8= =MRLP -----END PGP SIGNATURE-----

« previous php.internals (#32569) next »