On Wed, Apr 18, 2012 at 1:21 AM, Stas Malyshev <smalys...@sugarcrm.com> wrote: > Hi! > >> Well, not that you mention it, I don't see a reason why we shouldn't >> add run-time resolution where necessary. For once this would allow > > Runtime resolution of what? We already have get_class(), > get_called_class() and __NAMESPACE__. Now, having constant expression > for full class name might be useful since some contexts allow only > constant expressions. But for runtime contexts we already have it. And > there's no such thing as run-time resolution of namespaced class names. Yes, you are right. static::class would be equivalent to get_called_class() and $foo::class would be equivalent to get_class($foo).
>> static::class, but also would allow $obj::class. Not sure this is >> really necessary, but it would be more consistent :) > > $obj::class means "class" constant of the class whose name is given by > string variable $obj. Probably not what you intended. And you have > get_class() already. As already mentioned, There can't be a class constant called "class", because it is a keyword. (const class = 'Foo' is a syntax error). But yes, I agree that runtime resolution only duplicates existing behavior, so it isn't really necessary (you could argue thought that self::class similarly also only replicates the existing __CLASS__). It would be nice for consistency in my eyes, but I'm good without it too :) Nikita -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php