Interfaces name "Interface", was: [PHP-DEV] Re: Idea for namespace lookup resolution

From: Date: Mon, 31 Dec 2007 12:33:14 +0000
Subject: Interfaces name "Interface", was: [PHP-DEV] Re: Idea for namespace lookup resolution
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-34296@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I started a scratch project with this patch and working with it seems intuitive so far. My only question at the moment is the following, however I guess it isn't specific to your NS patch then to Dmitry's: My current practice to declare an interface and provide concrete implementation was like this: file: Foo/Bar/Interface.php interface: Foo_Bar_Interface Now this gets problematic: file: Foo/Bar/Interface.php namespace: Foo::Bar; interface: Interface The last one doesn't work, because the source actually looks like: interface Interface { which gives syntax error, unexpected T_INTERFACE, expecting T_STRING I tried something like namespace Foo; interface Bar::Interface; but that gives another parser error about the :: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '{' Is there any chance for Rescue for this, instead of changing the naming scheme? thanks, - - Markus Jessie Hernandez wrote: > Attached is a patch implementing my proposal. > > Basically, when inside a namespace, you must reference global classes > using ::globalName or by having a "use ::globalName" statement. This > allows classes inside namespaces to have the same name as internal ones > without the need of explicitly "use"-ing them (and prevents clashes with > new internal classes in the future). This only applies to classes, > functions/constants will still follow the current rules, since > __autoload does not apply to them (meaning you won't have to do things > like ::strlen just because you're inside a namespace). > > Also, no errors are generated when using a class with the same name as > an internal class, BUT there is an error if you import/alias a class > with the same name as a global (non-internal) class. The reason for this > is that the user has control of which global classes they're including, > while the same might not be true of internal classes. > > Some tests had to be modified to support the patch, and there might be a > need for additional tests to be included, but at least you can all try > out the patch and see how you feel about these new rules. > > Please look at the patch, try it out, and let me know what you think > about it or if there's anything that can be improved. Thanks. > > > Regards, > > Jessie Hernandez > Zend Certified Engineer (http://zend.com/zce.php?c=ZEND006359&r=222727282) > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHeOGK1nS0RcInK9ARAmsFAKC98h2eUH+CusL/h8X4pT5A3EH3SwCg4Jxg M+S0xyhNEbc/BzLxSY/UO0M= =jR9j -----END PGP SIGNATURE-----

« previous php.internals (#34296) next »