Feature proposal: userland support for name qualification
| From: | Ignas Rudaitis | Date: | Sat, 31 Jul 2010 12:14:12 +0000 |
| Subject: | Feature proposal: userland support for name qualification | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-49191@lists.php.net to get a copy of this message | ||
Hello php.internals,
Here is a (hopefully) simple language feature I'd like to suggest:
Now that PHP has support for namespaces and therefore makes it
possible to refer to classes, functions and constants by their shorter
unqualified aliases, it would be useful to extend this functionality
to string references to these classes/functions/constants as well.
Perhaps it wouldn't be as useful for constants, but class and function
names need to be used as string literals from time to time, so given
that a statement like "use Foo\Bar\Baz" is present, having a special
syntax for retrieving the fully qualified name as a string, like
Baz::__CLASS__, qualify(Baz) or use(Baz) would save numerous
keystrokes, eliminate possible typos and make refactoring (renaming)
easier.
The use cases that come to my mind are class names in exception
messages, in DI container setup code, also things like Doctrine's
$entityManager->getRepository('Application\Entities\Message') and
callable function name strings.
Of course, if it's actually problematic to implement this, that's
fine, just let me know.
Thanks.