Are you aware of __NAMESPACE__?  Also, if you are using a lot of
external namespace names, you might consider simply defining constants:

namespace foo\bar\baz;
const ns = __NAMESPACE__;

then you can simply do

use foo\bar\baz;  $name = baz\ns;

I don't see a huge pressing need for nameof since the above is 3 extra
lines of code - total - per NS.

If this sounds good, I will add an example to the new docs
yet-to-be-committed.

Greg

I'm aware of __NAMESPACE__, and your example is kinda creative, but I think that's a touch too much acrobatics for something that's a basic need :P Consider callbacks, factories, strategies, drivers, adapters, proxies and so on which typically may and do pass class/function names around. I don't know.

I'd rather endure the pain and write the string in full every single time than cause extra confusion in my source code :)

Regards, Stan Vassilev

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

Reply via email to