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.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to