Why not just enhance get_class() function to accept the object itself (not only the instance)?
This means: - No new keyword - No magic Foo::__MIRACLEHERE__ - No 50 pages documentation to help user Regards, On Thu, Jan 22, 2009 at 5:24 AM, Stan Vassilev | FM <sv_for...@fmethod.com> wrote: > > >> Especially in namespaced code it should be very useful to have >> "something" returning fully qualified name as string. It can be operator, >> but I think introducing new keyword is bad way, or it can be realized using >> well known magic constant in new context: >> >> Example: >> >> function factory($class) >> { >> return new $class; >> } >> >> $obj = factory('MyClass'); // returns object MyClass >> $obj = factory(MyClass::__CLASS__); // returns again object MyClass, code >> is little bit more selfexplaining > > > Hi, > > I've discovered this omission earlier and I have proposed two solutions: > > 1) $x = nameof Foo; > > -or- > > 2) $x = Foo::__NAME__; // very similar to yours, Foo::__CLASS__ may even be > better > > Since passing identifier references as strings is relatively pervasive in a > lot of the PHP code out there, I hope this is resolved for 5.3, before we > figure out we need it the hard way after we've littered our code with tons > of manually written out explicit references. > > One problem with your proposal / my second proposal is, it works for > classes, but doesn't address namespaced 1) functions 2) constants. > > A new keyword would address this, but then, who wants a new keyword, > right... > > Regards, > Stan Vassilev > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Guilherme Blanco - Web Developer CBC - Certified Bindows Consultant Cell Phone: +55 (16) 9215-8480 MSN: guilhermebla...@hotmail.com URL: http://blog.bisna.com São Paulo - SP/Brazil -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php